1
Fork 0

move span to self instead of crate

This commit is contained in:
SparkyPotato 2022-11-13 13:46:11 +05:30
parent 825f8edc2f
commit c7b2891315
3 changed files with 15 additions and 1 deletions

View file

@ -469,9 +469,11 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
} }
// Replace `use foo::{ self };` with `use foo;` // Replace `use foo::{ self };` with `use foo;`
let self_span = source.ident.span;
source = module_path.pop().unwrap(); source = module_path.pop().unwrap();
if rename.is_none() { 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 { } else {

View file

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

View file

@ -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