Skip to content

Commit

Permalink
Silence unused_imports if import comes from glob
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Apr 10, 2024
1 parent 5974fe8 commit 9934593
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 37 deletions.
5 changes: 3 additions & 2 deletions compiler/rustc_resolve/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1375,8 +1375,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
target_bindings[ns].get(),
) {
Ok(other_binding) => {
is_redundant =
binding.res() == other_binding.res() && !other_binding.is_ambiguity();
is_redundant = binding.res() == other_binding.res()
&& !other_binding.is_ambiguity()
&& !other_binding.is_glob_import();
if is_redundant {
redundant_span[ns] =
Some((other_binding.span, other_binding.is_import()));
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/lint/use-redundant/use-redundant-glob-parent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub mod bar {
use bar::*;

pub fn warning() -> Foo {
use bar::Foo; //~ WARNING imported redundantly
use bar::Foo; //FIXME(unused_imports): ~ WARNING imported redundantly
Foo(Bar('a'))
}

Expand Down
17 changes: 0 additions & 17 deletions tests/ui/lint/use-redundant/use-redundant-glob-parent.stderr

This file was deleted.

2 changes: 1 addition & 1 deletion tests/ui/lint/use-redundant/use-redundant-glob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub mod bar {

pub fn warning() -> bar::Foo {
use bar::*;
use bar::Foo; //~ WARNING imported redundantly
use bar::Foo; //FIXME(unused_imports): ~ WARNING imported redundantly
Foo(Bar('a'))
}

Expand Down
16 changes: 0 additions & 16 deletions tests/ui/lint/use-redundant/use-redundant-glob.stderr

This file was deleted.

0 comments on commit 9934593

Please sign in to comment.