Distinguish between imported and defined items
This commit is contained in:
parent
d04e83fe2c
commit
8919894c51
3 changed files with 7 additions and 5 deletions
|
@ -489,7 +489,7 @@ pub enum BuiltinLintDiagnostics {
|
|||
UnknownCrateTypes(Span, String, String),
|
||||
UnusedImports(String, Vec<(Span, String)>),
|
||||
NestedImplTrait { outer_impl_trait_span: Span, inner_impl_trait_span: Span },
|
||||
RedundantImport(Vec<Span>, ast::Ident),
|
||||
RedundantImport(Vec<(Span, bool)>, ast::Ident),
|
||||
}
|
||||
|
||||
impl BuiltinLintDiagnostics {
|
||||
|
@ -587,10 +587,11 @@ impl BuiltinLintDiagnostics {
|
|||
db.span_label(inner_impl_trait_span, "nested `impl Trait` here");
|
||||
}
|
||||
BuiltinLintDiagnostics::RedundantImport(spans, ident) => {
|
||||
for span in spans {
|
||||
for (span, is_imported) in spans {
|
||||
let introduced = if is_imported { "imported" } else { "defined" };
|
||||
db.span_label(
|
||||
span,
|
||||
format!("the item `{}` was already imported here", ident)
|
||||
format!("the item `{}` was {} here", ident, introduced)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1295,7 +1295,8 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
|
|||
) {
|
||||
Ok(other_binding) => {
|
||||
is_redundant[ns] = Some(binding.def() == other_binding.def());
|
||||
redundant_span[ns] = Some(other_binding.span);
|
||||
redundant_span[ns] =
|
||||
Some((other_binding.span, other_binding.is_import()));
|
||||
}
|
||||
Err(_) => is_redundant[ns] = Some(false)
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ warning: the item `Bar` is imported redundantly
|
|||
--> $DIR/use-redundant.rs:14:9
|
||||
|
|
||||
LL | use crate::foo::Bar;
|
||||
| --------------- the item `Bar` was already imported here
|
||||
| --------------- the item `Bar` was imported here
|
||||
...
|
||||
LL | use crate::foo::Bar;
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
Loading…
Reference in a new issue