Skip to content

Commit c7b2891

Browse files
committed
move span to self instead of crate
1 parent 825f8ed commit c7b2891

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

compiler/rustc_resolve/src/build_reduced_graph.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,11 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
469469
}
470470

471471
// Replace `use foo::{ self };` with `use foo;`
472+
let self_span = source.ident.span;
472473
source = module_path.pop().unwrap();
473474
if rename.is_none() {
474-
ident = source.ident;
475+
// Keep the span of `self`, but the name of `foo`
476+
ident = Ident { name: source.ident.name, span: self_span };
475477
}
476478
}
477479
} else {

src/test/ui/use/use-crate-self.rs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
use crate::{self};
2+
//~^ ERROR crate root imports need to be explicitly named: `use crate as name;`
3+
4+
fn main() {}

src/test/ui/use/use-crate-self.stderr

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: crate root imports need to be explicitly named: `use crate as name;`
2+
--> $DIR/use-crate-self.rs:1:13
3+
|
4+
LL | use crate::{self};
5+
| ^^^^
6+
7+
error: aborting due to previous error
8+

0 commit comments

Comments
 (0)