diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 40a98d74f33..60f0ad9e30d 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -986,6 +986,9 @@ impl<'a> Resolver<'a> { import.span, &format!("`{}` is imported here, but {}", ident, it_is), ); + // Silence the 'unused import' warning we might get, + // since this diagnostic already covers that import. + self.record_use(ident, binding, false); return; } } diff --git a/src/test/ui/macros/issue-88206.rs b/src/test/ui/macros/issue-88206.rs index 67b7448a3ed..f0dab54c149 100644 --- a/src/test/ui/macros/issue-88206.rs +++ b/src/test/ui/macros/issue-88206.rs @@ -1,11 +1,9 @@ // compile-flags: -Z deduplicate-diagnostics=yes #![warn(unused_imports)] -//~^ NOTE lint level use std::str::*; -//~^ WARNING unused import -//~| NOTE `from_utf8` is imported here, but it is not a macro +//~^ NOTE `from_utf8` is imported here, but it is not a macro //~| NOTE `from_utf8_mut` is imported here, but it is not a derive macro //~| NOTE `from_utf8_unchecked` is imported here, but it is not an attribute @@ -15,8 +13,7 @@ mod hey { } use hey::{Serialize, Deserialize}; -//~^ WARNING unused import -//~| NOTE `Serialize` is imported here, but it is not a derive macro +//~^ NOTE `Serialize` is imported here, but it is not a derive macro //~| NOTE `Deserialize` is imported here, but it is not an attribute #[derive(Serialize)] diff --git a/src/test/ui/macros/issue-88206.stderr b/src/test/ui/macros/issue-88206.stderr index 4e45de2ee3e..b6fd606e28c 100644 --- a/src/test/ui/macros/issue-88206.stderr +++ b/src/test/ui/macros/issue-88206.stderr @@ -1,5 +1,5 @@ error: cannot find macro `test` in this scope - --> $DIR/issue-88206.rs:60:5 + --> $DIR/issue-88206.rs:57:5 | LL | test!(); | ^^^^ @@ -7,7 +7,7 @@ LL | test!(); = note: `test` is in scope, but it is an attribute error: cannot find macro `Copy` in this scope - --> $DIR/issue-88206.rs:56:5 + --> $DIR/issue-88206.rs:53:5 | LL | Copy!(); | ^^^^ @@ -15,7 +15,7 @@ LL | Copy!(); = note: `Copy` is in scope, but it is a derive macro error: cannot find macro `Box` in this scope - --> $DIR/issue-88206.rs:52:5 + --> $DIR/issue-88206.rs:49:5 | LL | Box!(); | ^^^ @@ -23,19 +23,19 @@ LL | Box!(); = note: `Box` is in scope, but it is not a macro error: cannot find macro `from_utf8` in this scope - --> $DIR/issue-88206.rs:49:5 + --> $DIR/issue-88206.rs:46:5 | LL | from_utf8!(); | ^^^^^^^^^ | note: `from_utf8` is imported here, but it is not a macro - --> $DIR/issue-88206.rs:6:5 + --> $DIR/issue-88206.rs:5:5 | LL | use std::str::*; | ^^^^^^^^^^^ error: cannot find attribute `println` in this scope - --> $DIR/issue-88206.rs:43:3 + --> $DIR/issue-88206.rs:40:3 | LL | #[println] | ^^^^^^^ @@ -43,31 +43,31 @@ LL | #[println] = note: `println` is in scope, but it is a function-like macro error: cannot find attribute `from_utf8_unchecked` in this scope - --> $DIR/issue-88206.rs:39:3 + --> $DIR/issue-88206.rs:36:3 | LL | #[from_utf8_unchecked] | ^^^^^^^^^^^^^^^^^^^ | note: `from_utf8_unchecked` is imported here, but it is not an attribute - --> $DIR/issue-88206.rs:6:5 + --> $DIR/issue-88206.rs:5:5 | LL | use std::str::*; | ^^^^^^^^^^^ error: cannot find attribute `Deserialize` in this scope - --> $DIR/issue-88206.rs:35:3 + --> $DIR/issue-88206.rs:32:3 | LL | #[Deserialize] | ^^^^^^^^^^^ | note: `Deserialize` is imported here, but it is not an attribute - --> $DIR/issue-88206.rs:17:22 + --> $DIR/issue-88206.rs:15:22 | LL | use hey::{Serialize, Deserialize}; | ^^^^^^^^^^^ error: cannot find derive macro `println` in this scope - --> $DIR/issue-88206.rs:30:10 + --> $DIR/issue-88206.rs:27:10 | LL | #[derive(println)] | ^^^^^^^ @@ -75,46 +75,28 @@ LL | #[derive(println)] = note: `println` is in scope, but it is a function-like macro error: cannot find derive macro `from_utf8_mut` in this scope - --> $DIR/issue-88206.rs:26:10 + --> $DIR/issue-88206.rs:23:10 | LL | #[derive(from_utf8_mut)] | ^^^^^^^^^^^^^ | note: `from_utf8_mut` is imported here, but it is not a derive macro - --> $DIR/issue-88206.rs:6:5 + --> $DIR/issue-88206.rs:5:5 | LL | use std::str::*; | ^^^^^^^^^^^ error: cannot find derive macro `Serialize` in this scope - --> $DIR/issue-88206.rs:22:10 + --> $DIR/issue-88206.rs:19:10 | LL | #[derive(Serialize)] | ^^^^^^^^^ | note: `Serialize` is imported here, but it is not a derive macro - --> $DIR/issue-88206.rs:17:11 + --> $DIR/issue-88206.rs:15:11 | LL | use hey::{Serialize, Deserialize}; | ^^^^^^^^^ -warning: unused import: `std::str::*` - --> $DIR/issue-88206.rs:6:5 - | -LL | use std::str::*; - | ^^^^^^^^^^^ - | -note: the lint level is defined here - --> $DIR/issue-88206.rs:3:9 - | -LL | #![warn(unused_imports)] - | ^^^^^^^^^^^^^^ - -warning: unused imports: `Deserialize`, `Serialize` - --> $DIR/issue-88206.rs:17:11 - | -LL | use hey::{Serialize, Deserialize}; - | ^^^^^^^^^ ^^^^^^^^^^^ - -error: aborting due to 10 previous errors; 2 warnings emitted +error: aborting due to 10 previous errors