Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2223,7 +2223,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
match binding.kind {
NameBindingKind::Import { import, .. } => {
for segment in import.module_path.iter().skip(1) {
path.push(segment.ident);
// Don't include `{{root}}` in suggestions - it's an internal symbol
// that should never be shown to users.
if segment.ident.name != kw::PathRoot {
path.push(segment.ident);
}
}
sugg_paths.push((
path.iter().cloned().chain(std::iter::once(ident)).collect::<Vec<_>>(),
Expand Down
13 changes: 13 additions & 0 deletions tests/ui/imports/nested-import-root-symbol-150103.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Issue: https://github.com/rust-lang/rust/issues/150103
// ICE when using `::` at start of nested imports
// caused by `{{root}}` appearing in diagnostic suggestions

mod A {
use Iuse::{ ::Fish }; //~ ERROR failed to resolve: use of unresolved module or unlinked crate
}

mod B {
use A::{::Fish}; //~ ERROR failed to resolve: crate root in paths can only be used in start position
}

fn main() {}
20 changes: 20 additions & 0 deletions tests/ui/imports/nested-import-root-symbol-150103.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
error[E0433]: failed to resolve: use of unresolved module or unlinked crate `Iuse`
--> $DIR/nested-import-root-symbol-150103.rs:6:9
|
LL | use Iuse::{ ::Fish };
| ^^^^ use of unresolved module or unlinked crate `Iuse`
|
help: you might be missing a crate named `Iuse`, add it to your project and import it in your code
|
LL + extern crate Iuse;
|

error[E0433]: failed to resolve: crate root in paths can only be used in start position
--> $DIR/nested-import-root-symbol-150103.rs:10:13
|
LL | use A::{::Fish};
| ^ crate root in paths can only be used in start position

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0433`.
Loading