forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#58381 - davidtwco:issue-42944, r=estebank
Only suggest imports if not imported. Fixes rust-lang#42944 and fixes rust-lang#53430. This commit modifies name resolution error reporting so that if a name is in scope and has been imported then we do not suggest importing it. This can occur when we add a label about constructors not being visible due to private fields. In these cases, we know that the struct/variant has been imported and we should silence any suggestions to import the struct/variant. r? @estebank
- Loading branch information
Showing
5 changed files
with
63 additions
and
17 deletions.
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
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,19 @@ | ||
mod foo { | ||
pub struct B(()); | ||
} | ||
|
||
mod bar { | ||
use foo::B; | ||
|
||
fn foo() { | ||
B(()); //~ ERROR expected function, found struct `B` [E0423] | ||
} | ||
} | ||
|
||
mod baz { | ||
fn foo() { | ||
B(()); //~ ERROR cannot find function `B` in this scope [E0425] | ||
} | ||
} | ||
|
||
fn main() {} |
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,20 @@ | ||
error[E0423]: expected function, found struct `B` | ||
--> $DIR/issue-42944.rs:9:9 | ||
| | ||
LL | B(()); //~ ERROR expected function, found struct `B` [E0423] | ||
| ^ constructor is not visible here due to private fields | ||
|
||
error[E0425]: cannot find function `B` in this scope | ||
--> $DIR/issue-42944.rs:15:9 | ||
| | ||
LL | B(()); //~ ERROR cannot find function `B` in this scope [E0425] | ||
| ^ not found in this scope | ||
help: possible candidate is found in another module, you can import it into scope | ||
| | ||
LL | use foo::B; | ||
| | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors occurred: E0423, E0425. | ||
For more information about an error, try `rustc --explain E0423`. |
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