Skip to content

Commit

Permalink
move span to self instead of crate
Browse files Browse the repository at this point in the history
  • Loading branch information
SparkyPotato committed Nov 13, 2022
1 parent 825f8ed commit c7b2891
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compiler/rustc_resolve/src/build_reduced_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,11 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
}

// Replace `use foo::{ self };` with `use foo;`
let self_span = source.ident.span;
source = module_path.pop().unwrap();
if rename.is_none() {
ident = source.ident;
// Keep the span of `self`, but the name of `foo`
ident = Ident { name: source.ident.name, span: self_span };
}
}
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/test/ui/use/use-crate-self.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
use crate::{self};
//~^ ERROR crate root imports need to be explicitly named: `use crate as name;`

fn main() {}
8 changes: 8 additions & 0 deletions src/test/ui/use/use-crate-self.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: crate root imports need to be explicitly named: `use crate as name;`
--> $DIR/use-crate-self.rs:1:13
|
LL | use crate::{self};
| ^^^^

error: aborting due to previous error

0 comments on commit c7b2891

Please sign in to comment.