about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2023-04-10 16:46:12 +0000
committerEsteban Küber <esteban@kuber.com.ar>2023-04-12 22:50:10 +0000
commit9fadcc143a49a124fa1d0d3261593defb986a987 (patch)
tree893e65c8134b89447a09716b0d0c34979a94cc22
parent5b40aa5eb484b31c9a82c1b1a0f414840477b9ea (diff)
downloadrust-9fadcc143a49a124fa1d0d3261593defb986a987.tar.gz
rust-9fadcc143a49a124fa1d0d3261593defb986a987.zip
Special-case item attributes in the suggestion output
-rw-r--r--compiler/rustc_errors/src/emitter.rs11
-rw-r--r--src/tools/clippy/tests/ui/crashes/ice-6252.stderr3
-rw-r--r--src/tools/clippy/tests/ui/new_without_default.stderr6
-rw-r--r--tests/ui/coherence/coherence_inherent.stderr1
-rw-r--r--tests/ui/coherence/coherence_inherent_cc.stderr1
-rw-r--r--tests/ui/const-generics/generic_const_exprs/issue-94287.stderr1
-rw-r--r--tests/ui/const-generics/issues/issue-82956.stderr4
-rw-r--r--tests/ui/derived-errors/issue-31997-1.stderr1
-rw-r--r--tests/ui/did_you_mean/issue-56028-there-is-an-enum-variant.stderr4
-rw-r--r--tests/ui/hygiene/globs.stderr2
-rw-r--r--tests/ui/hygiene/no_implicit_prelude.stderr2
-rw-r--r--tests/ui/hygiene/trait_items.stderr1
-rw-r--r--tests/ui/impl-trait/no-method-suggested-traits.stderr12
-rw-r--r--tests/ui/impl-trait/universal_wrong_bounds.stderr2
-rw-r--r--tests/ui/imports/glob-resolve1.stderr1
-rw-r--r--tests/ui/imports/issue-38293.stderr1
-rw-r--r--tests/ui/imports/issue-4366-2.stderr1
-rw-r--r--tests/ui/imports/issue-4366.stderr1
-rw-r--r--tests/ui/imports/overlapping_pub_trait.stderr1
-rw-r--r--tests/ui/imports/unnamed_pub_trait.stderr1
-rw-r--r--tests/ui/issues/issue-10465.stderr1
-rw-r--r--tests/ui/issues/issue-17546.stderr8
-rw-r--r--tests/ui/issues/issue-35976.unimported.stderr1
-rw-r--r--tests/ui/issues/issue-37534.stderr1
-rw-r--r--tests/ui/issues/issue-39175.stderr1
-rw-r--r--tests/ui/issues/issue-56175.stderr2
-rw-r--r--tests/ui/issues/issue-77919.stderr1
-rw-r--r--tests/ui/layout/issue-84108.stderr2
-rw-r--r--tests/ui/macros/issue-100199.stderr1
-rw-r--r--tests/ui/macros/macro-outer-attributes.stderr1
-rw-r--r--tests/ui/namespace/namespace-mix.stderr8
-rw-r--r--tests/ui/parser/circular_modules_main.stderr1
-rw-r--r--tests/ui/privacy/privacy-ns1.stderr3
-rw-r--r--tests/ui/privacy/privacy-ns2.stderr3
-rw-r--r--tests/ui/proc-macro/amputate-span.stderr2
-rw-r--r--tests/ui/proc-macro/attributes-on-modules-fail.stderr2
-rw-r--r--tests/ui/resolve/crate-in-paths.stderr1
-rw-r--r--tests/ui/resolve/enums-are-namespaced-xc.stderr3
-rw-r--r--tests/ui/resolve/filter-intrinsics.stderr2
-rw-r--r--tests/ui/resolve/issue-102946.stderr1
-rw-r--r--tests/ui/resolve/issue-16058.stderr3
-rw-r--r--tests/ui/resolve/issue-17518.stderr1
-rw-r--r--tests/ui/resolve/issue-21221-1.stderr7
-rw-r--r--tests/ui/resolve/issue-21221-2.stderr2
-rw-r--r--tests/ui/resolve/issue-21221-3.stderr1
-rw-r--r--tests/ui/resolve/issue-21221-4.stderr1
-rw-r--r--tests/ui/resolve/issue-2356.stderr1
-rw-r--r--tests/ui/resolve/issue-26545.stderr1
-rw-r--r--tests/ui/resolve/issue-35675.stderr2
-rw-r--r--tests/ui/resolve/issue-3907.stderr1
-rw-r--r--tests/ui/resolve/issue-50599.stderr2
-rw-r--r--tests/ui/resolve/issue-73427.stderr2
-rw-r--r--tests/ui/resolve/issue-90113.stderr1
-rw-r--r--tests/ui/resolve/missing-in-namespace.stderr1
-rw-r--r--tests/ui/resolve/no-implicit-prelude-nested.stderr15
-rw-r--r--tests/ui/resolve/no-implicit-prelude.stderr5
-rw-r--r--tests/ui/resolve/privacy-enum-ctor.stderr4
-rw-r--r--tests/ui/resolve/resolve-primitive-fallback.stderr1
-rw-r--r--tests/ui/resolve/use_suggestion.stderr2
-rw-r--r--tests/ui/resolve/use_suggestion_placement.stderr3
-rw-r--r--tests/ui/rust-2018/issue-52202-use-suggestions.stderr4
-rw-r--r--tests/ui/rust-2018/trait-import-suggestions.stderr3
-rw-r--r--tests/ui/rust-2018/uniform-paths/issue-87932.stderr1
-rw-r--r--tests/ui/rust-2021/future-prelude-collision-shadow.stderr2
-rw-r--r--tests/ui/self/class-missing-self.stderr1
-rw-r--r--tests/ui/shadowed/shadowed-trait-methods.stderr1
-rw-r--r--tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.stderr1
-rw-r--r--tests/ui/span/issue-35987.stderr1
-rw-r--r--tests/ui/suggestions/core-std-import-order-issue-83564.stderr2
-rw-r--r--tests/ui/suggestions/dont-wrap-ambiguous-receivers.stderr2
-rw-r--r--tests/ui/suggestions/import-trait-for-method-call.stderr1
-rw-r--r--tests/ui/suggestions/no-extern-crate-in-type.stderr1
-rw-r--r--tests/ui/suggestions/raw-name-use-suggestion.stderr1
-rw-r--r--tests/ui/suggestions/suggest-tryinto-edition-change.stderr7
-rw-r--r--tests/ui/suggestions/use-placement-resolve.stderr1
-rw-r--r--tests/ui/suggestions/use-placement-typeck.stderr1
-rw-r--r--tests/ui/trait-bounds/impl-bound-with-references-error.stderr1
-rw-r--r--tests/ui/trait-bounds/shadowed-path-in-trait-bound-suggestion.stderr1
-rw-r--r--tests/ui/traits/issue-78372.stderr1
-rw-r--r--tests/ui/traits/item-privacy.stderr3
-rw-r--r--tests/ui/traits/method-private.stderr1
-rw-r--r--tests/ui/typeck/issue-43189.stderr1
-rw-r--r--tests/ui/underscore-imports/shadow.stderr1
-rw-r--r--tests/ui/unresolved/unresolved-candidates.stderr1
84 files changed, 10 insertions, 188 deletions
diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs
index 7b6d65511c1..fe44799efdb 100644
--- a/compiler/rustc_errors/src/emitter.rs
+++ b/compiler/rustc_errors/src/emitter.rs
@@ -1886,6 +1886,7 @@ impl EmitterWriter {
             }
             let mut unhighlighted_lines = Vec::new();
             let mut last_pos = 0;
