-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First attempt at fixing #20591 #24818
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
74648b5
First attempt at fixing #20591
tbelaire 168615f
Now passing in the ImportResolver to check_conflict...
tbelaire 69a5c37
Maybe it works
tbelaire 5c05278
Fixed types, and slimmed down code
tbelaire 372c69d
Fixed test text
tbelaire db9d018
Fixed some nits
tbelaire File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
#![feature(no_std)] | ||
#![no_std] | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a comment explaining what is being tested to the test file |
||
// This tests that conflicting imports shows both `use` lines | ||
// when reporting the error. | ||
|
||
mod sub1 { | ||
fn foo() {} // implementation 1 | ||
} | ||
|
||
mod sub2 { | ||
fn foo() {} // implementation 2 | ||
} | ||
|
||
use sub1::foo; //~ NOTE previous import of `foo` here | ||
use sub2::foo; //~ ERROR a value named `foo` has already been imported in this module [E0252] | ||
|
||
fn main() {} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I'd prefer a type annotation in code rather than in a comment.
(I won't block this PR on that nit; it's more a note for the future...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I always feel so weirded out when just annotating the type is what forces an import. I went back and forth on that line, it felt strange to be the only line importing from syntax::map.
Just as a style note, I feel like it'd be easier to navigate the code if even more type annotations were placed, (or I had a IDE which could tell me the type on mouseover). But I'm sure the core team already knows the types of most of the functions, so it's unnecessary for them, and in fact, just extra noise.
Which way should I favour in general? I'm hesitant to break with the established style, but I feel it'd be helpful to the newer contributors to add a fair number of annotations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DXR, which should be coming online soon, does type on mouse-over for most variables.
I'd probably remove the comment and not add an annotation, tbh - I think a programmer should probably expect the result of
expect_item
to be anItem
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aye, but what kind of item?
syntax ::map
isn't even imported.I know I had to open up a number of files side by side and carefully trace through struct and function definitions to pin down some types in this block. A simple type annotation or two would have saved me at least 10 minutes of tracking things down.