forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
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#106175 - compiler-errors:bad-import-sugg, r…
…=oli-obk Fix bad import suggestion with nested `use` tree Fixes rust-lang#105566 Fixes rust-lang#105373 Ideally, we'd find some way to turn these into structured suggestions -- perhaps on a separate line as a different `use` statement, but I have no idea how to access the span for the whole `use` from this point in the import resolution code.
- Loading branch information
Showing
8 changed files
with
167 additions
and
43 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
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 @@ | ||
// edition: 2021 | ||
|
||
#![allow(unused)] | ||
|
||
mod A { | ||
pub(crate) type AA = (); | ||
pub(crate) type BB = (); | ||
|
||
mod A2 { | ||
use super::{super::C::D::AA, AA as _}; | ||
//~^ ERROR unresolved import | ||
} | ||
} | ||
|
||
mod C { | ||
pub mod D {} | ||
} | ||
|
||
mod B { | ||
use crate::C::{self, AA}; | ||
//~^ ERROR unresolved import | ||
|
||
use crate::{A, C::BB}; | ||
//~^ ERROR unresolved import | ||
} | ||
|
||
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,30 @@ | ||
error[E0432]: unresolved import `super::super::C::D::AA` | ||
--> $DIR/bad-import-in-nested.rs:10:21 | ||
| | ||
LL | use super::{super::C::D::AA, AA as _}; | ||
| ^^^^^^^^^^^^^^^ no `AA` in `C::D` | ||
| | ||
= note: consider importing this type alias instead: | ||
crate::A::AA | ||
|
||
error[E0432]: unresolved import `crate::C::AA` | ||
--> $DIR/bad-import-in-nested.rs:20:26 | ||
| | ||
LL | use crate::C::{self, AA}; | ||
| ^^ no `AA` in `C` | ||
| | ||
= note: consider importing this type alias instead: | ||
crate::A::AA | ||
|
||
error[E0432]: unresolved import `crate::C::BB` | ||
--> $DIR/bad-import-in-nested.rs:23:20 | ||
| | ||
LL | use crate::{A, C::BB}; | ||
| ^^^^^ no `BB` in `C` | ||
| | ||
= note: consider importing this type alias instead: | ||
crate::A::BB | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0432`. |
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,16 @@ | ||
mod A { | ||
pub type B = (); | ||
pub type B2 = (); | ||
} | ||
|
||
mod C { | ||
use crate::D::B as _; | ||
//~^ ERROR unresolved import `crate::D::B` | ||
|
||
use crate::D::B2; | ||
//~^ ERROR unresolved import `crate::D::B2` | ||
} | ||
|
||
mod D {} | ||
|
||
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,25 @@ | ||
error[E0432]: unresolved import `crate::D::B` | ||
--> $DIR/bad-import-with-rename.rs:7:9 | ||
| | ||
LL | use crate::D::B as _; | ||
| ^^^^^^^^^^^^^^^^ no `B` in `D` | ||
| | ||
help: consider importing this type alias instead | ||
| | ||
LL | use A::B as _; | ||
| ~~~~~~~~~~ | ||
|
||
error[E0432]: unresolved import `crate::D::B2` | ||
--> $DIR/bad-import-with-rename.rs:10:9 | ||
| | ||
LL | use crate::D::B2; | ||
| ^^^^^^^^^^^^ no `B2` in `D` | ||
| | ||
help: consider importing this type alias instead | ||
| | ||
LL | use A::B2; | ||
| ~~~~~~ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0432`. |
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