+            let mut is_item_attribute = false;
             for (line_pos, (line, highlight_parts)) in lines.by_ref().zip(highlights).enumerate() {
                 last_pos = line_pos;
                 debug!(%line_pos, %line, ?highlight_parts);
@@ -1895,6 +1896,12 @@ impl EmitterWriter {
                     unhighlighted_lines.push((line_pos, line));
                     continue;
                 }
+                if highlight_parts.len() == 1
+                    && line.trim().starts_with("#[")
+                    && line.trim().ends_with(']')
+                {
+                    is_item_attribute = true;
+                }
 
                 match unhighlighted_lines.len() {
                     0 => (),
@@ -1971,11 +1978,13 @@ impl EmitterWriter {
                     is_multiline,
                 )
             }
-            if let DisplaySuggestion::Add = show_code_change {
+            if let DisplaySuggestion::Add = show_code_change && is_item_attribute {
                 // The suggestion adds an entire line of code, ending on a newline, so we'll also
                 // print the *following* line, to provide context of what we're advicing people to
                 // do. Otherwise you would only see contextless code that can be confused for
                 // already existing code, despite the colors and UI elements.
+                // We special case `#[derive(_)]\n` and other attribute suggestions, because those
+                // are the ones where context is most useful.
                 let file_lines = sm
                     .span_to_lines(span.primary_span().unwrap().shrink_to_hi())
                     .expect("span_to_lines failed when emitting suggestion");
diff --git a/src/tools/clippy/tests/ui/crashes/ice-6252.stderr b/src/tools/clippy/tests/ui/crashes/ice-6252.stderr
index 3c7e08ebeae..4787282f504 100644
--- a/src/tools/clippy/tests/ui/crashes/ice-6252.stderr
+++ b/src/tools/clippy/tests/ui/crashes/ice-6252.stderr
@@ -7,13 +7,10 @@ LL |     _n: PhantomData,
 help: consider importing one of these items
    |
 LL + use core::marker::PhantomData;
-LL | trait TypeVal<T> {
    |
 LL + use serde::__private::PhantomData;
-LL | trait TypeVal<T> {
    |
 LL + use std::marker::PhantomData;
-LL | trait TypeVal<T> {
    |
 
 error[E0412]: cannot find type `VAL` in this scope
diff --git a/src/tools/clippy/tests/ui/new_without_default.stderr b/src/tools/clippy/tests/ui/new_without_default.stderr
index 9b0a2f6ca5b..583dd327d6a 100644
--- a/src/tools/clippy/tests/ui/new_without_default.stderr
+++ b/src/tools/clippy/tests/ui/new_without_default.stderr
@@ -14,7 +14,6 @@ LL +     fn default() -> Self {
 LL +         Self::new()
 LL +     }
 LL + }
-LL | impl Foo {
    |
 
 error: you should consider adding a `Default` implementation for `Bar`
@@ -32,7 +31,6 @@ LL +     fn default() -> Self {
 LL +         Self::new()
 LL +     }
 LL + }
-LL | impl Bar {
    |
 
 error: you should consider adding a `Default` implementation for `LtKo<'c>`
@@ -50,7 +48,6 @@ LL +     fn default() -> Self {
 LL +         Self::new()
 LL +     }
 LL + }
-LL | impl<'c> LtKo<'c> {
    |
 
 error: you should consider adding a `Default` implementation for `NewNotEqualToDerive`
@@ -68,7 +65,6 @@ LL +     fn default() -> Self {
 LL +         Self::new()
 LL +     }
 LL + }
-LL | impl NewNotEqualToDerive {
    |
 
 error: you should consider adding a `Default` implementation for `FooGenerics<T>`
@@ -86,7 +82,6 @@ LL +     fn default() -> Self {
 LL +         Self::new()
 LL +     }
 LL + }
-LL | impl<T> FooGenerics<T> {
    |
 
 error: you should consider adding a `Default` implementation for `BarGenerics<T>`
@@ -104,7 +99,6 @@ LL +     fn default() -> Self {
 LL +         Self::new()
 LL +     }
 LL + }
-LL | impl<T: Copy> BarGenerics<T> {
    |
 
 error: you should consider adding a `Default` implementation for `Foo<T>`
diff --git a/tests/ui/coherence/coherence_inherent.stderr b/tests/ui/coherence/coherence_inherent.stderr
index 48f70700046..b381b068073 100644
--- a/tests/ui/coherence/coherence_inherent.stderr
+++ b/tests/ui/coherence/coherence_inherent.stderr
@@ -8,7 +8,6 @@ LL |         s.the_fn();
 help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
 LL +     use Lib::TheTrait;
-LL |     use Lib::TheStruct;
    |
 
 error: aborting due to previous error
diff --git a/tests/ui/coherence/coherence_inherent_cc.stderr b/tests/ui/coherence/coherence_inherent_cc.stderr
index 58254740f82..7b6cb7d4390 100644
--- a/tests/ui/coherence/coherence_inherent_cc.stderr
+++ b/tests/ui/coherence/coherence_inherent_cc.stderr
@@ -8,7 +8,6 @@ LL |         s.the_fn();
 help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
 LL +     use coherence_inherent_cc_lib::TheTrait;
-LL |     use coherence_inherent_cc_lib::TheStruct;
    |
 
 error: aborting due to previous error
diff --git a/tests/ui/const-generics/generic_const_exprs/issue-94287.stderr b/tests/ui/const-generics/generic_const_exprs/issue-94287.stderr
index 1e4e4edb596..dc7d0c54fcc 100644
--- a/tests/ui/const-generics/generic_const_exprs/issue-94287.stderr
+++ b/tests/ui/const-generics/generic_const_exprs/issue-94287.stderr
@@ -9,7 +9,6 @@ help: consider enabling this feature
   --> $DIR/issue-94287.rs:1:1
    |
 LL + #![feature(generic_const_exprs)]
-LL | #![feature(generic_const_exprs)]
    |
 
 error: aborting due to previous error
diff --git a/tests/ui/const-generics/issues/issue-82956.stderr b/tests/ui/const-generics/issues/issue-82956.stderr
index d1d50732551..d70c8d0bfbf 100644
--- a/tests/ui/const-generics/issues/issue-82956.stderr
+++ b/tests/ui/const-generics/issues/issue-82956.stderr
@@ -7,16 +7,12 @@ LL |         let mut iter = IntoIter::new(self);
 help: consider importing one of these items
    |
 LL + use std::array::IntoIter;
-LL | pub struct ConstCheck<const CHECK: bool>;
    |
 LL + use std::collections::binary_heap::IntoIter;
-LL | pub struct ConstCheck<const CHECK: bool>;
    |
 LL + use std::collections::btree_map::IntoIter;
-LL | pub struct ConstCheck<const CHECK: bool>;
    |
 LL + use std::collections::btree_set::IntoIter;
-LL | pub struct ConstCheck<const CHECK: bool>;
    |
      and 8 other candidates
 
diff --git a/tests/ui/derived-errors/issue-31997-1.stderr b/tests/ui/derived-errors/issue-31997-1.stderr
index 2ea3d910dbf..a0262f4c1e5 100644
--- a/tests/ui/derived-errors/issue-31997-1.stderr
+++ b/tests/ui/derived-errors/issue-31997-1.stderr
@@ -7,7 +7,6 @@ LL |     let mut map = HashMap::new();
 help: consider importing this struct
    |
 LL + use std::collections::HashMap;
-LL | use std::io::prelude::*;
    |
 
 error: aborting due to previous error
diff --git a/tests/ui/did_you_mean/issue-56028-there-is-an-enum-variant.stderr b/tests/ui/did_you_mean/issue-56028-there-is-an-enum-variant.stderr
index 11cdcfadef3..5c610f36322 100644
--- a/tests/ui/did_you_mean/issue-56028-there-is-an-enum-variant.stderr
+++ b/tests/ui/did_you_mean/issue-56028-there-is-an-enum-variant.stderr
@@ -25,16 +25,12 @@ LL | fn setup() -> Set { Set }
 help: consider importing one of these items
    |
 LL + use AffixHeart::Set;
-LL | enum PutDown { Set }
    |
 LL + use CauseToBe::Set;
-LL | enum PutDown { Set }
    |
 LL + use Determine::Set;
-LL | enum PutDown { Set }
    |
 LL + use PutDown::Set;
-LL | enum PutDown { Set }
    |
      and 3 other candidates
 
diff --git a/tests/ui/hygiene/globs.stderr b/tests/ui/hygiene/globs.stderr
index b68950b66db..18017264440 100644
--- a/tests/ui/hygiene/globs.stderr
+++ b/tests/ui/hygiene/globs.stderr
@@ -14,7 +14,6 @@ LL |         g();
 help: consider importing this function
    |
 LL + use foo::f;
-LL | mod foo {
    |
 
 error[E0425]: cannot find function `g` in this scope
@@ -41,7 +40,6 @@ LL |     f();
 help: consider importing this function
    |
 LL + use bar::g;
-LL | mod foo {
    |
 
 error[E0425]: cannot find function `f` in this scope
diff --git a/tests/ui/hygiene/no_implicit_prelude.stderr b/tests/ui/hygiene/no_implicit_prelude.stderr
index 21cecfefd34..96187b1c501 100644
--- a/tests/ui/hygiene/no_implicit_prelude.stderr
+++ b/tests/ui/hygiene/no_implicit_prelude.stderr
@@ -11,7 +11,6 @@ LL |         Vec::new();
 help: consider importing this struct
    |
 LL +     use std::vec::Vec;
-LL |     pub macro m() { Vec::<i32>::new(); ().clone() }
    |
 
 error[E0599]: no method named `clone` found for unit type `()` in the current scope
@@ -28,7 +27,6 @@ LL |         ().clone()
 help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
 LL +     use std::clone::Clone;
-LL |     pub macro m() { Vec::<i32>::new(); ().clone() }
    |
 
 error: aborting due to 2 previous errors
diff --git a/tests/ui/hygiene/trait_items.stderr b/tests/ui/hygiene/trait_items.stderr
index 60cf6787f82..f303534c709 100644
--- a/tests/ui/hygiene/trait_items.stderr
+++ b/tests/ui/hygiene/trait_items.stderr
@@ -15,7 +15,6 @@ LL |     pub macro m() { ().f() }
 help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
 LL +     use foo::T;
-LL |     use foo::*;
    |
 
 error: aborting due to previous error
diff --git a/tests/ui/impl-trait/no-method-suggested-traits.stderr b/tests/ui/impl-trait/no-method-suggested-traits.stderr
index 0d37ea38b58..160cc044078 100644
--- a/tests/ui/impl-trait/no-method-suggested-traits.stderr
+++ b/tests/ui/impl-trait/no-method-suggested-traits.stderr
@@ -8,16 +8,12 @@ LL |     1u32.method();
 help: the following traits are implemented but not in scope; perhaps add a `use` for one of them:
    |
 LL + use foo::Bar;
-LL | extern crate no_method_suggested_traits;
    |
 LL + use no_method_suggested_traits::Reexported;
-LL | extern crate no_method_suggested_traits;
    |
 LL + use no_method_suggested_traits::foo::PubPub;
-LL | extern crate no_method_suggested_traits;
    |
 LL + use no_method_suggested_traits::qux::PrivPub;
-LL | extern crate no_method_suggested_traits;
    |
 
 error[E0599]: no method named `method` found for struct `Rc<&mut Box<&u32>>` in the current scope
@@ -30,16 +26,12 @@ LL |     std::rc::Rc::new(&mut Box::new(&1u32)).method();
 help: the following traits are implemented but not in scope; perhaps add a `use` for one of them:
    |
 LL + use foo::Bar;
-LL | extern crate no_method_suggested_traits;
    |
 LL + use no_method_suggested_traits::Reexported;
-LL | extern crate no_method_suggested_traits;
    |
 LL + use no_method_suggested_traits::foo::PubPub;
-LL | extern crate no_method_suggested_traits;
    |
 LL + use no_method_suggested_traits::qux::PrivPub;
-LL | extern crate no_method_suggested_traits;
    |
 
 error[E0599]: no method named `method` found for type `char` in the current scope
@@ -55,7 +47,6 @@ LL |     'a'.method();
 help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
 LL + use foo::Bar;
-LL | extern crate no_method_suggested_traits;
    |
 
 error[E0599]: no method named `method` found for struct `Rc<&mut Box<&char>>` in the current scope
@@ -68,7 +59,6 @@ LL |     std::rc::Rc::new(&mut Box::new(&'a')).method();
 help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
 LL + use foo::Bar;
-LL | extern crate no_method_suggested_traits;
    |
 
 error[E0599]: no method named `method` found for type `i32` in the current scope
@@ -86,7 +76,6 @@ LL |         fn method(&self) {}
 help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
 LL + use no_method_suggested_traits::foo::PubPub;
-LL | extern crate no_method_suggested_traits;
    |
 
 error[E0599]: no method named `method` found for struct `Rc<&mut Box<&i32>>` in the current scope
@@ -99,7 +88,6 @@ LL |     std::rc::Rc::new(&mut Box::new(&1i32)).method();
 help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
 LL + use no_method_suggested_traits::foo::PubPub;
-LL | extern crate no_method_suggested_traits;
    |
 
 error[E0599]: no method named `method` found for struct `Foo` in the current scope
diff --git a/tests/ui/impl-trait/universal_wrong_bounds.stderr b/tests/ui/impl-trait/universal_wrong_bounds.stderr
index 1561708efba..464d689589e 100644
--- a/tests/ui/impl-trait/universal_wrong_bounds.stderr
+++ b/tests/ui/impl-trait/universal_wrong_bounds.stderr
@@ -7,7 +7,6 @@ LL | fn wants_debug(g: impl Debug) { }
 help: consider importing this trait instead
    |
 LL + use std::fmt::Debug;
-LL | use std::fmt::Display;
    |
 
 error[E0404]: expected trait, found derive macro `Debug`
@@ -19,7 +18,6 @@ LL | fn wants_display(g: impl Debug) { }
 help: consider importing this trait instead
    |
 LL + use std::fmt::Debug;
-LL | use std::fmt::Display;
    |
 
 error: aborting due to 2 previous errors
diff --git a/tests/ui/imports/glob-resolve1.stderr b/tests/ui/imports/glob-resolve1.stderr
index 6d7ceb25a8f..4401ef58732 100644
--- a/tests/ui/imports/glob-resolve1.stderr
+++ b/tests/ui/imports/glob-resolve1.stderr
@@ -61,7 +61,6 @@ LL |     import();
 help: consider importing this function
    |
 LL + use other::import;
-LL | use bar::*;
    |
 
 error[E0412]: cannot find type `A` in this scope
diff --git a/tests/ui/imports/issue-38293.stderr b/tests/ui/imports/issue-38293.stderr
index 7a3b405a782..1bb7ae29e10 100644
--- a/tests/ui/imports/issue-38293.stderr
+++ b/tests/ui/imports/issue-38293.stderr
@@ -13,7 +13,6 @@ LL |     baz();
 help: consider importing this function instead
    |
 LL + use bar::baz;
-LL | use foo::f::{self};
    |
 
 error: aborting due to 2 previous errors
diff --git a/tests/ui/imports/issue-4366-2.stderr b/tests/ui/imports/issue-4366-2.stderr
index d8539f9a9d4..412423f4d59 100644
--- a/tests/ui/imports/issue-4366-2.stderr
+++ b/tests/ui/imports/issue-4366-2.stderr
@@ -19,7 +19,6 @@ LL |     foo();
 help: consider importing this function instead
    |
 LL + use foo::foo;
-LL | use m1::*;
    |
 
 error: aborting due to 2 previous errors
diff --git a/tests/ui/imports/issue-4366.stderr b/tests/ui/imports/issue-4366.stderr
index 724db83e99a..4d5b392a7e1 100644
--- a/tests/ui/imports/issue-4366.stderr
+++ b/tests/ui/imports/issue-4366.stderr
@@ -7,7 +7,6 @@ LL |         fn sub() -> isize { foo(); 1 }
 help: consider importing this function
    |
 LL +         use foo::foo;
-LL |         use a::b::*;
    |
 
 error: aborting due to previous error
diff --git a/tests/ui/imports/overlapping_pub_trait.stderr b/tests/ui/imports/overlapping_pub_trait.stderr
index 268709e11b6..490dccd3e80 100644
--- a/tests/ui/imports/overlapping_pub_trait.stderr
+++ b/tests/ui/imports/overlapping_pub_trait.stderr
@@ -13,7 +13,6 @@ LL |     pub trait Tr { fn method(&self); }
 help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
 LL + use overlapping_pub_trait_source::m::Tr;
-LL | extern crate overlapping_pub_trait_source;
    |
 
 error: aborting due to previous error
diff --git a/tests/ui/imports/unnamed_pub_trait.stderr b/tests/ui/imports/unnamed_pub_trait.stderr
index 47fa6d3a398..5133273c22f 100644
--- a/tests/ui/imports/unnamed_pub_trait.stderr
+++ b/tests/ui/imports/unnamed_pub_trait.stderr
@@ -13,7 +13,6 @@ LL |     pub trait Tr { fn method(&self); }
 help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
 LL + use unnamed_pub_trait_source::prelude::*; // trait Tr
-LL | extern crate unnamed_pub_trait_source;
    |
 
 error: aborting due to previous error
diff --git a/tests/ui/issues/issue-10465.stderr b/tests/ui/issues/issue-10465.stderr
index 9941e14a94e..1b7b9d5909e 100644
--- a/tests/ui/issues/issue-10465.stderr
+++ b/tests/ui/issues/issue-10465.stderr
@@ -8,7 +8,6 @@ LL |             b.foo();
 help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
 LL +         use a::A;
-LL |         use b::B;
    |
 
 error: aborting due to previous error
diff --git a/tests/ui/issues/issue-17546.stderr b/tests/ui/issues/issue-17546.stderr
index 23a12fa167b..cf7ed1bbd66 100644
--- a/tests/ui/issues/issue-17546.stderr
+++ b/tests/ui/issues/issue-17546.stderr
@@ -25,16 +25,12 @@ LL |     fn new() -> Result<foo::MyEnum, String> {
 help: consider importing one of these items instead
    |
 LL +     use std::fmt::Result;
-LL |     use foo::MyEnum::Result;
    |
 LL +     use std::io::Result;
-LL |     use foo::MyEnum::Result;
    |
 LL +     use std::result::Result;
-LL |     use foo::MyEnum::Result;
    |
 LL +     use std::thread::Result;
-LL |     use foo::MyEnum::Result;
    |
 
 error[E0573]: expected type, found variant `Result`
@@ -46,16 +42,12 @@ LL | fn new() -> Result<foo::MyEnum, String> {
 help: consider importing one of these items instead
    |
 LL + use std::fmt::Result;
-LL | use foo::MyEnum::Result;
    |
 LL + use std::io::Result;
-LL | use foo::MyEnum::Result;
    |
 LL + use std::result::Result;
-LL | use foo::MyEnum::Result;
    |
 LL + use std::thread::Result;
-LL | use foo::MyEnum::Result;
    |
 
 error[E0573]: expected type, found variant `NoResult`
diff --git a/tests/ui/issues/issue-35976.unimported.stderr b/tests/ui/issues/issue-35976.unimported.stderr
index 8a3e2fcd083..b31d2a31551 100644
--- a/tests/ui/issues/issue-35976.unimported.stderr
+++ b/tests/ui/issues/issue-35976.unimported.stderr
@@ -10,7 +10,6 @@ LL |     arg.wait();
 help: another candidate was found in the following trait, perhaps add a `use` for it:
    |
 LL + use private::Future;
-LL | mod private {
    |
 
 error: aborting due to previous error
diff --git a/tests/ui/issues/issue-37534.stderr b/tests/ui/issues/issue-37534.stderr
index 8449eb9c692..7d3dd8800bd 100644
--- a/tests/ui/issues/issue-37534.stderr
+++ b/tests/ui/issues/issue-37534.stderr
@@ -7,7 +7,6 @@ LL | struct Foo<T: ?Hash> { }
 help: consider importing this trait instead
    |
 LL + use std::hash::Hash;
-LL | struct Foo<T: ?Hash> { }
    |
 
 warning: default bound relaxed for a type parameter, but this does nothing because the given bound is not a default; only `?Sized` is supported
diff --git a/tests/ui/issues/issue-39175.stderr b/tests/ui/issues/issue-39175.stderr
index 19e7f5162a7..3a1476ac0e3 100644
--- a/tests/ui/issues/issue-39175.stderr
+++ b/tests/ui/issues/issue-39175.stderr
@@ -8,7 +8,6 @@ LL |     Command::new("echo").arg("hello").exec();
 help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
 LL + use std::os::unix::process::CommandExt;
-LL | use std::process::Command;
    |
 
 error: aborting due to previous error
diff --git a/tests/ui/issues/issue-56175.stderr b/tests/ui/issues/issue-56175.stderr
index bedbaef29b9..1ddee1f4895 100644
--- a/tests/ui/issues/issue-56175.stderr
+++ b/tests/ui/issues/issue-56175.stderr
@@ -13,7 +13,6 @@ LL |         fn trait_method(&self) {
 help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
 LL + use reexported_trait::Trait;
-LL | fn main() {
    |
 
 error[E0599]: no method named `trait_method_b` found for struct `FooStruct` in the current scope
@@ -31,7 +30,6 @@ LL |         fn trait_method_b(&self) {
 help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
 LL + use reexported_trait::TraitBRename;
-LL | fn main() {
    |
 
 error: aborting due to 2 previous errors
diff --git a/tests/ui/issues/issue-77919.stderr b/tests/ui/issues/issue-77919.stderr
index 1f3f6cb33c7..d6dcc8997b9 100644
--- a/tests/ui/issues/issue-77919.stderr
+++ b/tests/ui/issues/issue-77919.stderr
@@ -7,7 +7,6 @@ LL |     _n: PhantomData,
 help: consider importing this struct
    |
 LL + use std::marker::PhantomData;
-LL | fn main() {
    |
 
 error[E0412]: cannot find type `VAL` in this scope
diff --git a/tests/ui/layout/issue-84108.stderr b/tests/ui/layout/issue-84108.stderr
index cdc21df79a7..5ad450bed07 100644
--- a/tests/ui/layout/issue-84108.stderr
+++ b/tests/ui/layout/issue-84108.stderr
@@ -7,7 +7,6 @@ LL | static FOO: (dyn AsRef<OsStr>, u8) = ("hello", 42);
 help: consider importing this struct
    |
 LL + use std::ffi::OsStr;
-LL | static FOO: (dyn AsRef<OsStr>, u8) = ("hello", 42);
    |
 
 error[E0412]: cannot find type `Path` in this scope
@@ -19,7 +18,6 @@ LL | const BAR: (&Path, [u8], usize) = ("hello", [], 42);
 help: consider importing this struct
    |
 LL + use std::path::Path;
-LL | static FOO: (dyn AsRef<OsStr>, u8) = ("hello", 42);
    |
 
 error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
diff --git a/tests/ui/macros/issue-100199.stderr b/tests/ui/macros/issue-100199.stderr
index ab6bc08b5f7..89a6f585ce4 100644
--- a/tests/ui/macros/issue-100199.stderr
+++ b/tests/ui/macros/issue-100199.stderr
@@ -8,7 +8,6 @@ LL | #[issue_100199::struct_with_bound]
 help: consider importing this trait
    |
 LL + use traits::MyTrait;
-LL | #[issue_100199::struct_with_bound]
    |
 
 error: aborting due to previous error
diff --git a/tests/ui/macros/macro-outer-attributes.stderr b/tests/ui/macros/macro-outer-attributes.stderr
index cfd1c7739ba..0bdc3416f80 100644
--- a/tests/ui/macros/macro-outer-attributes.stderr
+++ b/tests/ui/macros/macro-outer-attributes.stderr
@@ -7,7 +7,6 @@ LL |     a::bar();
 help: consider importing this function
    |
 LL + use b::bar;
-LL | macro_rules! test { ($nm:ident,
    |
 help: if you import `bar`, refer to it directly
    |
diff --git a/tests/ui/namespace/namespace-mix.stderr b/tests/ui/namespace/namespace-mix.stderr
index 216548180bc..3ac5e96c574 100644
--- a/tests/ui/namespace/namespace-mix.stderr
+++ b/tests/ui/namespace/namespace-mix.stderr
@@ -15,10 +15,8 @@ LL |     check(m1::TS);
 help: consider importing one of these items instead
    |
 LL + use m2::S;
-LL | use namespace_mix::*;
    |
 LL + use xm2::S;
-LL | use namespace_mix::*;
    |
 help: if you import `S`, refer to it directly
    |
@@ -45,10 +43,8 @@ LL |     check(xm1::TS);
 help: consider importing one of these items instead
    |
 LL + use m2::S;
-LL | use namespace_mix::*;
    |
 LL + use xm2::S;
-LL | use namespace_mix::*;
    |
 help: if you import `S`, refer to it directly
    |
@@ -73,10 +69,8 @@ LL |     check(m7::TV);
 help: consider importing one of these items instead
    |
 LL + use m8::V;
-LL | use namespace_mix::*;
    |
 LL + use xm8::V;
-LL | use namespace_mix::*;
    |
 help: if you import `V`, refer to it directly
    |
@@ -103,10 +97,8 @@ LL |     check(xm7::TV);
 help: consider importing one of these items instead
    |
 LL + use m8::V;
-LL | use namespace_mix::*;
    |
 LL + use xm8::V;
-LL | use namespace_mix::*;
    |
 help: if you import `V`, refer to it directly
    |
diff --git a/tests/ui/parser/circular_modules_main.stderr b/tests/ui/parser/circular_modules_main.stderr
index 2804c6ebf50..2de70789358 100644
--- a/tests/ui/parser/circular_modules_main.stderr
+++ b/tests/ui/parser/circular_modules_main.stderr
@@ -13,7 +13,6 @@ LL |     println!("{}", circular_modules_main::hi_str());
 help: consider importing this function
    |
 LL + use hi_str;
-LL | #[path = "circular_modules_main.rs"]
    |
 help: if you import `hi_str`, refer to it directly
    |
diff --git a/tests/ui/privacy/privacy-ns1.stderr b/tests/ui/privacy/privacy-ns1.stderr
index fe3e4a78a84..9710cc48637 100644
--- a/tests/ui/privacy/privacy-ns1.stderr
+++ b/tests/ui/privacy/privacy-ns1.stderr
@@ -14,7 +14,6 @@ LL |     Baz();
 help: consider importing this function instead
    |
 LL + use foo2::Bar;
-LL | pub mod foo1 {
    |
 
 error[E0425]: cannot find function, tuple struct or tuple variant `Bar` in this scope
@@ -33,7 +32,6 @@ LL |     Baz();
 help: consider importing this function
    |
 LL + use foo2::Bar;
-LL | pub mod foo1 {
    |
 
 error[E0412]: cannot find type `Bar` in this scope
@@ -52,7 +50,6 @@ LL |     let _x: Box<Baz>;
 help: consider importing this trait
    |
 LL + use foo1::Bar;
-LL | pub mod foo1 {
    |
 
 error[E0747]: constant provided when a type was expected
diff --git a/tests/ui/privacy/privacy-ns2.stderr b/tests/ui/privacy/privacy-ns2.stderr
index 73a24bd20f3..75e735e1e6a 100644
--- a/tests/ui/privacy/privacy-ns2.stderr
+++ b/tests/ui/privacy/privacy-ns2.stderr
@@ -7,7 +7,6 @@ LL |     Bar();
 help: consider importing this function instead
    |
 LL + use foo2::Bar;
-LL | pub mod foo1 {
    |
 
 error[E0423]: expected function, tuple struct or tuple variant, found trait `Bar`
@@ -26,7 +25,6 @@ LL |     Baz();
 help: consider importing this function instead
    |
 LL + use foo2::Bar;
-LL | pub mod foo1 {
    |
 
 error[E0573]: expected type, found function `Bar`
@@ -42,7 +40,6 @@ LL |     let _x = Bar();
 help: consider importing this trait instead
    |
 LL + use foo1::Bar;
-LL | pub mod foo1 {
    |
 
 error[E0603]: trait `Bar` is private
diff --git a/tests/ui/proc-macro/amputate-span.stderr b/tests/ui/proc-macro/amputate-span.stderr
index fa83707e79d..aa797339be4 100644
--- a/tests/ui/proc-macro/amputate-span.stderr
+++ b/tests/ui/proc-macro/amputate-span.stderr
@@ -7,7 +7,6 @@ LL |     Command::new("git");
 help: consider importing this struct
    |
 LL + use std::process::Command;
-LL | #[amputate_span::drop_first_token]
    |
 
 error[E0433]: failed to resolve: use of undeclared type `Command`
@@ -19,7 +18,6 @@ LL |         Command::new("git");
 help: consider importing this struct
    |
 LL +     use std::process::Command;
-LL |     #[amputate_span::drop_first_token]
    |
 
 error: aborting due to 2 previous errors
diff --git a/tests/ui/proc-macro/attributes-on-modules-fail.stderr b/tests/ui/proc-macro/attributes-on-modules-fail.stderr
index a0ab9999c08..97521f23aee 100644
--- a/tests/ui/proc-macro/attributes-on-modules-fail.stderr
+++ b/tests/ui/proc-macro/attributes-on-modules-fail.stderr
@@ -51,7 +51,6 @@ LL |     type A = Y;
 help: consider importing this struct
    |
 LL +     use Y;
-LL |     pub struct X;
    |
 
 error[E0412]: cannot find type `X` in this scope
@@ -63,7 +62,6 @@ LL | type A = X;
 help: consider importing this struct
    |
 LL + use m::X;
-LL | #[macro_use]
    |
 
 error: aborting due to 7 previous errors
diff --git a/tests/ui/resolve/crate-in-paths.stderr b/tests/ui/resolve/crate-in-paths.stderr
index 45ecf5a59ad..07fb5dcc035 100644
--- a/tests/ui/resolve/crate-in-paths.stderr
+++ b/tests/ui/resolve/crate-in-paths.stderr
@@ -7,7 +7,6 @@ LL |     Foo;
 help: consider importing this unit struct
    |
 LL + use crate::bar::Foo;
-LL | mod bar {
    |
 
 error: aborting due to previous error
diff --git a/tests/ui/resolve/enums-are-namespaced-xc.stderr b/tests/ui/resolve/enums-are-namespaced-xc.stderr
index efebf15684b..5af6cb04275 100644
--- a/tests/ui/resolve/enums-are-namespaced-xc.stderr
+++ b/tests/ui/resolve/enums-are-namespaced-xc.stderr
@@ -7,7 +7,6 @@ LL |     let _ = namespaced_enums::A;
 help: consider importing this unit variant
    |
 LL + use namespaced_enums::Foo::A;
-LL | extern crate namespaced_enums;
    |
 help: if you import `A`, refer to it directly
    |
@@ -24,7 +23,6 @@ LL |     let _ = namespaced_enums::B(10);
 help: consider importing this tuple variant
    |
 LL + use namespaced_enums::Foo::B;
-LL | extern crate namespaced_enums;
    |
 help: if you import `B`, refer to it directly
    |
@@ -41,7 +39,6 @@ LL |     let _ = namespaced_enums::C { a: 10 };
 help: consider importing this variant
    |
 LL + use namespaced_enums::Foo::C;
-LL | extern crate namespaced_enums;
    |
 help: if you import `C`, refer to it directly
    |
diff --git a/tests/ui/resolve/filter-intrinsics.stderr b/tests/ui/resolve/filter-intrinsics.stderr
index 3b4a09a25e7..cc1092dd0cf 100644
--- a/tests/ui/resolve/filter-intrinsics.stderr
+++ b/tests/ui/resolve/filter-intrinsics.stderr
@@ -7,7 +7,6 @@ LL |     let _ = size_of::<usize>();
 help: consider importing this function
    |
 LL + use std::mem::size_of;
-LL | fn main() {
    |
 
 error[E0425]: cannot find function `fabsf64` in this scope
@@ -19,7 +18,6 @@ LL |     let _ = fabsf64(1.0);
 help: consider importing this function
    |
 LL + use std::intrinsics::fabsf64;
-LL | fn main() {
    |
 
 error: aborting due to 2 previous errors
diff --git a/tests/ui/resolve/issue-102946.stderr b/tests/ui/resolve/issue-102946.stderr
index 73843849214..b2cdcb25c3f 100644
--- a/tests/ui/resolve/issue-102946.stderr
+++ b/tests/ui/resolve/issue-102946.stderr
@@ -7,7 +7,6 @@ LL | impl Error for str::Utf8Error {
 help: consider importing this trait
    |
 LL + use std::error::Error;
-LL | impl Error for str::Utf8Error {
    |
 
 error[E0223]: ambiguous associated type
diff --git a/tests/ui/resolve/issue-16058.stderr b/tests/ui/resolve/issue-16058.stderr
index 65dba047234..710002a154e 100644
--- a/tests/ui/resolve/issue-16058.stderr
+++ b/tests/ui/resolve/issue-16058.stderr
@@ -7,13 +7,10 @@ LL |         Result {
 help: consider importing one of these items instead
    |
 LL + use std::fmt::Result;
-LL | pub struct GslResult {
    |
 LL + use std::io::Result;
-LL | pub struct GslResult {
    |
 LL + use std::thread::Result;
-LL | pub struct GslResult {
    |
 
 error: aborting due to previous error
diff --git a/tests/ui/resolve/issue-17518.stderr b/tests/ui/resolve/issue-17518.stderr
index 19b59b841e0..492e3b34a17 100644
--- a/tests/ui/resolve/issue-17518.stderr
+++ b/tests/ui/resolve/issue-17518.stderr
@@ -7,7 +7,6 @@ LL |     E { name: "foobar" };
 help: consider importing this variant
    |
 LL + use SomeEnum::E;
-LL | enum SomeEnum {
    |
 
 error: aborting due to previous error
diff --git a/tests/ui/resolve/issue-21221-1.stderr b/tests/ui/resolve/issue-21221-1.stderr
index 836ea564f4e..a38116cd728 100644
--- a/tests/ui/resolve/issue-21221-1.stderr
+++ b/tests/ui/resolve/issue-21221-1.stderr
@@ -7,13 +7,10 @@ LL | impl Mul for Foo {
 help: consider importing one of these items
    |
 LL + use mul1::Mul;
-LL | mod mul1 {
    |
 LL + use mul2::Mul;
-LL | mod mul1 {
    |
 LL + use std::ops::Mul;
-LL | mod mul1 {
    |
 
 error[E0412]: cannot find type `Mul` in this scope
@@ -25,13 +22,10 @@ LL | fn getMul() -> Mul {
 help: consider importing one of these items
    |
 LL + use mul1::Mul;
-LL | mod mul1 {
    |
 LL + use mul2::Mul;
-LL | mod mul1 {
    |
 LL + use std::ops::Mul;
-LL | mod mul1 {
    |
 
 error[E0405]: cannot find trait `ThisTraitReallyDoesntExistInAnyModuleReally` in this scope
@@ -49,7 +43,6 @@ LL | impl Div for Foo {
 help: consider importing this trait
    |
 LL + use std::ops::Div;
-LL | mod mul1 {
    |
 
 error: aborting due to 4 previous errors
diff --git a/tests/ui/resolve/issue-21221-2.stderr b/tests/ui/resolve/issue-21221-2.stderr
index e88274e6c60..9beb626623e 100644
--- a/tests/ui/resolve/issue-21221-2.stderr
+++ b/tests/ui/resolve/issue-21221-2.stderr
@@ -7,10 +7,8 @@ LL | impl T for Foo { }
 help: consider importing one of these items
    |
 LL + use baz::T;
-LL | pub mod foo {
    |
 LL + use foo::bar::T;
-LL | pub mod foo {
    |
 
 error: aborting due to previous error
diff --git a/tests/ui/resolve/issue-21221-3.stderr b/tests/ui/resolve/issue-21221-3.stderr
index e02eaec05e3..0dabdfd9b39 100644
--- a/tests/ui/resolve/issue-21221-3.stderr
+++ b/tests/ui/resolve/issue-21221-3.stderr
@@ -7,7 +7,6 @@ LL | impl OuterTrait for Foo {}
 help: consider importing this trait
    |
 LL + use issue_21221_3::outer::OuterTrait;
-LL | extern crate issue_21221_3;
    |
 
 error: aborting due to previous error
diff --git a/tests/ui/resolve/issue-21221-4.stderr b/tests/ui/resolve/issue-21221-4.stderr
index e8c38ed6acf..5af14b1b68d 100644
--- a/tests/ui/resolve/issue-21221-4.stderr
+++ b/tests/ui/resolve/issue-21221-4.stderr
@@ -7,7 +7,6 @@ LL | impl T for Foo {}
 help: consider importing this trait
    |
 LL + use issue_21221_4::T;
-LL | extern crate issue_21221_4;
    |
 
 error: aborting due to previous error
diff --git a/tests/ui/resolve/issue-2356.stderr b/tests/ui/resolve/issue-2356.stderr
index ed820f15c83..313b3e30dd9 100644
--- a/tests/ui/resolve/issue-2356.stderr
+++ b/tests/ui/resolve/issue-2356.stderr
@@ -11,7 +11,6 @@ LL |     Self::default();
 help: consider importing this function
    |
 LL + use std::default::default;
-LL | trait Groom {
    |
 
 error[E0425]: cannot find value `whiskers` in this scope
diff --git a/tests/ui/resolve/issue-26545.stderr b/tests/ui/resolve/issue-26545.stderr
index 2b98b5b8a7b..42a7531c5b9 100644
--- a/tests/ui/resolve/issue-26545.stderr
+++ b/tests/ui/resolve/issue-26545.stderr
@@ -7,7 +7,6 @@ LL |         B(());
 help: consider importing this tuple struct
    |
 LL +     use foo::B;
-LL |     fn foo() {
    |
 
 error: aborting due to previous error
diff --git a/tests/ui/resolve/issue-35675.stderr b/tests/ui/resolve/issue-35675.stderr
index d2856145371..44af65b0768 100644
--- a/tests/ui/resolve/issue-35675.stderr
+++ b/tests/ui/resolve/issue-35675.stderr
@@ -18,7 +18,6 @@ LL |     Apple(5)
 help: consider importing this tuple variant
    |
 LL + use Fruit::Apple;
-LL | enum Fruit {
    |
 
 error[E0573]: expected type, found variant `Fruit::Apple`
@@ -39,7 +38,6 @@ LL |     Apple(5)
 help: consider importing this tuple variant
    |
 LL + use Fruit::Apple;
-LL | enum Fruit {
    |
 
 error[E0573]: expected type, found variant `Ok`
diff --git a/tests/ui/resolve/issue-3907.stderr b/tests/ui/resolve/issue-3907.stderr
index 50ad668f8db..70631a13cdf 100644
--- a/tests/ui/resolve/issue-3907.stderr
+++ b/tests/ui/resolve/issue-3907.stderr
@@ -11,7 +11,6 @@ LL | trait Foo = dyn issue_3907::Foo;
 help: consider importing this trait instead
    |
 LL + use issue_3907::Foo;
-LL | extern crate issue_3907;
    |
 
 error: aborting due to previous error
diff --git a/tests/ui/resolve/issue-50599.stderr b/tests/ui/resolve/issue-50599.stderr
index 548d215b00a..d7419b64fac 100644
--- a/tests/ui/resolve/issue-50599.stderr
+++ b/tests/ui/resolve/issue-50599.stderr
@@ -7,10 +7,8 @@ LL |     const M: usize = (f64::from(N) * std::f64::LOG10_2) as usize;
 help: consider importing one of these items
    |
 LL + use std::f32::consts::LOG10_2;
-LL | fn main() {
    |
 LL + use std::f64::consts::LOG10_2;
-LL | fn main() {
    |
 help: if you import `LOG10_2`, refer to it directly
    |
diff --git a/tests/ui/resolve/issue-73427.stderr b/tests/ui/resolve/issue-73427.stderr
index 5a663ae79bc..622de9b39bd 100644
--- a/tests/ui/resolve/issue-73427.stderr
+++ b/tests/ui/resolve/issue-73427.stderr
@@ -108,10 +108,8 @@ LL |     (E::TupleWithFields(/* fields */)).foo();
 help: consider importing one of these items instead
    |
 LL + use std::f32::consts::E;
-LL | enum A {
    |
 LL + use std::f64::consts::E;
-LL | enum A {
    |
 
 error[E0532]: expected tuple struct or tuple variant, found enum `A`
diff --git a/tests/ui/resolve/issue-90113.stderr b/tests/ui/resolve/issue-90113.stderr
index a9d4b573f11..5f55d9c241a 100644
--- a/tests/ui/resolve/issue-90113.stderr
+++ b/tests/ui/resolve/issue-90113.stderr
@@ -7,7 +7,6 @@ LL |         Cons(..) => {}
 help: consider importing this tuple variant
    |
 LL + use list::List::Cons;
-LL | mod list {
    |
 
 error: aborting due to previous error
diff --git a/tests/ui/resolve/missing-in-namespace.stderr b/tests/ui/resolve/missing-in-namespace.stderr
index 66f40102a3e..7a7b749aebb 100644
--- a/tests/ui/resolve/missing-in-namespace.stderr
+++ b/tests/ui/resolve/missing-in-namespace.stderr
@@ -7,7 +7,6 @@ LL |     let _map = std::hahmap::HashMap::new();
 help: consider importing this struct
    |
 LL + use std::collections::HashMap;
-LL | fn main() {
    |
 help: if you import `HashMap`, refer to it directly
    |
diff --git a/tests/ui/resolve/no-implicit-prelude-nested.stderr b/tests/ui/resolve/no-implicit-prelude-nested.stderr
index 4df6c31d316..49cf72bfee2 100644
--- a/tests/ui/resolve/no-implicit-prelude-nested.stderr
+++ b/tests/ui/resolve/no-implicit-prelude-nested.stderr
@@ -7,7 +7,6 @@ LL |         impl Add for Test {}
 help: consider importing this trait
    |
 LL +         use std::ops::Add;
-LL |         struct Test;
    |
 
 error[E0404]: expected trait, found derive macro `Clone`
@@ -19,7 +18,6 @@ LL |         impl Clone for Test {}
 help: consider importing this trait instead
    |
 LL +         use std::clone::Clone;
-LL |         struct Test;
    |
 
 error[E0405]: cannot find trait `Iterator` in this scope
@@ -31,7 +29,6 @@ LL |         impl Iterator for Test {}
 help: consider importing this trait
    |
 LL +         use std::iter::Iterator;
-LL |         struct Test;
    |
 
 error[E0405]: cannot find trait `ToString` in this scope
@@ -43,7 +40,6 @@ LL |         impl ToString for Test {}
 help: consider importing this trait
    |
 LL +         use std::string::ToString;
-LL |         struct Test;
    |
 
 error[E0405]: cannot find trait `Writer` in this scope
@@ -61,7 +57,6 @@ LL |             drop(2)
 help: consider importing this function
    |
 LL +         use std::mem::drop;
-LL |         struct Test;
    |
 
 error[E0405]: cannot find trait `Add` in this scope
@@ -73,7 +68,6 @@ LL |     impl Add for Test {}
 help: consider importing this trait
    |
 LL +     use std::ops::Add;
-LL |     mod baz {
    |
 
 error[E0404]: expected trait, found derive macro `Clone`
@@ -85,7 +79,6 @@ LL |     impl Clone for Test {}
 help: consider importing this trait instead
    |
 LL +     use std::clone::Clone;
-LL |     mod baz {
    |
 
 error[E0405]: cannot find trait `Iterator` in this scope
@@ -97,7 +90,6 @@ LL |     impl Iterator for Test {}
 help: consider importing this trait
    |
 LL +     use std::iter::Iterator;
-LL |     mod baz {
    |
 
 error[E0405]: cannot find trait `ToString` in this scope
@@ -109,7 +101,6 @@ LL |     impl ToString for Test {}
 help: consider importing this trait
    |
 LL +     use std::string::ToString;
-LL |     mod baz {
    |
 
 error[E0405]: cannot find trait `Writer` in this scope
@@ -127,7 +118,6 @@ LL |         drop(2)
 help: consider importing this function
    |
 LL +     use std::mem::drop;
-LL |     mod baz {
    |
 
 error[E0405]: cannot find trait `Add` in this scope
@@ -139,7 +129,6 @@ LL |         impl Add for Test {}
 help: consider importing this trait
    |
 LL +         use std::ops::Add;
-LL |         struct Test;
    |
 
 error[E0404]: expected trait, found derive macro `Clone`
@@ -151,7 +140,6 @@ LL |         impl Clone for Test {}
 help: consider importing this trait instead
    |
 LL +         use std::clone::Clone;
-LL |         struct Test;
    |
 
 error[E0405]: cannot find trait `Iterator` in this scope
@@ -163,7 +151,6 @@ LL |         impl Iterator for Test {}
 help: consider importing this trait
    |
 LL +         use std::iter::Iterator;
-LL |         struct Test;
    |
 
 error[E0405]: cannot find trait `ToString` in this scope
@@ -175,7 +162,6 @@ LL |         impl ToString for Test {}
 help: consider importing this trait
    |
 LL +         use std::string::ToString;
-LL |         struct Test;
    |
 
 error[E0405]: cannot find trait `Writer` in this scope
@@ -193,7 +179,6 @@ LL |             drop(2)
 help: consider importing this function
    |
 LL +         use std::mem::drop;
-LL |         struct Test;
    |
 
 error: aborting due to 18 previous errors
diff --git a/tests/ui/resolve/no-implicit-prelude.stderr b/tests/ui/resolve/no-implicit-prelude.stderr
index a8e5f1b69e2..5a759743f72 100644
--- a/tests/ui/resolve/no-implicit-prelude.stderr
+++ b/tests/ui/resolve/no-implicit-prelude.stderr
@@ -7,7 +7,6 @@ LL | impl Add for Test {}
 help: consider importing this trait
    |
 LL + use std::ops::Add;
-LL | struct Test;
    |
 
 error[E0404]: expected trait, found derive macro `Clone`
@@ -19,7 +18,6 @@ LL | impl Clone for Test {}
 help: consider importing this trait instead
    |
 LL + use std::clone::Clone;
-LL | struct Test;
    |
 
 error[E0405]: cannot find trait `Iterator` in this scope
@@ -31,7 +29,6 @@ LL | impl Iterator for Test {}
 help: consider importing this trait
    |
 LL + use std::iter::Iterator;
-LL | struct Test;
    |
 
 error[E0405]: cannot find trait `ToString` in this scope
@@ -43,7 +40,6 @@ LL | impl ToString for Test {}
 help: consider importing this trait
    |
 LL + use std::string::ToString;
-LL | struct Test;
    |
 
 error[E0405]: cannot find trait `Writer` in this scope
@@ -61,7 +57,6 @@ LL |     drop(2)
 help: consider importing this function
    |
 LL + use std::mem::drop;
-LL | struct Test;
    |
 
 error: aborting due to 6 previous errors
diff --git a/tests/ui/resolve/privacy-enum-ctor.stderr b/tests/ui/resolve/privacy-enum-ctor.stderr
index 76dc25539d0..0bb09090569 100644
--- a/tests/ui/resolve/privacy-enum-ctor.stderr
+++ b/tests/ui/resolve/privacy-enum-ctor.stderr
@@ -85,10 +85,8 @@ LL |     let _: E = m::f;
 help: consider importing one of these items instead
    |
 LL + use std::f32::consts::E;
-LL | use m::E; // OK, only the type is imported
    |
 LL + use std::f64::consts::E;
-LL | use m::E; // OK, only the type is imported
    |
 help: if you import `E`, refer to it directly
    |
@@ -124,10 +122,8 @@ LL |     let _: E = (E::Fn(/* fields */));
 help: consider importing one of these items instead
    |
 LL + use std::f32::consts::E;
-LL | use m::E; // OK, only the type is imported
    |
 LL + use std::f64::consts::E;
-LL | use m::E; // OK, only the type is imported
    |
 
 error[E0412]: cannot find type `Z` in this scope
diff --git a/tests/ui/resolve/resolve-primitive-fallback.stderr b/tests/ui/resolve/resolve-primitive-fallback.stderr
index 2227522d6ea..e3a5d4edcf1 100644
--- a/tests/ui/resolve/resolve-primitive-fallback.stderr
+++ b/tests/ui/resolve/resolve-primitive-fallback.stderr
@@ -13,7 +13,6 @@ LL |     let _: ::u8;
 help: consider importing this builtin type
    |
 LL + use std::primitive::u8;
-LL | fn main() {
    |
 help: if you import `u8`, refer to it directly
    |
diff --git a/tests/ui/resolve/use_suggestion.stderr b/tests/ui/resolve/use_suggestion.stderr
index a30dbd954e1..1155f5caa17 100644
--- a/tests/ui/resolve/use_suggestion.stderr
+++ b/tests/ui/resolve/use_suggestion.stderr
@@ -7,7 +7,6 @@ LL |     let x1 = HashMap::new();
 help: consider importing this struct
    |
 LL + use std::collections::HashMap;
-LL | fn main() {
    |
 
 error[E0412]: cannot find type `HashMap` in this scope
@@ -19,7 +18,6 @@ LL |     let y1: HashMap;
 help: consider importing this struct
    |
 LL + use std::collections::HashMap;
-LL | fn main() {
    |
 
 error[E0412]: cannot find type `GooMap` in this scope
diff --git a/tests/ui/resolve/use_suggestion_placement.stderr b/tests/ui/resolve/use_suggestion_placement.stderr
index 9288530ad2e..3611f9ae6b4 100644
--- a/tests/ui/resolve/use_suggestion_placement.stderr
+++ b/tests/ui/resolve/use_suggestion_placement.stderr
@@ -7,7 +7,6 @@ LL |     type Bar = Path;
 help: consider importing this struct
    |
 LL +     use std::path::Path;
-LL |     #[derive(Debug)]
    |
 
 error[E0425]: cannot find value `A` in this scope
@@ -19,7 +18,6 @@ LL |     let _ = A;
 help: consider importing this constant
    |
 LL + use m::A;
-LL | macro_rules! y {
    |
 
 error[E0412]: cannot find type `HashMap` in this scope
@@ -31,7 +29,6 @@ LL |     type Dict<K, V> = HashMap<K, V>;
 help: consider importing this struct
    |
 LL + use std::collections::HashMap;
-LL | macro_rules! y {
    |
 
 error: aborting due to 3 previous errors
diff --git a/tests/ui/rust-2018/issue-52202-use-suggestions.stderr b/tests/ui/rust-2018/issue-52202-use-suggestions.stderr
index 5450ede8223..9933b92439c 100644
--- a/tests/ui/rust-2018/issue-52202-use-suggestions.stderr
+++ b/tests/ui/rust-2018/issue-52202-use-suggestions.stderr
@@ -7,16 +7,12 @@ LL |     let _d = Drain {};
 help: consider importing one of these items
    |
 LL + use crate::plumbing::Drain;
-LL | mod plumbing {
    |
 LL + use std::collections::binary_heap::Drain;
-LL | mod plumbing {
    |
 LL + use std::collections::hash_map::Drain;
-LL | mod plumbing {
    |
 LL + use std::collections::hash_set::Drain;
-LL | mod plumbing {
    |
      and 3 other candidates
 
diff --git a/tests/ui/rust-2018/trait-import-suggestions.stderr b/tests/ui/rust-2018/trait-import-suggestions.stderr
index 4be5c7b0d0c..325c5976e7c 100644
--- a/tests/ui/rust-2018/trait-import-suggestions.stderr
+++ b/tests/ui/rust-2018/trait-import-suggestions.stderr
@@ -11,7 +11,6 @@ LL |         x.foobar();
 help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
 LL +     use crate::foo::foobar::Foobar;
-LL |     mod foobar {
    |
 
 error[E0599]: no method named `bar` found for type `u32` in the current scope
@@ -27,7 +26,6 @@ LL |     x.bar();
 help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
 LL + use crate::foo::Bar;
-LL | mod foo {
    |
 
 error[E0599]: no method named `baz` found for type `u32` in the current scope
@@ -46,7 +44,6 @@ LL |     let y = u32::from_str("33");
 help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
 LL + use std::str::FromStr;
-LL | mod foo {
    |
 help: there is an associated function with a similar name
    |
diff --git a/tests/ui/rust-2018/uniform-paths/issue-87932.stderr b/tests/ui/rust-2018/uniform-paths/issue-87932.stderr
index e5e17f22c5f..ac2baa3595b 100644
--- a/tests/ui/rust-2018/uniform-paths/issue-87932.stderr
+++ b/tests/ui/rust-2018/uniform-paths/issue-87932.stderr
@@ -11,7 +11,6 @@ LL |     A::deserialize();
 help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
 LL + use <crate::A as issue_87932_a::Deserialize>::deserialize::_a::Deserialize;
-LL | pub struct A {}
    |
 
 error: aborting due to previous error
diff --git a/tests/ui/rust-2021/future-prelude-collision-shadow.stderr b/tests/ui/rust-2021/future-prelude-collision-shadow.stderr
index 34bf68e8913..9dfaf13e2ec 100644
--- a/tests/ui/rust-2021/future-prelude-collision-shadow.stderr
+++ b/tests/ui/rust-2021/future-prelude-collision-shadow.stderr
@@ -9,10 +9,8 @@ LL |         let _: u32 = 3u8.try_into().unwrap();
 help: the following traits are implemented but not in scope; perhaps add a `use` for one of them:
    |
 LL +     use crate::m::TryIntoU32;
-LL |     use crate::m::AnotherTrick as TryIntoU32;
    |
 LL +     use std::convert::TryInto;
-LL |     use crate::m::AnotherTrick as TryIntoU32;
    |
 
 error: aborting due to previous error
diff --git a/tests/ui/self/class-missing-self.stderr b/tests/ui/self/class-missing-self.stderr
index 2f35b30dbcb..3c37d819743 100644
--- a/tests/ui/self/class-missing-self.stderr
+++ b/tests/ui/self/class-missing-self.stderr
@@ -17,7 +17,6 @@ LL |       self.sleep();
 help: consider importing this function
    |
 LL + use std::thread::sleep;
-LL | struct Cat {
    |
 
 error: aborting due to 2 previous errors
diff --git a/tests/ui/shadowed/shadowed-trait-methods.stderr b/tests/ui/shadowed/shadowed-trait-methods.stderr
index 6d7ab27f3e1..1af0400c886 100644
--- a/tests/ui/shadowed/shadowed-trait-methods.stderr
+++ b/tests/ui/shadowed/shadowed-trait-methods.stderr
@@ -11,7 +11,6 @@ LL |     ().f()
 help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
 LL + use foo::T;
-LL | mod foo {
    |
 
 error: aborting due to previous error
diff --git a/tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.stderr b/tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.stderr
index 626cc67d9eb..60433e1c284 100644
--- a/tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.stderr
+++ b/tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.stderr
@@ -16,7 +16,6 @@ LL |         interval: Duration,
 help: consider importing this struct
    |
 LL + use std::time::Duration;
-LL | fn main() {}
    |
 
 error: aborting due to 2 previous errors
diff --git a/tests/ui/span/issue-35987.stderr b/tests/ui/span/issue-35987.stderr
index 0e64bcb0106..88c86d2a91b 100644
--- a/tests/ui/span/issue-35987.stderr
+++ b/tests/ui/span/issue-35987.stderr
@@ -12,7 +12,6 @@ LL | impl<T: Clone, Add> Add for Foo<T> {
 help: consider importing this trait instead
    |
 LL + use std::ops::Add;
-LL | use std::ops::Add;
    |
 
 error: aborting due to previous error
diff --git a/tests/ui/suggestions/core-std-import-order-issue-83564.stderr b/tests/ui/suggestions/core-std-import-order-issue-83564.stderr
index c87ff952553..48ee44a74f2 100644
--- a/tests/ui/suggestions/core-std-import-order-issue-83564.stderr
+++ b/tests/ui/suggestions/core-std-import-order-issue-83564.stderr
@@ -7,10 +7,8 @@ LL |     let _x = NonZeroU32::new(5).unwrap();
 help: consider importing one of these items
    |
 LL + use core::num::NonZeroU32;
-LL | fn main() {
    |
 LL + use std::num::NonZeroU32;
-LL | fn main() {
    |
 
 error: aborting due to previous error
diff --git a/tests/ui/suggestions/dont-wrap-ambiguous-receivers.stderr b/tests/ui/suggestions/dont-wrap-ambiguous-receivers.stderr
index 6eced1d416e..85fbb8b88e8 100644
--- a/tests/ui/suggestions/dont-wrap-ambiguous-receivers.stderr
+++ b/tests/ui/suggestions/dont-wrap-ambiguous-receivers.stderr
@@ -11,10 +11,8 @@ LL |     banana::Chaenomeles.pick()
 help: the following traits are implemented but not in scope; perhaps add a `use` for one of them:
    |
 LL + use banana::Apple;
-LL | mod banana {
    |
 LL + use banana::Peach;
-LL | mod banana {
    |
 
 error: aborting due to previous error
diff --git a/tests/ui/suggestions/import-trait-for-method-call.stderr b/tests/ui/suggestions/import-trait-for-method-call.stderr
index 464fe85ac17..3f54daf136f 100644
--- a/tests/ui/suggestions/import-trait-for-method-call.stderr
+++ b/tests/ui/suggestions/import-trait-for-method-call.stderr
@@ -11,7 +11,6 @@ LL |     h.finish()
 help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
 LL + use std::hash::Hasher;
-LL | use std::hash::BuildHasher;
    |
 
 error[E0599]: the method `as_ref` exists for reference `&dyn Bar`, but its trait bounds were not satisfied
diff --git a/tests/ui/suggestions/no-extern-crate-in-type.stderr b/tests/ui/suggestions/no-extern-crate-in-type.stderr
index d8e53229f49..68100e56cbc 100644
--- a/tests/ui/suggestions/no-extern-crate-in-type.stderr
+++ b/tests/ui/suggestions/no-extern-crate-in-type.stderr
@@ -7,7 +7,6 @@ LL | type Output = Option<Foo>;
 help: consider importing this struct
    |
 LL + use foo::Foo;
-LL | extern crate foo;
    |
 
 error: aborting due to previous error
diff --git a/tests/ui/suggestions/raw-name-use-suggestion.stderr b/tests/ui/suggestions/raw-name-use-suggestion.stderr
index 733af9079d5..fb070ffc332 100644
--- a/tests/ui/suggestions/raw-name-use-suggestion.stderr
+++ b/tests/ui/suggestions/raw-name-use-suggestion.stderr
@@ -29,7 +29,6 @@ LL |     r#break();
 help: consider importing this function
    |
 LL + use foo::r#break;
-LL | mod foo {
    |
 
 error: aborting due to 3 previous errors
diff --git a/tests/ui/suggestions/suggest-tryinto-edition-change.stderr b/tests/ui/suggestions/suggest-tryinto-edition-change.stderr
index 525a5bc164d..671f5efddd9 100644
--- a/tests/ui/suggestions/suggest-tryinto-edition-change.stderr
+++ b/tests/ui/suggestions/suggest-tryinto-edition-change.stderr
@@ -9,10 +9,8 @@ LL |     let _i: i16 = TryFrom::try_from(0_i32).unwrap();
 help: consider importing one of these items
    |
 LL + use core::convert::TryFrom;
-LL | fn test() {
    |
 LL + use std::convert::TryFrom;
-LL | fn test() {
    |
 
 error[E0433]: failed to resolve: use of undeclared type `TryInto`
@@ -26,10 +24,8 @@ LL |     let _i: i16 = TryInto::try_into(0_i32).unwrap();
 help: consider importing one of these items
    |
 LL + use core::convert::TryInto;
-LL | fn test() {
    |
 LL + use std::convert::TryInto;
-LL | fn test() {
    |
 
 error[E0433]: failed to resolve: use of undeclared type `FromIterator`
@@ -47,10 +43,8 @@ LL |     let _v: Vec<_> = IntoIterator::from_iter(&[1]);
 help: consider importing one of these items
    |
 LL + use core::iter::FromIterator;
-LL | fn test() {
    |
 LL + use std::iter::FromIterator;
-LL | fn test() {
    |
 
 error[E0599]: no method named `try_into` found for type `i32` in the current scope
@@ -67,7 +61,6 @@ LL |     let _i: i16 = 0_i32.try_into().unwrap();
 help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
 LL + use std::convert::TryInto;
-LL | fn test() {
    |
 
 error: aborting due to 4 previous errors
diff --git a/tests/ui/suggestions/use-placement-resolve.stderr b/tests/ui/suggestions/use-placement-resolve.stderr
index 16cbc9edcef..77724e7e2a4 100644
--- a/tests/ui/suggestions/use-placement-resolve.stderr
+++ b/tests/ui/suggestions/use-placement-resolve.stderr
@@ -7,7 +7,6 @@ LL | fn foobar<T: Debug>(x: T) {}
 help: consider importing this trait instead
    |
 LL + use std::fmt::Debug;
-LL | fn main() {}
    |
 
 error: aborting due to previous error
diff --git a/tests/ui/suggestions/use-placement-typeck.stderr b/tests/ui/suggestions/use-placement-typeck.stderr
index dc0586302f5..e900e12b7df 100644
--- a/tests/ui/suggestions/use-placement-typeck.stderr
+++ b/tests/ui/suggestions/use-placement-typeck.stderr
@@ -14,7 +14,6 @@ LL |     pub struct S;
 help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
 LL + use m::Foo;
-LL | fn main() {
    |
 
 error: aborting due to previous error
diff --git a/tests/ui/trait-bounds/impl-bound-with-references-error.stderr b/tests/ui/trait-bounds/impl-bound-with-references-error.stderr
index cc3b887cf07..b114d295d78 100644
--- a/tests/ui/trait-bounds/impl-bound-with-references-error.stderr
+++ b/tests/ui/trait-bounds/impl-bound-with-references-error.stderr
@@ -7,7 +7,6 @@ LL |     T: Into<Cow<'static, str>>,
 help: consider importing this enum
    |
 LL + use std::borrow::Cow;
-LL | pub enum LabelText {
    |
 
 error[E0119]: conflicting implementations of trait `From<LabelText>` for type `LabelText`
diff --git a/tests/ui/trait-bounds/shadowed-path-in-trait-bound-suggestion.stderr b/tests/ui/trait-bounds/shadowed-path-in-trait-bound-suggestion.stderr
index 60a86cc8e41..4547e1c984c 100644
--- a/tests/ui/trait-bounds/shadowed-path-in-trait-bound-suggestion.stderr
+++ b/tests/ui/trait-bounds/shadowed-path-in-trait-bound-suggestion.stderr
@@ -7,7 +7,6 @@ LL |     pub struct A<H: A::Trait>(pub H);
 help: consider importing this trait
    |
 LL +     use A::Trait;
-LL |     pub struct A<H: A::Trait>(pub H);
    |
 help: if you import `Trait`, refer to it directly
    |
diff --git a/tests/ui/traits/issue-78372.stderr b/tests/ui/traits/issue-78372.stderr
index f9c2c0d6dec..ec692ff911d 100644
--- a/tests/ui/traits/issue-78372.stderr
+++ b/tests/ui/traits/issue-78372.stderr
@@ -7,7 +7,6 @@ LL | struct Smaht<T, MISC>(PhantomData);
 help: consider importing this struct
    |
 LL + use std::marker::PhantomData;
-LL | use std::ops::DispatchFromDyn;
    |
 
 error[E0412]: cannot find type `U` in this scope
diff --git a/tests/ui/traits/item-privacy.stderr b/tests/ui/traits/item-privacy.stderr
index f505f36aaea..f5381318925 100644
--- a/tests/ui/traits/item-privacy.stderr
+++ b/tests/ui/traits/item-privacy.stderr
@@ -30,7 +30,6 @@ LL |     S.b();
 help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
 LL + use method::B;
-LL | struct S;
    |
 
 error[E0624]: method `a` is private
@@ -71,7 +70,6 @@ LL |     S::b(&S);
 help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
 LL + use method::B;
-LL | struct S;
    |
 
 error[E0624]: method `a` is private
@@ -112,7 +110,6 @@ LL |     S::B;
 help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
 LL + use assoc_const::B;
-LL | struct S;
    |
 
 error[E0624]: associated constant `A` is private
diff --git a/tests/ui/traits/method-private.stderr b/tests/ui/traits/method-private.stderr
index 2b047df75a0..e11799308c5 100644
--- a/tests/ui/traits/method-private.stderr
+++ b/tests/ui/traits/method-private.stderr
@@ -11,7 +11,6 @@ LL |     foo.method();
 help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
 LL + use inner::Bar;
-LL | mod inner {
    |
 
 error: aborting due to previous error
diff --git a/tests/ui/typeck/issue-43189.stderr b/tests/ui/typeck/issue-43189.stderr
index fa8a6143622..c072e6a08ba 100644
--- a/tests/ui/typeck/issue-43189.stderr
+++ b/tests/ui/typeck/issue-43189.stderr
@@ -13,7 +13,6 @@ LL |     fn a(&self) {}
 help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
 LL + use xcrate_issue_43189_b::xcrate_issue_43189_a::A;
-LL | extern crate xcrate_issue_43189_b;
    |
 
 error: aborting due to previous error
diff --git a/tests/ui/underscore-imports/shadow.stderr b/tests/ui/underscore-imports/shadow.stderr
index b0ecf129ca3..f2c19405bbb 100644
--- a/tests/ui/underscore-imports/shadow.stderr
+++ b/tests/ui/underscore-imports/shadow.stderr
@@ -8,7 +8,6 @@ LL |         x.deref();
 help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
 LL +     use std::ops::Deref;
-LL |     use crate::b::Shadow as _; // Only imports the struct
    |
 
 error: aborting due to previous error
diff --git a/tests/ui/unresolved/unresolved-candidates.stderr b/tests/ui/unresolved/unresolved-candidates.stderr
index 53f63c1c840..7ef2f6b1a29 100644
--- a/tests/ui/unresolved/unresolved-candidates.stderr
+++ b/tests/ui/unresolved/unresolved-candidates.stderr
@@ -18,7 +18,6 @@ LL |     impl Trait for () {}
 help: consider importing this trait
    |
 LL +     use a::Trait;
-LL |     impl Trait for () {}
    |
 
 error: aborting due to 2 previous errors