Rollup merge of #104315 - SparkyPotato:fix-104276, r=cjgillot

Improve spans with `use crate::{self}`

Fixes #104276.

The error becomes:
```
error: crate root imports need to be explicitly named: `use crate as name;`
 --> src/lib.rs.rs:1:13
  |
1 | use crate::{self};
  |             ^^^^

warning: unused import: `self`
 --> src/lib.rs:1:13
  |
1 | use crate::{self};
  |             ^^^^
  |
  = note: `#[warn(unused_imports)]` on by default
```
This commit is contained in:
Matthias Krüger 2022-11-13 17:37:37 +01:00 committed by GitHub
commit 5c764da9b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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;`
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 {