From 40878ca6ea79d6e55e430846a2de3350a76cd08f Mon Sep 17 00:00:00 2001
From: r0cky <mu001999@outlook.com>
Date: Tue, 2 Jan 2024 00:14:21 +0800
Subject: [PATCH 1/2] Make traits / trait methods detected by the dead code
 lint!

---
 compiler/rustc_passes/src/dead.rs          | 91 +++++++++++++++++-----
 tests/ui/lint/dead-code/issue-41883.rs     | 29 +++++++
 tests/ui/lint/dead-code/issue-41883.stderr | 36 +++++++++
 3 files changed, 136 insertions(+), 20 deletions(-)
 create mode 100644 tests/ui/lint/dead-code/issue-41883.rs
 create mode 100644 tests/ui/lint/dead-code/issue-41883.stderr

diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs
index d19987cb33c..e11102c459e 100644
--- a/compiler/rustc_passes/src/dead.rs
+++ b/compiler/rustc_passes/src/dead.rs
@@ -4,6 +4,7 @@
 // is dead.
 
 use hir::def_id::{LocalDefIdMap, LocalDefIdSet};
+use hir::ItemKind;
 use rustc_data_structures::unord::UnordSet;
 use rustc_errors::MultiSpan;
 use rustc_hir as hir;
@@ -14,7 +15,7 @@ use rustc_hir::{Node, PatKind, TyKind};
 use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
 use rustc_middle::middle::privacy::Level;
 use rustc_middle::query::Providers;
-use rustc_middle::ty::{self, TyCtxt};
+use rustc_middle::ty::{self, TyCtxt, Visibility};
 use rustc_session::lint;
 use rustc_session::lint::builtin::DEAD_CODE;
 use rustc_span::symbol::{sym, Symbol};
@@ -381,9 +382,46 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
                     intravisit::walk_item(self, item)
                 }
                 hir::ItemKind::ForeignMod { .. } => {}
+                hir::ItemKind::Trait(..) => {
+                    for impl_def_id in self.tcx.all_impls(item.owner_id.to_def_id()) {
+                        if let Some(local_def_id) = impl_def_id.as_local()
+                            && let ItemKind::Impl(impl_ref) =
+                                self.tcx.hir().expect_item(local_def_id).kind
+                        {
+                            // skip items
+                            // mark dependent traits live
+                            intravisit::walk_generics(self, impl_ref.generics);
+                            // mark dependent parameters live
+                            intravisit::walk_path(self, impl_ref.of_trait.unwrap().path);
+                        }
+                    }
+
+                    intravisit::walk_item(self, item)
+                }
                 _ => intravisit::walk_item(self, item),
             },
             Node::TraitItem(trait_item) => {
+                // mark corresponing ImplTerm live
+                let trait_item_id = trait_item.owner_id.to_def_id();
+                if let Some(trait_id) = self.tcx.trait_of_item(trait_item_id) {
+                    // mark the trait live
+                    self.check_def_id(trait_id);
+
+                    for impl_id in self.tcx.all_impls(trait_id) {
+                        if let Some(local_impl_id) = impl_id.as_local()
+                            && let ItemKind::Impl(impl_ref) =
+                                self.tcx.hir().expect_item(local_impl_id).kind
+                        {
+                            // mark self_ty live
+                            intravisit::walk_ty(self, impl_ref.self_ty);
+                            if let Some(&impl_item_id) =
+                                self.tcx.impl_item_implementor_ids(impl_id).get(&trait_item_id)
+                            {
+                                self.check_def_id(impl_item_id);
+                            }
+                        }
+                    }
+                }
                 intravisit::walk_trait_item(self, trait_item);
             }
             Node::ImplItem(impl_item) => {
@@ -636,10 +674,6 @@ fn check_item<'tcx>(
             }
         }
         DefKind::Impl { of_trait } => {
-            if of_trait {
-                worklist.push((id.owner_id.def_id, ComesFromAllowExpect::No));
-            }
-
             // get DefIds from another query
             let local_def_ids = tcx
                 .associated_item_def_ids(id.owner_id)
@@ -648,7 +682,11 @@ fn check_item<'tcx>(
 
             // And we access the Map here to get HirId from LocalDefId
             for id in local_def_ids {
-                if of_trait {
+                // for impl trait blocks, mark associate functions live if the trait is public
+                if of_trait
+                    && (!matches!(tcx.def_kind(id), DefKind::AssocFn)
+                        || tcx.local_visibility(id) == Visibility::Public)
+                {
                     worklist.push((id, ComesFromAllowExpect::No));
                 } else if let Some(comes_from_allow) = has_allow_dead_code_or_lang_attr(tcx, id) {
                     worklist.push((id, comes_from_allow));
@@ -679,7 +717,7 @@ fn check_trait_item(
     use hir::TraitItemKind::{Const, Fn};
     if matches!(tcx.def_kind(id.owner_id), DefKind::AssocConst | DefKind::AssocFn) {
         let trait_item = tcx.hir().trait_item(id);
-        if matches!(trait_item.kind, Const(_, Some(_)) | Fn(_, hir::TraitFn::Provided(_)))
+        if matches!(trait_item.kind, Const(_, Some(_)) | Fn(..))
             && let Some(comes_from_allow) =
                 has_allow_dead_code_or_lang_attr(tcx, trait_item.owner_id.def_id)
         {
@@ -948,7 +986,8 @@ impl<'tcx> DeadVisitor<'tcx> {
             | DefKind::TyAlias
             | DefKind::Enum
             | DefKind::Union
-            | DefKind::ForeignTy => self.warn_dead_code(def_id, "used"),
+            | DefKind::ForeignTy
+            | DefKind::Trait => self.warn_dead_code(def_id, "used"),
             DefKind::Struct => self.warn_dead_code(def_id, "constructed"),
             DefKind::Variant | DefKind::Field => bug!("should be handled specially"),
             _ => {}
@@ -973,18 +1012,33 @@ fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalModDefId) {
     let module_items = tcx.hir_module_items(module);
 
     for item in module_items.items() {
-        if let hir::ItemKind::Impl(impl_item) = tcx.hir().item(item).kind {
-            let mut dead_items = Vec::new();
-            for item in impl_item.items {
-                let def_id = item.id.owner_id.def_id;
-                if !visitor.is_live_code(def_id) {
-                    let name = tcx.item_name(def_id.to_def_id());
-                    let level = visitor.def_lint_level(def_id);
+        let def_kind = tcx.def_kind(item.owner_id);
 
-                    dead_items.push(DeadItem { def_id, name, level })
+        let mut dead_codes = Vec::new();
+        // if we have diagnosed the trait, do not diagnose unused methods
+        if matches!(def_kind, DefKind::Impl { .. })
+            || (def_kind == DefKind::Trait && live_symbols.contains(&item.owner_id.def_id))
+        {
+            for &def_id in tcx.associated_item_def_ids(item.owner_id.def_id) {
+                // We have diagnosed unused methods in traits
+                if matches!(def_kind, DefKind::Impl { of_trait: true })
+                    && tcx.def_kind(def_id) == DefKind::AssocFn
+                    || def_kind == DefKind::Trait && tcx.def_kind(def_id) != DefKind::AssocFn
+                {
+                    continue;
+                }
+
+                if let Some(local_def_id) = def_id.as_local()
+                    && !visitor.is_live_code(local_def_id)
+                {
+                    let name = tcx.item_name(def_id);
+                    let level = visitor.def_lint_level(local_def_id);
+                    dead_codes.push(DeadItem { def_id: local_def_id, name, level });
                 }
             }
-            visitor.warn_multiple(item.owner_id.def_id, "used", dead_items, ReportOn::NamedField);
+        }
+        if !dead_codes.is_empty() {
+            visitor.warn_multiple(item.owner_id.def_id, "used", dead_codes, ReportOn::NamedField);
         }
 
         if !live_symbols.contains(&item.owner_id.def_id) {
@@ -997,7 +1051,6 @@ fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalModDefId) {
             continue;
         }
 
-        let def_kind = tcx.def_kind(item.owner_id);
         if let DefKind::Struct | DefKind::Union | DefKind::Enum = def_kind {
             let adt = tcx.adt_def(item.owner_id);
             let mut dead_variants = Vec::new();
@@ -1044,8 +1097,6 @@ fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalModDefId) {
     for foreign_item in module_items.foreign_items() {
         visitor.check_definition(foreign_item.owner_id.def_id);
     }
-
-    // We do not warn trait items.
 }
 
 pub(crate) fn provide(providers: &mut Providers) {
diff --git a/tests/ui/lint/dead-code/issue-41883.rs b/tests/ui/lint/dead-code/issue-41883.rs
new file mode 100644
index 00000000000..e165861e893
--- /dev/null
+++ b/tests/ui/lint/dead-code/issue-41883.rs
@@ -0,0 +1,29 @@
+#![deny(dead_code)]
+
+enum Category {
+    Dead, //~ ERROR variant `Dead` is never constructed
+    Used,
+}
+
+trait UnusedTrait { //~ ERROR trait `UnusedTrait` is never used
+    fn this_is_unused(&self) -> Category {
+        Category::Dead
+    }
+}
+
+struct UnusedStruct; //~ ERROR struct `UnusedStruct` is never constructed
+
+impl UnusedTrait for UnusedStruct {
+    fn this_is_unused(&self) -> Category {
+        Category::Used
+    }
+}
+
+mod private {
+    #[derive(Debug)]
+    struct UnusedStruct; //~ ERROR struct `UnusedStruct` is never constructed
+}
+
+fn main() {
+    let _c = Category::Used;
+}
diff --git a/tests/ui/lint/dead-code/issue-41883.stderr b/tests/ui/lint/dead-code/issue-41883.stderr
new file mode 100644
index 00000000000..cf079e4dda3
--- /dev/null
+++ b/tests/ui/lint/dead-code/issue-41883.stderr
@@ -0,0 +1,36 @@
+error: variant `Dead` is never constructed
+  --> $DIR/issue-41883.rs:4:5
+   |
+LL | enum Category {
+   |      -------- variant in this enum
+LL |     Dead,
+   |     ^^^^
+   |
+note: the lint level is defined here
+  --> $DIR/issue-41883.rs:1:9
+   |
+LL | #![deny(dead_code)]
+   |         ^^^^^^^^^
+
+error: trait `UnusedTrait` is never used
+  --> $DIR/issue-41883.rs:8:7
+   |
+LL | trait UnusedTrait {
+   |       ^^^^^^^^^^^
+
+error: struct `UnusedStruct` is never constructed
+  --> $DIR/issue-41883.rs:14:8
+   |
+LL | struct UnusedStruct;
+   |        ^^^^^^^^^^^^
+
+error: struct `UnusedStruct` is never constructed
+  --> $DIR/issue-41883.rs:24:12
+   |
+LL |     struct UnusedStruct;
+   |            ^^^^^^^^^^^^
+   |
+   = note: `UnusedStruct` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
+
+error: aborting due to 4 previous errors
+

From c7519d42c2664828c98fdb98acab73e9a39b0b97 Mon Sep 17 00:00:00 2001
From: r0cky <mu001999@outlook.com>
Date: Wed, 7 Feb 2024 10:42:01 +0800
Subject: [PATCH 2/2] Update tests

---
 compiler/rustc_span/src/source_map/tests.rs   | 49 +------------------
 library/core/tests/macros.rs                  |  1 +
 library/std/src/sys_common/mod.rs             |  2 +
 .../tests/fail/dyn-call-trait-mismatch.rs     |  1 +
 .../tests/fail/dyn-upcast-trait-mismatch.rs   |  6 +++
 .../tests/pass/cast-rfc0401-vtable-kinds.rs   |  1 +
 src/tools/miri/tests/pass/dyn-upcast.rs       |  3 ++
 src/tools/miri/tests/pass/weak_memory/weak.rs |  1 +
 src/tools/tidy/src/ui_tests.rs                |  5 +-
 .../instantiation-through-vtable.rs           |  4 +-
 .../trait-method-default-impl.rs              |  3 ++
 .../codegen-units/item-collection/unsizing.rs |  2 +
 tests/ui-fulldeps/rustc_encodable_hygiene.rs  |  2 +-
 .../anon-params/anon-params-deprecated.fixed  |  1 +
 .../ui/anon-params/anon-params-deprecated.rs  |  1 +
 .../anon-params/anon-params-deprecated.stderr |  6 +--
 .../associated-const-outer-ty-refs.rs         |  3 +-
 .../associated-const-type-parameters.rs       |  2 +-
 .../associated-const-type-parameters.stderr   | 10 ++++
 .../dyn-impl-trait-type.rs                    |  2 +-
 .../dyn-impl-trait-type.stderr                | 12 +++++
 .../dyn-rpit-and-let.rs                       |  2 +-
 .../dyn-rpit-and-let.stderr                   | 12 +++++
 tests/ui/associated-type-bounds/rpit.rs       |  2 +-
 tests/ui/associated-type-bounds/rpit.stderr   | 12 +++++
 ...ng-assoc-type-because-of-assoc-const.fixed |  1 +
 ...ining-assoc-type-because-of-assoc-const.rs |  1 +
 ...g-assoc-type-because-of-assoc-const.stderr |  2 +-
 .../trait-alias-impl-trait.rs                 |  1 +
 .../associated-types-for-unimpl-trait.fixed   |  1 +
 .../associated-types-for-unimpl-trait.rs      |  1 +
 .../associated-types-for-unimpl-trait.stderr  |  2 +-
 .../associated-types-in-bound-type-arg.rs     |  2 +-
 .../associated-types-issue-20220.rs           |  2 +-
 .../associated-types-issue-20220.stderr       | 10 ++++
 .../associated-types-issue-20371.rs           |  2 +-
 .../associated-types-nested-projections.rs    |  2 +-
 ...associated-types-nested-projections.stderr | 13 +++++
 ...sociated-types-normalize-in-bounds-ufcs.rs |  2 +-
 .../associated-types-normalize-in-bounds.rs   |  2 +-
 ...d-types-projection-bound-in-supertraits.rs |  2 +-
 ...ypes-projection-from-known-type-in-impl.rs |  2 +-
 ...-projection-from-known-type-in-impl.stderr | 13 +++++
 ...ated-trait-in-method-without-default.fixed |  1 +
 ...related-trait-in-method-without-default.rs |  1 +
 ...ted-trait-in-method-without-default.stderr |  2 +-
 ...ted-types-projection-to-unrelated-trait.rs |  2 +-
 ...ed-path-with-trait-with-type-parameters.rs |  2 +-
 .../associated-types-resolve-lifetime.rs      |  2 +-
 .../ui/associated-types/impl-wf-cycle-5.fixed |  2 +
 tests/ui/associated-types/impl-wf-cycle-5.rs  |  2 +
 .../associated-types/impl-wf-cycle-5.stderr   |  4 +-
 .../ui/associated-types/impl-wf-cycle-6.fixed |  2 +
 tests/ui/associated-types/impl-wf-cycle-6.rs  |  2 +
 .../associated-types/impl-wf-cycle-6.stderr   |  4 +-
 .../auto-traits/auto-trait-validation.fixed   |  1 +
 tests/ui/auto-traits/auto-trait-validation.rs |  1 +
 .../auto-traits/auto-trait-validation.stderr  |  8 +--
 tests/ui/auto-traits/auto-traits.rs           |  4 +-
 tests/ui/auto-traits/auto-traits.stderr       | 16 ++++++
 .../builtin-superkinds-in-metadata2.rs        |  2 +-
 .../builtin-superkinds-simple2.rs             |  2 +-
 .../builtin-superkinds-typaram.rs             |  2 +-
 tests/ui/cast/cast-rfc0401-vtable-kinds.rs    |  2 +-
 .../ui/cast/cast-rfc0401-vtable-kinds.stderr  | 10 ++++
 tests/ui/cast/fat-ptr-cast-rpass.rs           |  2 +-
 tests/ui/cast/fat-ptr-cast-rpass.stderr       | 12 +++++
 tests/ui/coercion/issue-14589.rs              |  2 +-
 tests/ui/coercion/issue-14589.stderr          | 12 +++++
 .../coherence-multidispatch-tuple.rs          |  2 +-
 .../const-generics/associated-type-bound.rs   |  2 +-
 .../condition-in-trait-const-arg.rs           |  2 +-
 tests/ui/const-generics/dyn-supertraits.rs    |  6 +--
 .../ui/const-generics/dyn-supertraits.stderr  | 22 +++++++++
 .../issues/issue-69654-run-pass.rs            |  2 +-
 .../issues/issue-69654-run-pass.stderr        | 10 ++++
 tests/ui/consts/const-block-item.rs           |  2 +-
 tests/ui/consts/const-block-item.stderr       | 10 ++++
 tests/ui/consts/underscore_const_names.rs     |  4 +-
 tests/ui/default-method-parsing.rs            |  2 +-
 tests/ui/delegation/target-expr-pass.rs       |  6 +--
 tests/ui/delegation/target-expr-pass.stderr   | 22 ++++++++-
 tests/ui/deriving/deriving-bounds.rs          |  2 +-
 tests/ui/drop/drop-struct-as-object.rs        |  2 +-
 tests/ui/drop/drop-struct-as-object.stderr    | 12 +++++
 .../dynamically-sized-types/dst-coercions.rs  |  2 +-
 .../dst-coercions.stderr                      | 12 +++++
 tests/ui/empty-type-parameter-list.rs         |  2 +-
 tests/ui/empty-type-parameter-list.stderr     | 10 ++++
 .../explicit-call-to-supertrait-dtor.fixed    |  1 +
 .../explicit-call-to-supertrait-dtor.rs       |  1 +
 .../explicit-call-to-supertrait-dtor.stderr   |  2 +-
 tests/ui/extern/no-mangle-associated-fn.rs    |  2 +-
 .../ui/extern/no-mangle-associated-fn.stderr  | 10 ++++
 .../issue-88360.fixed                         |  1 +
 .../generic-associated-types/issue-88360.rs   |  1 +
 .../issue-88360.stderr                        |  2 +-
 tests/ui/generics/generic-no-mangle.fixed     |  2 +-
 tests/ui/generics/generic-no-mangle.rs        |  2 +-
 tests/ui/impl-trait/example-st.rs             |  2 +-
 tests/ui/impl-trait/example-st.stderr         | 10 ++++
 .../in-trait/suggest-missing-item.fixed       |  1 +
 .../in-trait/suggest-missing-item.rs          |  1 +
 .../in-trait/suggest-missing-item.stderr      |  2 +-
 .../ui/impl-trait/type-alias-generic-param.rs |  2 +-
 .../type-alias-generic-param.stderr           | 10 ++++
 tests/ui/issues/issue-14399.rs                |  2 +-
 tests/ui/issues/issue-14399.stderr            | 12 +++++
 tests/ui/issues/issue-15858.rs                |  2 +-
 tests/ui/issues/issue-15858.stderr            | 12 +++++
 tests/ui/issues/issue-17351.rs                |  2 +-
 tests/ui/issues/issue-17351.stderr            | 12 +++++
 tests/ui/issues/issue-18173.rs                |  2 +-
 tests/ui/issues/issue-20055-box-trait.rs      |  2 +-
 tests/ui/issues/issue-20055-box-trait.stderr  | 12 +++++
 tests/ui/issues/issue-21909.rs                |  2 +-
 tests/ui/issues/issue-23485.rs                |  2 +-
 tests/ui/issues/issue-23485.stderr            | 13 +++++
 tests/ui/issues/issue-2989.rs                 |  4 +-
 tests/ui/issues/issue-2989.stderr             | 10 ++++
 tests/ui/issues/issue-34074.rs                |  2 +-
 tests/ui/issues/issue-34503.rs                |  2 +-
 tests/ui/issues/issue-34503.stderr            | 14 ++++++
 tests/ui/issues/issue-3563-3.rs               |  2 +-
 tests/ui/issues/issue-3563-3.stderr           | 13 +++++
 tests/ui/issues/issue-50571.fixed             |  1 +
 tests/ui/issues/issue-50571.rs                |  1 +
 tests/ui/issues/issue-50571.stderr            |  2 +-
 tests/ui/issues/issue-7575.rs                 |  2 +-
 tests/ui/issues/issue-7575.stderr             | 10 ++++
 tests/ui/issues/issue-7911.rs                 |  2 +-
 tests/ui/issues/issue-7911.stderr             | 12 +++++
 tests/ui/issues/issue-8248.rs                 |  2 +-
 tests/ui/issues/issue-8248.stderr             | 12 +++++
 tests/ui/issues/issue-9951.rs                 |  2 +-
 tests/ui/issues/issue-9951.stderr             | 12 +++++
 tests/ui/lint/dead-code/associated-type.rs    |  2 +-
 .../multiple-dead-codes-in-the-same-struct.rs |  2 +-
 ...tiple-dead-codes-in-the-same-struct.stderr | 12 ++---
 tests/ui/lint/issue-20343.rs                  |  3 ++
 tests/ui/macros/issue-22463.rs                |  2 +-
 tests/ui/methods/method-lookup-order.rs       |  1 +
 .../methods/method-recursive-blanket-impl.rs  |  2 +-
 .../method-recursive-blanket-impl.stderr      | 10 ++++
 .../method-two-trait-defer-resolution-2.rs    |  2 +-
 ...method-two-trait-defer-resolution-2.stderr | 12 +++++
 ...o-traits-distinguished-via-where-clause.rs |  2 +-
 ...aits-distinguished-via-where-clause.stderr | 10 ++++
 tests/ui/mir/mir_raw_fat_ptr.rs               |  2 +-
 tests/ui/mir/mir_raw_fat_ptr.stderr           | 12 +++++
 .../ui/moves/issue-22536-copy-mustnt-zero.rs  |  2 +-
 .../moves/issue-22536-copy-mustnt-zero.stderr | 13 +++++
 .../assoc_type_bounds_implicit_sized.fixed    |  1 +
 .../assoc_type_bounds_implicit_sized.rs       |  1 +
 .../assoc_type_bounds_implicit_sized.stderr   |  4 +-
 tests/ui/overloaded/issue-14958.rs            |  2 +-
 tests/ui/overloaded/issue-14958.stderr        | 12 +++++
 .../overloaded/overloaded-index-in-field.rs   |  2 +-
 .../overloaded-index-in-field.stderr          | 15 ++++++
 tests/ui/parser/parse-assoc-type-lt.rs        |  2 +-
 tests/ui/parser/suggest-assoc-const.fixed     |  1 +
 tests/ui/parser/suggest-assoc-const.rs        |  1 +
 tests/ui/parser/suggest-assoc-const.stderr    |  2 +-
 ...ing-semicolon-after-impl-trait-items.fixed |  1 +
 ...moving-semicolon-after-impl-trait-items.rs |  1 +
 ...ng-semicolon-after-impl-trait-items.stderr |  2 +-
 tests/ui/pattern/issue-22546.rs               |  2 +-
 tests/ui/pattern/issue-22546.stderr           | 10 ++++
 .../sealed-traits/re-exported-trait.fixed     |  1 +
 .../sealed-traits/re-exported-trait.rs        |  1 +
 .../sealed-traits/re-exported-trait.stderr    |  4 +-
 ...est-fix-invalid-top-level-macro-attr.fixed |  1 +
 ...uggest-fix-invalid-top-level-macro-attr.rs |  1 +
 ...st-fix-invalid-top-level-macro-attr.stderr |  1 +
 .../regions-no-variance-from-fn-generics.rs   |  2 +-
 ...lid-unused-qualifications-suggestion.fixed |  1 +
 ...nvalid-unused-qualifications-suggestion.rs |  1 +
 ...id-unused-qualifications-suggestion.stderr |  6 +--
 ...al-self-impl-for-unsafe-obj.current.stderr | 15 ++++++
 ...anual-self-impl-for-unsafe-obj.next.stderr | 15 ++++++
 .../manual-self-impl-for-unsafe-obj.rs        |  2 +-
 tests/ui/rust-2018/issue-51008-1.rs           |  2 +-
 tests/ui/rust-2018/issue-51008.rs             |  2 +-
 tests/ui/sized/coinductive-2.rs               |  2 +-
 tests/ui/sized/coinductive-2.stderr           | 10 ++++
 .../ui/specialization/assoc-ty-graph-cycle.rs |  2 +-
 .../defaultimpl/out-of-order.rs               |  2 +-
 .../defaultimpl/overlap-projection.rs         |  2 +-
 .../specialization-out-of-order.rs            |  2 +-
 .../specialization-overlap-projection.rs      |  2 +-
 .../specialization-supertraits.rs             |  2 +-
 tests/ui/statics/static-impl.rs               |  2 +-
 tests/ui/statics/static-impl.stderr           | 13 +++++
 tests/ui/stdlib-unit-tests/raw-fat-ptr.rs     |  2 +-
 tests/ui/stdlib-unit-tests/raw-fat-ptr.stderr | 12 +++++
 .../ui/structs-enums/enum-null-pointer-opt.rs |  2 +-
 .../enum-null-pointer-opt.stderr              | 12 +++++
 tests/ui/suggestions/bound-suggestions.fixed  |  5 ++
 tests/ui/suggestions/bound-suggestions.rs     |  5 ++
 tests/ui/suggestions/bound-suggestions.stderr | 10 ++--
 tests/ui/suggestions/constrain-trait.fixed    |  1 +
 tests/ui/suggestions/constrain-trait.rs       |  1 +
 tests/ui/suggestions/constrain-trait.stderr   |  4 +-
 .../lifetimes/type-param-bound-scope.fixed    |  1 +
 .../lifetimes/type-param-bound-scope.rs       |  1 +
 .../lifetimes/type-param-bound-scope.stderr   | 10 ++--
 .../missing-bound-in-manual-copy-impl-2.fixed |  1 +
 .../missing-bound-in-manual-copy-impl-2.rs    |  1 +
 ...missing-bound-in-manual-copy-impl-2.stderr |  4 +-
 .../missing-bound-in-manual-copy-impl.fixed   |  1 +
 .../missing-bound-in-manual-copy-impl.rs      |  1 +
 .../missing-bound-in-manual-copy-impl.stderr  |  2 +-
 tests/ui/suggestions/missing-trait-item.fixed |  1 +
 tests/ui/suggestions/missing-trait-item.rs    |  1 +
 .../ui/suggestions/missing-trait-item.stderr  |  4 +-
 .../ui/threads-sendsync/sync-send-atomics.rs  |  2 +-
 tests/ui/traits/alias/bounds.rs               |  2 +-
 tests/ui/traits/alias/bounds.stderr           | 10 ++++
 tests/ui/traits/alias/syntax.rs               |  2 +-
 .../bound/impl-comparison-duplicates.rs       |  2 +-
 tests/ui/traits/bound/recursion.rs            |  2 +-
 tests/ui/traits/composition-trivial.rs        |  2 +-
 tests/ui/traits/cycle-generic-bound.rs        |  2 +-
 .../ui/traits/default-method/bound-subst4.rs  |  2 +-
 .../traits/default-method/bound-subst4.stderr | 13 +++++
 tests/ui/traits/default-method/mut.rs         |  2 +-
 .../traits/impl-inherent-prefer-over-trait.rs |  2 +-
 .../impl-inherent-prefer-over-trait.stderr    | 12 +++++
 .../traits/impl-object-overlap-issue-23853.rs |  2 +-
 .../impl-object-overlap-issue-23853.stderr    | 12 +++++
 tests/ui/traits/impl.rs                       |  2 +-
 tests/ui/traits/impl.stderr                   | 12 +++++
 tests/ui/traits/issue-38033.rs                |  2 +-
 tests/ui/traits/issue-38033.stderr            | 13 +++++
 tests/ui/traits/issue-56488.rs                |  2 +-
 tests/ui/traits/issue-59029-2.rs              |  2 +-
 tests/ui/traits/issue-6128.rs                 |  2 +-
 tests/ui/traits/issue-6128.stderr             | 14 ++++++
 ...ispatch-conditional-impl-not-considered.rs |  2 +-
 ...tch-conditional-impl-not-considered.stderr | 10 ++++
 .../multidispatch-infer-convert-target.rs     |  2 +-
 .../multidispatch-infer-convert-target.stderr | 12 +++++
 .../negative-specializes-negative.rs          |  2 +-
 tests/ui/traits/trait-upcasting/lifetime.rs   |  4 +-
 .../ui/traits/trait-upcasting/lifetime.stderr | 25 ++++++++++
 .../ui/traits/trait-upcasting/replace-vptr.rs |  4 +-
 .../trait-upcasting/replace-vptr.stderr       | 20 ++++++++
 tests/ui/traits/use-before-def.rs             |  2 +-
 tests/ui/traits/wf-object/reverse-order.rs    |  2 +-
 tests/ui/trivial_casts-rpass.rs               |  2 +-
 tests/ui/trivial_casts-rpass.stderr           | 12 +++++
 tests/ui/type-alias-impl-trait/issue-58887.rs |  2 +-
 ...use-inherent-impl-ampersand-rust2015.fixed |  1 +
 ...clause-inherent-impl-ampersand-rust2015.rs |  1 +
 ...se-inherent-impl-ampersand-rust2015.stderr |  2 +-
 ...use-inherent-impl-ampersand-rust2018.fixed |  1 +
 ...clause-inherent-impl-ampersand-rust2018.rs |  1 +
 ...se-inherent-impl-ampersand-rust2018.stderr |  2 +-
 .../where-clause-trait-impl-region-2015.fixed |  1 +
 .../where-clause-trait-impl-region-2015.rs    |  1 +
 ...where-clause-trait-impl-region-2015.stderr |  2 +-
 .../where-clause-trait-impl-region-2018.fixed |  2 +
 .../where-clause-trait-impl-region-2018.rs    |  2 +
 ...where-clause-trait-impl-region-2018.stderr |  2 +-
 tests/ui/where-clauses/issue-50825-1.rs       |  2 +-
 .../where-clause-bounds-inconsistency.rs      |  2 +-
 .../where-clause-early-bound-lifetimes.rs     |  2 +-
 .../where-clause-early-bound-lifetimes.stderr | 12 +++++
 .../where-clause-method-substituion-rpass.rs  |  2 +-
 ...ere-clause-method-substituion-rpass.stderr | 12 +++++
 ...-clause-placement-assoc-type-in-impl.fixed |  2 +
 ...ere-clause-placement-assoc-type-in-impl.rs |  2 +
 ...clause-placement-assoc-type-in-impl.stderr |  6 +--
 ...clause-placement-assoc-type-in-trait.fixed |  1 +
 ...re-clause-placement-assoc-type-in-trait.rs |  1 +
 ...lause-placement-assoc-type-in-trait.stderr |  4 +-
 276 files changed, 1049 insertions(+), 234 deletions(-)
 create mode 100644 tests/ui/associated-consts/associated-const-type-parameters.stderr
 create mode 100644 tests/ui/associated-type-bounds/dyn-impl-trait-type.stderr
 create mode 100644 tests/ui/associated-type-bounds/dyn-rpit-and-let.stderr
 create mode 100644 tests/ui/associated-type-bounds/rpit.stderr
 create mode 100644 tests/ui/associated-types/associated-types-issue-20220.stderr
 create mode 100644 tests/ui/associated-types/associated-types-nested-projections.stderr
 create mode 100644 tests/ui/associated-types/associated-types-projection-from-known-type-in-impl.stderr
 create mode 100644 tests/ui/auto-traits/auto-traits.stderr
 create mode 100644 tests/ui/cast/cast-rfc0401-vtable-kinds.stderr
 create mode 100644 tests/ui/cast/fat-ptr-cast-rpass.stderr
 create mode 100644 tests/ui/coercion/issue-14589.stderr
 create mode 100644 tests/ui/const-generics/dyn-supertraits.stderr
 create mode 100644 tests/ui/const-generics/issues/issue-69654-run-pass.stderr
 create mode 100644 tests/ui/consts/const-block-item.stderr
 create mode 100644 tests/ui/drop/drop-struct-as-object.stderr
 create mode 100644 tests/ui/dynamically-sized-types/dst-coercions.stderr
 create mode 100644 tests/ui/empty-type-parameter-list.stderr
 create mode 100644 tests/ui/extern/no-mangle-associated-fn.stderr
 create mode 100644 tests/ui/impl-trait/example-st.stderr
 create mode 100644 tests/ui/impl-trait/type-alias-generic-param.stderr
 create mode 100644 tests/ui/issues/issue-14399.stderr
 create mode 100644 tests/ui/issues/issue-15858.stderr
 create mode 100644 tests/ui/issues/issue-17351.stderr
 create mode 100644 tests/ui/issues/issue-20055-box-trait.stderr
 create mode 100644 tests/ui/issues/issue-23485.stderr
 create mode 100644 tests/ui/issues/issue-2989.stderr
 create mode 100644 tests/ui/issues/issue-34503.stderr
 create mode 100644 tests/ui/issues/issue-3563-3.stderr
 create mode 100644 tests/ui/issues/issue-7575.stderr
 create mode 100644 tests/ui/issues/issue-7911.stderr
 create mode 100644 tests/ui/issues/issue-8248.stderr
 create mode 100644 tests/ui/issues/issue-9951.stderr
 create mode 100644 tests/ui/methods/method-recursive-blanket-impl.stderr
 create mode 100644 tests/ui/methods/method-two-trait-defer-resolution-2.stderr
 create mode 100644 tests/ui/methods/method-two-traits-distinguished-via-where-clause.stderr
 create mode 100644 tests/ui/mir/mir_raw_fat_ptr.stderr
 create mode 100644 tests/ui/moves/issue-22536-copy-mustnt-zero.stderr
 create mode 100644 tests/ui/overloaded/issue-14958.stderr
 create mode 100644 tests/ui/overloaded/overloaded-index-in-field.stderr
 create mode 100644 tests/ui/pattern/issue-22546.stderr
 create mode 100644 tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.current.stderr
 create mode 100644 tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.next.stderr
 create mode 100644 tests/ui/sized/coinductive-2.stderr
 create mode 100644 tests/ui/statics/static-impl.stderr
 create mode 100644 tests/ui/stdlib-unit-tests/raw-fat-ptr.stderr
 create mode 100644 tests/ui/structs-enums/enum-null-pointer-opt.stderr
 create mode 100644 tests/ui/traits/alias/bounds.stderr
 create mode 100644 tests/ui/traits/default-method/bound-subst4.stderr
 create mode 100644 tests/ui/traits/impl-inherent-prefer-over-trait.stderr
 create mode 100644 tests/ui/traits/impl-object-overlap-issue-23853.stderr
 create mode 100644 tests/ui/traits/impl.stderr
 create mode 100644 tests/ui/traits/issue-38033.stderr
 create mode 100644 tests/ui/traits/issue-6128.stderr
 create mode 100644 tests/ui/traits/multidispatch-conditional-impl-not-considered.stderr
 create mode 100644 tests/ui/traits/multidispatch-infer-convert-target.stderr
 create mode 100644 tests/ui/traits/trait-upcasting/lifetime.stderr
 create mode 100644 tests/ui/traits/trait-upcasting/replace-vptr.stderr
 create mode 100644 tests/ui/trivial_casts-rpass.stderr
 create mode 100644 tests/ui/where-clauses/where-clause-early-bound-lifetimes.stderr
 create mode 100644 tests/ui/where-clauses/where-clause-method-substituion-rpass.stderr

diff --git a/compiler/rustc_span/src/source_map/tests.rs b/compiler/rustc_span/src/source_map/tests.rs
index 5788d11ed43..51f8aa04e8a 100644
--- a/compiler/rustc_span/src/source_map/tests.rs
+++ b/compiler/rustc_span/src/source_map/tests.rs
@@ -1,5 +1,7 @@
 use super::*;
 
+use rustc_data_structures::sync::FreezeLock;
+
 fn init_source_map() -> SourceMap {
     let sm = SourceMap::new(FilePathMapping::empty());
     sm.new_source_file(PathBuf::from("blork.rs").into(), "first line.\nsecond line".to_string());
@@ -263,53 +265,6 @@ fn t10() {
     );
 }
 
-/// Returns the span corresponding to the `n`th occurrence of `substring` in `source_text`.
-trait SourceMapExtension {
-    fn span_substr(
-        &self,
-        file: &Lrc<SourceFile>,
-        source_text: &str,
-        substring: &str,
-        n: usize,
-    ) -> Span;
-}
-
-impl SourceMapExtension for SourceMap {
-    fn span_substr(
-        &self,
-        file: &Lrc<SourceFile>,
-        source_text: &str,
-        substring: &str,
-        n: usize,
-    ) -> Span {
-        eprintln!(
-            "span_substr(file={:?}/{:?}, substring={:?}, n={})",
-            file.name, file.start_pos, substring, n
-        );
-        let mut i = 0;
-        let mut hi = 0;
-        loop {
-            let offset = source_text[hi..].find(substring).unwrap_or_else(|| {
-                panic!(
-                    "source_text `{}` does not have {} occurrences of `{}`, only {}",
-                    source_text, n, substring, i
-                );
-            });
-            let lo = hi + offset;
-            hi = lo + substring.len();
-            if i == n {
-                let span = Span::with_root_ctxt(
-                    BytePos(lo as u32 + file.start_pos.0),
-                    BytePos(hi as u32 + file.start_pos.0),
-                );
-                assert_eq!(&self.span_to_snippet(span).unwrap()[..], substring);
-                return span;
-            }
-            i += 1;
-        }
-    }
-}
-
 // Takes a unix-style path and returns a platform specific path.
 fn path(p: &str) -> PathBuf {
     path_str(p).into()
diff --git a/library/core/tests/macros.rs b/library/core/tests/macros.rs
index eb886def164..09994fbcbdb 100644
--- a/library/core/tests/macros.rs
+++ b/library/core/tests/macros.rs
@@ -1,3 +1,4 @@
+#[allow(dead_code)]
 trait Trait {
     fn blah(&self);
 }
diff --git a/library/std/src/sys_common/mod.rs b/library/std/src/sys_common/mod.rs
index 851832a377c..01f83ecb414 100644
--- a/library/std/src/sys_common/mod.rs
+++ b/library/std/src/sys_common/mod.rs
@@ -59,12 +59,14 @@ cfg_if::cfg_if! {
 
 /// A trait for viewing representations from std types
 #[doc(hidden)]
+#[allow(dead_code)] // not used on all platforms
 pub trait AsInner<Inner: ?Sized> {
     fn as_inner(&self) -> &Inner;
 }
 
 /// A trait for viewing representations from std types
 #[doc(hidden)]
+#[allow(dead_code)] // not used on all platforms
 pub trait AsInnerMut<Inner: ?Sized> {
     fn as_inner_mut(&mut self) -> &mut Inner;
 }
diff --git a/src/tools/miri/tests/fail/dyn-call-trait-mismatch.rs b/src/tools/miri/tests/fail/dyn-call-trait-mismatch.rs
index 0e7c3dbcc04..13f913454dc 100644
--- a/src/tools/miri/tests/fail/dyn-call-trait-mismatch.rs
+++ b/src/tools/miri/tests/fail/dyn-call-trait-mismatch.rs
@@ -1,4 +1,5 @@
 trait T1 {
+    #[allow(dead_code)]
     fn method1(self: Box<Self>);
 }
 trait T2 {
diff --git a/src/tools/miri/tests/fail/dyn-upcast-trait-mismatch.rs b/src/tools/miri/tests/fail/dyn-upcast-trait-mismatch.rs
index 648ac07c43e..982f33b0a31 100644
--- a/src/tools/miri/tests/fail/dyn-upcast-trait-mismatch.rs
+++ b/src/tools/miri/tests/fail/dyn-upcast-trait-mismatch.rs
@@ -2,30 +2,36 @@
 #![allow(incomplete_features)]
 
 trait Foo: PartialEq<i32> + std::fmt::Debug + Send + Sync {
+    #[allow(dead_code)]
     fn a(&self) -> i32 {
         10
     }
 
+    #[allow(dead_code)]
     fn z(&self) -> i32 {
         11
     }
 
+    #[allow(dead_code)]
     fn y(&self) -> i32 {
         12
     }
 }
 
 trait Bar: Foo {
+    #[allow(dead_code)]
     fn b(&self) -> i32 {
         20
     }
 
+    #[allow(dead_code)]
     fn w(&self) -> i32 {
         21
     }
 }
 
 trait Baz: Bar {
+    #[allow(dead_code)]
     fn c(&self) -> i32 {
         30
     }
diff --git a/src/tools/miri/tests/pass/cast-rfc0401-vtable-kinds.rs b/src/tools/miri/tests/pass/cast-rfc0401-vtable-kinds.rs
index ccf96b99672..2491bda0917 100644
--- a/src/tools/miri/tests/pass/cast-rfc0401-vtable-kinds.rs
+++ b/src/tools/miri/tests/pass/cast-rfc0401-vtable-kinds.rs
@@ -9,6 +9,7 @@ trait Foo<T> {
     }
 }
 
+#[allow(dead_code)]
 trait Bar {
     fn bar(&self) {
         println!("Bar!");
diff --git a/src/tools/miri/tests/pass/dyn-upcast.rs b/src/tools/miri/tests/pass/dyn-upcast.rs
index 8432012a9ba..529b9c471d4 100644
--- a/src/tools/miri/tests/pass/dyn-upcast.rs
+++ b/src/tools/miri/tests/pass/dyn-upcast.rs
@@ -383,14 +383,17 @@ fn struct_() {
 
 fn replace_vptr() {
     trait A {
+        #[allow(dead_code)]
         fn foo_a(&self);
     }
 
     trait B {
+        #[allow(dead_code)]
         fn foo_b(&self);
     }
 
     trait C: A + B {
+        #[allow(dead_code)]
         fn foo_c(&self);
     }
 
diff --git a/src/tools/miri/tests/pass/weak_memory/weak.rs b/src/tools/miri/tests/pass/weak_memory/weak.rs
index 4c3be6b3559..e10ccc277f6 100644
--- a/src/tools/miri/tests/pass/weak_memory/weak.rs
+++ b/src/tools/miri/tests/pass/weak_memory/weak.rs
@@ -11,6 +11,7 @@ use std::sync::atomic::Ordering::*;
 use std::sync::atomic::{fence, AtomicUsize};
 use std::thread::spawn;
 
+#[allow(dead_code)]
 #[derive(Copy, Clone)]
 struct EvilSend<T>(pub T);
 
diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs
index 09469427426..e7b1ccf6a02 100644
--- a/src/tools/tidy/src/ui_tests.rs
+++ b/src/tools/tidy/src/ui_tests.rs
@@ -13,8 +13,9 @@ use std::path::{Path, PathBuf};
 // desirable, because large numbers of files are unwieldy in general. See issue
 // #73494.
 const ENTRY_LIMIT: usize = 900;
-const ISSUES_ENTRY_LIMIT: usize = 1807;
-const ROOT_ENTRY_LIMIT: usize = 868;
+// FIXME: The following limits should be reduced eventually.
+const ISSUES_ENTRY_LIMIT: usize = 1819;
+const ROOT_ENTRY_LIMIT: usize = 870;
 
 const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
     "rs",     // test source files
diff --git a/tests/codegen-units/item-collection/instantiation-through-vtable.rs b/tests/codegen-units/item-collection/instantiation-through-vtable.rs
index e78226d4083..41edab7f879 100644
--- a/tests/codegen-units/item-collection/instantiation-through-vtable.rs
+++ b/tests/codegen-units/item-collection/instantiation-through-vtable.rs
@@ -26,7 +26,9 @@ fn start(_: isize, _: *const *const u8) -> isize {
     //~ MONO_ITEM fn std::ptr::drop_in_place::<Struct<u32>> - shim(None) @@ instantiation_through_vtable-cgu.0[Internal]
     //~ MONO_ITEM fn <Struct<u32> as Trait>::foo
     //~ MONO_ITEM fn <Struct<u32> as Trait>::bar
-    let _ = &s1 as &Trait;
+    let r1 = &s1 as &Trait;
+    r1.foo();
+    r1.bar();
 
     let s1 = Struct { _a: 0u64 };
     //~ MONO_ITEM fn std::ptr::drop_in_place::<Struct<u64>> - shim(None) @@ instantiation_through_vtable-cgu.0[Internal]
diff --git a/tests/codegen-units/item-collection/trait-method-default-impl.rs b/tests/codegen-units/item-collection/trait-method-default-impl.rs
index d953582cce9..c8a4552b11a 100644
--- a/tests/codegen-units/item-collection/trait-method-default-impl.rs
+++ b/tests/codegen-units/item-collection/trait-method-default-impl.rs
@@ -57,5 +57,8 @@ fn start(_: isize, _: *const *const u8) -> isize {
     //~ MONO_ITEM fn <u32 as SomeGenericTrait<i16>>::bar::<()>
     0u32.bar(0i16, ());
 
+    0i8.foo();
+    0i32.foo();
+
     0
 }
diff --git a/tests/codegen-units/item-collection/unsizing.rs b/tests/codegen-units/item-collection/unsizing.rs
index 34f52ce4e61..f578b00f276 100644
--- a/tests/codegen-units/item-collection/unsizing.rs
+++ b/tests/codegen-units/item-collection/unsizing.rs
@@ -75,5 +75,7 @@ fn start(_: isize, _: *const *const u8) -> isize {
     //~ MONO_ITEM fn <u32 as Trait>::foo
     let _wrapper_sized = wrapper_sized as Wrapper<Trait>;
 
+    false.foo();
+
     0
 }
diff --git a/tests/ui-fulldeps/rustc_encodable_hygiene.rs b/tests/ui-fulldeps/rustc_encodable_hygiene.rs
index bec7930d462..36c684a131e 100644
--- a/tests/ui-fulldeps/rustc_encodable_hygiene.rs
+++ b/tests/ui-fulldeps/rustc_encodable_hygiene.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 
 #![feature(rustc_private)]
 
diff --git a/tests/ui/anon-params/anon-params-deprecated.fixed b/tests/ui/anon-params/anon-params-deprecated.fixed
index c09e2077084..8ec1d41a709 100644
--- a/tests/ui/anon-params/anon-params-deprecated.fixed
+++ b/tests/ui/anon-params/anon-params-deprecated.fixed
@@ -5,6 +5,7 @@
 // edition:2015
 // run-rustfix
 
+#[allow(dead_code)]
 trait T {
     fn foo(_: i32); //~ WARNING anonymous parameters are deprecated
                  //~| WARNING this is accepted in the current edition
diff --git a/tests/ui/anon-params/anon-params-deprecated.rs b/tests/ui/anon-params/anon-params-deprecated.rs
index 6f7385da040..108ba60a02f 100644
--- a/tests/ui/anon-params/anon-params-deprecated.rs
+++ b/tests/ui/anon-params/anon-params-deprecated.rs
@@ -5,6 +5,7 @@
 // edition:2015
 // run-rustfix
 
+#[allow(dead_code)]
 trait T {
     fn foo(i32); //~ WARNING anonymous parameters are deprecated
                  //~| WARNING this is accepted in the current edition
diff --git a/tests/ui/anon-params/anon-params-deprecated.stderr b/tests/ui/anon-params/anon-params-deprecated.stderr
index 691e2c79512..541cb004b5b 100644
--- a/tests/ui/anon-params/anon-params-deprecated.stderr
+++ b/tests/ui/anon-params/anon-params-deprecated.stderr
@@ -1,5 +1,5 @@
 warning: anonymous parameters are deprecated and will be removed in the next edition
-  --> $DIR/anon-params-deprecated.rs:9:12
+  --> $DIR/anon-params-deprecated.rs:10:12
    |
 LL |     fn foo(i32);
    |            ^^^ help: try naming the parameter or explicitly ignoring it: `_: i32`
@@ -13,7 +13,7 @@ LL | #![warn(anonymous_parameters)]
    |         ^^^^^^^^^^^^^^^^^^^^
 
 warning: anonymous parameters are deprecated and will be removed in the next edition
-  --> $DIR/anon-params-deprecated.rs:12:30
+  --> $DIR/anon-params-deprecated.rs:13:30
    |
 LL |     fn bar_with_default_impl(String, String) {}
    |                              ^^^^^^ help: try naming the parameter or explicitly ignoring it: `_: String`
@@ -22,7 +22,7 @@ LL |     fn bar_with_default_impl(String, String) {}
    = note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686>
 
 warning: anonymous parameters are deprecated and will be removed in the next edition
-  --> $DIR/anon-params-deprecated.rs:12:38
+  --> $DIR/anon-params-deprecated.rs:13:38
    |
 LL |     fn bar_with_default_impl(String, String) {}
    |                                      ^^^^^^ help: try naming the parameter or explicitly ignoring it: `_: String`
diff --git a/tests/ui/associated-consts/associated-const-outer-ty-refs.rs b/tests/ui/associated-consts/associated-const-outer-ty-refs.rs
index f32ca0cccfc..d5e9a2bde00 100644
--- a/tests/ui/associated-consts/associated-const-outer-ty-refs.rs
+++ b/tests/ui/associated-consts/associated-const-outer-ty-refs.rs
@@ -1,4 +1,5 @@
-// run-pass
+// check-pass
+
 trait Lattice {
     const BOTTOM: Self;
 }
diff --git a/tests/ui/associated-consts/associated-const-type-parameters.rs b/tests/ui/associated-consts/associated-const-type-parameters.rs
index b62d47458be..a233b09ff89 100644
--- a/tests/ui/associated-consts/associated-const-type-parameters.rs
+++ b/tests/ui/associated-consts/associated-const-type-parameters.rs
@@ -27,7 +27,7 @@ fn sub<A: Foo, B: Foo>() -> i32 {
     A::X - B::X
 }
 
-trait Bar: Foo {
+trait Bar: Foo { //~ WARN trait `Bar` is never used
     const Y: i32 = Self::X;
 }
 
diff --git a/tests/ui/associated-consts/associated-const-type-parameters.stderr b/tests/ui/associated-consts/associated-const-type-parameters.stderr
new file mode 100644
index 00000000000..6ee2a5de1b6
--- /dev/null
+++ b/tests/ui/associated-consts/associated-const-type-parameters.stderr
@@ -0,0 +1,10 @@
+warning: trait `Bar` is never used
+  --> $DIR/associated-const-type-parameters.rs:30:7
+   |
+LL | trait Bar: Foo {
+   |       ^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/associated-type-bounds/dyn-impl-trait-type.rs b/tests/ui/associated-type-bounds/dyn-impl-trait-type.rs
index a3f4717791a..079c44b3a59 100644
--- a/tests/ui/associated-type-bounds/dyn-impl-trait-type.rs
+++ b/tests/ui/associated-type-bounds/dyn-impl-trait-type.rs
@@ -5,7 +5,7 @@
 use std::ops::Add;
 
 trait Tr1 { type As1; fn mk(&self) -> Self::As1; }
-trait Tr2<'a> { fn tr2(self) -> &'a Self; }
+trait Tr2<'a> { fn tr2(self) -> &'a Self; } //~ WARN method `tr2` is never used
 
 fn assert_copy<T: Copy>(x: T) { let _x = x; let _x = x; }
 fn assert_static<T: 'static>(_: T) {}
diff --git a/tests/ui/associated-type-bounds/dyn-impl-trait-type.stderr b/tests/ui/associated-type-bounds/dyn-impl-trait-type.stderr
new file mode 100644
index 00000000000..2e26a434f5d
--- /dev/null
+++ b/tests/ui/associated-type-bounds/dyn-impl-trait-type.stderr
@@ -0,0 +1,12 @@
+warning: method `tr2` is never used
+  --> $DIR/dyn-impl-trait-type.rs:8:20
+   |
+LL | trait Tr2<'a> { fn tr2(self) -> &'a Self; }
+   |       ---          ^^^
+   |       |
+   |       method in this trait
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/associated-type-bounds/dyn-rpit-and-let.rs b/tests/ui/associated-type-bounds/dyn-rpit-and-let.rs
index 52199124ea3..49e5e72f225 100644
--- a/tests/ui/associated-type-bounds/dyn-rpit-and-let.rs
+++ b/tests/ui/associated-type-bounds/dyn-rpit-and-let.rs
@@ -7,7 +7,7 @@
 use std::ops::Add;
 
 trait Tr1 { type As1; fn mk(&self) -> Self::As1; }
-trait Tr2<'a> { fn tr2(self) -> &'a Self; }
+trait Tr2<'a> { fn tr2(self) -> &'a Self; } //~ WARN method `tr2` is never used
 
 fn assert_copy<T: Copy>(x: T) { let _x = x; let _x = x; }
 fn assert_static<T: 'static>(_: T) {}
diff --git a/tests/ui/associated-type-bounds/dyn-rpit-and-let.stderr b/tests/ui/associated-type-bounds/dyn-rpit-and-let.stderr
new file mode 100644
index 00000000000..9eddbe46284
--- /dev/null
+++ b/tests/ui/associated-type-bounds/dyn-rpit-and-let.stderr
@@ -0,0 +1,12 @@
+warning: method `tr2` is never used
+  --> $DIR/dyn-rpit-and-let.rs:10:20
+   |
+LL | trait Tr2<'a> { fn tr2(self) -> &'a Self; }
+   |       ---          ^^^
+   |       |
+   |       method in this trait
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/associated-type-bounds/rpit.rs b/tests/ui/associated-type-bounds/rpit.rs
index 59c7733fbe4..557e63b5f71 100644
--- a/tests/ui/associated-type-bounds/rpit.rs
+++ b/tests/ui/associated-type-bounds/rpit.rs
@@ -5,7 +5,7 @@
 use std::ops::Add;
 
 trait Tr1 { type As1; fn mk(self) -> Self::As1; }
-trait Tr2<'a> { fn tr2(self) -> &'a Self; }
+trait Tr2<'a> { fn tr2(self) -> &'a Self; } //~ WARN method `tr2` is never used
 
 fn assert_copy<T: Copy>(x: T) { let _x = x; let _x = x; }
 fn assert_static<T: 'static>(_: T) {}
diff --git a/tests/ui/associated-type-bounds/rpit.stderr b/tests/ui/associated-type-bounds/rpit.stderr
new file mode 100644
index 00000000000..76bd75bd2ca
--- /dev/null
+++ b/tests/ui/associated-type-bounds/rpit.stderr
@@ -0,0 +1,12 @@
+warning: method `tr2` is never used
+  --> $DIR/rpit.rs:8:20
+   |
+LL | trait Tr2<'a> { fn tr2(self) -> &'a Self; }
+   |       ---          ^^^
+   |       |
+   |       method in this trait
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.fixed b/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.fixed
index b9f26a40219..128c7dfdda2 100644
--- a/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.fixed
+++ b/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.fixed
@@ -1,4 +1,5 @@
 // run-rustfix
+#![allow(dead_code)]
 trait O {
     type M;
 }
diff --git a/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.rs b/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.rs
index abff6af73e2..6b6478419b4 100644
--- a/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.rs
+++ b/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.rs
@@ -1,4 +1,5 @@
 // run-rustfix
+#![allow(dead_code)]
 trait O {
     type M;
 }
diff --git a/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.stderr b/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.stderr
index 7ca9aff4322..21bc37bb3ea 100644
--- a/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.stderr
+++ b/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.stderr
@@ -1,5 +1,5 @@
 error[E0308]: mismatched types
-  --> $DIR/suggest-contraining-assoc-type-because-of-assoc-const.rs:12:21
+  --> $DIR/suggest-contraining-assoc-type-because-of-assoc-const.rs:13:21
    |
 LL |     const N: C::M = 4u8;
    |                     ^^^ expected associated type, found `u8`
diff --git a/tests/ui/associated-type-bounds/trait-alias-impl-trait.rs b/tests/ui/associated-type-bounds/trait-alias-impl-trait.rs
index 93a44c01ce0..60088e443f3 100644
--- a/tests/ui/associated-type-bounds/trait-alias-impl-trait.rs
+++ b/tests/ui/associated-type-bounds/trait-alias-impl-trait.rs
@@ -1,5 +1,6 @@
 // run-pass
 
+#![allow(dead_code)]
 #![feature(associated_type_bounds)]
 #![feature(type_alias_impl_trait)]
 
diff --git a/tests/ui/associated-types/associated-types-for-unimpl-trait.fixed b/tests/ui/associated-types/associated-types-for-unimpl-trait.fixed
index 80bbef17469..adfba994f32 100644
--- a/tests/ui/associated-types/associated-types-for-unimpl-trait.fixed
+++ b/tests/ui/associated-types/associated-types-for-unimpl-trait.fixed
@@ -1,4 +1,5 @@
 // run-rustfix
+#![allow(dead_code)]
 #![allow(unused_variables)]
 
 trait Get {
diff --git a/tests/ui/associated-types/associated-types-for-unimpl-trait.rs b/tests/ui/associated-types/associated-types-for-unimpl-trait.rs
index 0f6cea8e69f..50478171d86 100644
--- a/tests/ui/associated-types/associated-types-for-unimpl-trait.rs
+++ b/tests/ui/associated-types/associated-types-for-unimpl-trait.rs
@@ -1,4 +1,5 @@
 // run-rustfix
+#![allow(dead_code)]
 #![allow(unused_variables)]
 
 trait Get {
diff --git a/tests/ui/associated-types/associated-types-for-unimpl-trait.stderr b/tests/ui/associated-types/associated-types-for-unimpl-trait.stderr
index 17941b6bf1e..27014fa53d8 100644
--- a/tests/ui/associated-types/associated-types-for-unimpl-trait.stderr
+++ b/tests/ui/associated-types/associated-types-for-unimpl-trait.stderr
@@ -1,5 +1,5 @@
 error[E0277]: the trait bound `Self: Get` is not satisfied
-  --> $DIR/associated-types-for-unimpl-trait.rs:10:40
+  --> $DIR/associated-types-for-unimpl-trait.rs:11:40
    |
 LL |     fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) {}
    |                                        ^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `Self`
diff --git a/tests/ui/associated-types/associated-types-in-bound-type-arg.rs b/tests/ui/associated-types/associated-types-in-bound-type-arg.rs
index 88bb5fe0afe..05e66a168d9 100644
--- a/tests/ui/associated-types/associated-types-in-bound-type-arg.rs
+++ b/tests/ui/associated-types/associated-types-in-bound-type-arg.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 // Test the case where we resolve `C::Result` and the trait bound
 // itself includes a `Self::Item` shorthand.
 //
diff --git a/tests/ui/associated-types/associated-types-issue-20220.rs b/tests/ui/associated-types/associated-types-issue-20220.rs
index 19fa7a6085a..89efce19834 100644
--- a/tests/ui/associated-types/associated-types-issue-20220.rs
+++ b/tests/ui/associated-types/associated-types-issue-20220.rs
@@ -4,7 +4,7 @@
 
 use std::vec;
 
-trait IntoIteratorX {
+trait IntoIteratorX { //~ WARN trait `IntoIteratorX` is never used
     type Item;
     type IntoIter: Iterator<Item=Self::Item>;
 
diff --git a/tests/ui/associated-types/associated-types-issue-20220.stderr b/tests/ui/associated-types/associated-types-issue-20220.stderr
new file mode 100644
index 00000000000..c682f46e140
--- /dev/null
+++ b/tests/ui/associated-types/associated-types-issue-20220.stderr
@@ -0,0 +1,10 @@
+warning: trait `IntoIteratorX` is never used
+  --> $DIR/associated-types-issue-20220.rs:7:7
+   |
+LL | trait IntoIteratorX {
+   |       ^^^^^^^^^^^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/associated-types/associated-types-issue-20371.rs b/tests/ui/associated-types/associated-types-issue-20371.rs
index ae8a8767d27..cbec83d45b2 100644
--- a/tests/ui/associated-types/associated-types-issue-20371.rs
+++ b/tests/ui/associated-types/associated-types-issue-20371.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 // Test that we are able to have an impl that defines an associated type
 // before the actual trait.
 
diff --git a/tests/ui/associated-types/associated-types-nested-projections.rs b/tests/ui/associated-types/associated-types-nested-projections.rs
index 76ba7496250..440f35c8bde 100644
--- a/tests/ui/associated-types/associated-types-nested-projections.rs
+++ b/tests/ui/associated-types/associated-types-nested-projections.rs
@@ -13,7 +13,7 @@ impl<'a> Bound for &'a i32 {}
 trait IntoIterator {
     type Iter: Iterator;
 
-    fn into_iter(self) -> Self::Iter;
+    fn into_iter(self) -> Self::Iter; //~ WARN method `into_iter` is never used
 }
 
 impl<'a, T> IntoIterator for &'a [T; 3] {
diff --git a/tests/ui/associated-types/associated-types-nested-projections.stderr b/tests/ui/associated-types/associated-types-nested-projections.stderr
new file mode 100644
index 00000000000..97d5a758573
--- /dev/null
+++ b/tests/ui/associated-types/associated-types-nested-projections.stderr
@@ -0,0 +1,13 @@
+warning: method `into_iter` is never used
+  --> $DIR/associated-types-nested-projections.rs:16:8
+   |
+LL | trait IntoIterator {
+   |       ------------ method in this trait
+...
+LL |     fn into_iter(self) -> Self::Iter;
+   |        ^^^^^^^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/associated-types/associated-types-normalize-in-bounds-ufcs.rs b/tests/ui/associated-types/associated-types-normalize-in-bounds-ufcs.rs
index e09aa3663c6..6612598b1b8 100644
--- a/tests/ui/associated-types/associated-types-normalize-in-bounds-ufcs.rs
+++ b/tests/ui/associated-types/associated-types-normalize-in-bounds-ufcs.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 #![allow(unused_variables)]
 // Test that we normalize associated types that appear in bounds; if
 // we didn't, the call to `self.split2()` fails to type check.
diff --git a/tests/ui/associated-types/associated-types-normalize-in-bounds.rs b/tests/ui/associated-types/associated-types-normalize-in-bounds.rs
index dcfae0f37e1..df0a82ee7ce 100644
--- a/tests/ui/associated-types/associated-types-normalize-in-bounds.rs
+++ b/tests/ui/associated-types/associated-types-normalize-in-bounds.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 #![allow(unused_variables)]
 // Test that we normalize associated types that appear in bounds; if
 // we didn't, the call to `self.split2()` fails to type check.
diff --git a/tests/ui/associated-types/associated-types-projection-bound-in-supertraits.rs b/tests/ui/associated-types/associated-types-projection-bound-in-supertraits.rs
index 107e6b4ce0c..e99d0112ec4 100644
--- a/tests/ui/associated-types/associated-types-projection-bound-in-supertraits.rs
+++ b/tests/ui/associated-types/associated-types-projection-bound-in-supertraits.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 #![allow(unused_variables)]
 // Test that we correctly handle projection bounds appearing in the
 // supertrait list (and in conjunction with overloaded operators). In
diff --git a/tests/ui/associated-types/associated-types-projection-from-known-type-in-impl.rs b/tests/ui/associated-types/associated-types-projection-from-known-type-in-impl.rs
index a59c327be21..e172c6e5611 100644
--- a/tests/ui/associated-types/associated-types-projection-from-known-type-in-impl.rs
+++ b/tests/ui/associated-types/associated-types-projection-from-known-type-in-impl.rs
@@ -6,7 +6,7 @@ trait Int
 {
     type T;
 
-    fn dummy(&self) { }
+    fn dummy(&self) { } //~ WARN method `dummy` is never used
 }
 
 trait NonZero
diff --git a/tests/ui/associated-types/associated-types-projection-from-known-type-in-impl.stderr b/tests/ui/associated-types/associated-types-projection-from-known-type-in-impl.stderr
new file mode 100644
index 00000000000..c26ed79a026
--- /dev/null
+++ b/tests/ui/associated-types/associated-types-projection-from-known-type-in-impl.stderr
@@ -0,0 +1,13 @@
+warning: method `dummy` is never used
+  --> $DIR/associated-types-projection-from-known-type-in-impl.rs:9:8
+   |
+LL | trait Int
+   |       --- method in this trait
+...
+LL |     fn dummy(&self) { }
+   |        ^^^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/associated-types/associated-types-projection-to-unrelated-trait-in-method-without-default.fixed b/tests/ui/associated-types/associated-types-projection-to-unrelated-trait-in-method-without-default.fixed
index 9bc308465eb..01f49d52ee2 100644
--- a/tests/ui/associated-types/associated-types-projection-to-unrelated-trait-in-method-without-default.fixed
+++ b/tests/ui/associated-types/associated-types-projection-to-unrelated-trait-in-method-without-default.fixed
@@ -2,6 +2,7 @@
 // Check that we get an error when you use `<Self as Get>::Value` in
 // the trait definition even if there is no default method.
 
+#![allow(dead_code)]
 trait Get {
     type Value;
 }
diff --git a/tests/ui/associated-types/associated-types-projection-to-unrelated-trait-in-method-without-default.rs b/tests/ui/associated-types/associated-types-projection-to-unrelated-trait-in-method-without-default.rs
index 549fc8fc618..7068a754a12 100644
--- a/tests/ui/associated-types/associated-types-projection-to-unrelated-trait-in-method-without-default.rs
+++ b/tests/ui/associated-types/associated-types-projection-to-unrelated-trait-in-method-without-default.rs
@@ -2,6 +2,7 @@
 // Check that we get an error when you use `<Self as Get>::Value` in
 // the trait definition even if there is no default method.
 
+#![allow(dead_code)]
 trait Get {
     type Value;
 }
diff --git a/tests/ui/associated-types/associated-types-projection-to-unrelated-trait-in-method-without-default.stderr b/tests/ui/associated-types/associated-types-projection-to-unrelated-trait-in-method-without-default.stderr
index 64a88525af8..79200dc3acc 100644
--- a/tests/ui/associated-types/associated-types-projection-to-unrelated-trait-in-method-without-default.stderr
+++ b/tests/ui/associated-types/associated-types-projection-to-unrelated-trait-in-method-without-default.stderr
@@ -1,5 +1,5 @@
 error[E0277]: the trait bound `Self: Get` is not satisfied
-  --> $DIR/associated-types-projection-to-unrelated-trait-in-method-without-default.rs:10:40
+  --> $DIR/associated-types-projection-to-unrelated-trait-in-method-without-default.rs:11:40
    |
 LL |     fn okay<U:Get>(&self, foo: U, bar: <Self as Get>::Value);
    |                                        ^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `Self`
diff --git a/tests/ui/associated-types/associated-types-projection-to-unrelated-trait.rs b/tests/ui/associated-types/associated-types-projection-to-unrelated-trait.rs
index 3b8c8c019e5..a2d6c9ff5a4 100644
--- a/tests/ui/associated-types/associated-types-projection-to-unrelated-trait.rs
+++ b/tests/ui/associated-types/associated-types-projection-to-unrelated-trait.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 // Check that we do not get an error when you use `<Self as Get>::Value` in
 // the trait definition if there is no default method and for every impl,
 // `Self` does implement `Get`.
diff --git a/tests/ui/associated-types/associated-types-qualified-path-with-trait-with-type-parameters.rs b/tests/ui/associated-types/associated-types-qualified-path-with-trait-with-type-parameters.rs
index 3c830d37060..1768fd1687b 100644
--- a/tests/ui/associated-types/associated-types-qualified-path-with-trait-with-type-parameters.rs
+++ b/tests/ui/associated-types/associated-types-qualified-path-with-trait-with-type-parameters.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 // pretty-expanded FIXME #23616
 
 trait Foo<T> {
diff --git a/tests/ui/associated-types/associated-types-resolve-lifetime.rs b/tests/ui/associated-types/associated-types-resolve-lifetime.rs
index 52f2324d72a..563d0c11822 100644
--- a/tests/ui/associated-types/associated-types-resolve-lifetime.rs
+++ b/tests/ui/associated-types/associated-types-resolve-lifetime.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 // pretty-expanded FIXME #23616
 
 trait Get<T> {
diff --git a/tests/ui/associated-types/impl-wf-cycle-5.fixed b/tests/ui/associated-types/impl-wf-cycle-5.fixed
index bff6ca90975..2b8f1e0d865 100644
--- a/tests/ui/associated-types/impl-wf-cycle-5.fixed
+++ b/tests/ui/associated-types/impl-wf-cycle-5.fixed
@@ -1,9 +1,11 @@
 // run-rustfix
 
+#[allow(dead_code)]
 trait Baz {}
 impl Baz for () {}
 impl<T> Baz for (T,) {}
 
+#[allow(dead_code)]
 trait Fiz {}
 impl Fiz for bool {}
 
diff --git a/tests/ui/associated-types/impl-wf-cycle-5.rs b/tests/ui/associated-types/impl-wf-cycle-5.rs
index a822e1fb008..e6de292ca5c 100644
--- a/tests/ui/associated-types/impl-wf-cycle-5.rs
+++ b/tests/ui/associated-types/impl-wf-cycle-5.rs
@@ -1,9 +1,11 @@
 // run-rustfix
 
+#[allow(dead_code)]
 trait Baz {}
 impl Baz for () {}
 impl<T> Baz for (T,) {}
 
+#[allow(dead_code)]
 trait Fiz {}
 impl Fiz for bool {}
 
diff --git a/tests/ui/associated-types/impl-wf-cycle-5.stderr b/tests/ui/associated-types/impl-wf-cycle-5.stderr
index 284a50bb9a3..61edf18b43d 100644
--- a/tests/ui/associated-types/impl-wf-cycle-5.stderr
+++ b/tests/ui/associated-types/impl-wf-cycle-5.stderr
@@ -1,5 +1,5 @@
 error[E0275]: overflow evaluating the requirement `<(T,) as Grault>::A == _`
-  --> $DIR/impl-wf-cycle-5.rs:20:1
+  --> $DIR/impl-wf-cycle-5.rs:22:1
    |
 LL | / impl<T> Grault for (T,)
 LL | |
@@ -12,7 +12,7 @@ LL |       type A = ();
    |       ------ associated type `<(T,) as Grault>::A` is specified here
    |
 note: required for `(T,)` to implement `Grault`
-  --> $DIR/impl-wf-cycle-5.rs:20:9
+  --> $DIR/impl-wf-cycle-5.rs:22:9
    |
 LL | impl<T> Grault for (T,)
    |         ^^^^^^     ^^^^
diff --git a/tests/ui/associated-types/impl-wf-cycle-6.fixed b/tests/ui/associated-types/impl-wf-cycle-6.fixed
index 73ed64f7ce3..5ddf1faefe0 100644
--- a/tests/ui/associated-types/impl-wf-cycle-6.fixed
+++ b/tests/ui/associated-types/impl-wf-cycle-6.fixed
@@ -1,9 +1,11 @@
 // run-rustfix
 
+#[allow(dead_code)]
 trait Baz {}
 impl Baz for () {}
 impl<T> Baz for (T,) {}
 
+#[allow(dead_code)]
 trait Fiz {}
 impl Fiz for bool {}
 
diff --git a/tests/ui/associated-types/impl-wf-cycle-6.rs b/tests/ui/associated-types/impl-wf-cycle-6.rs
index 20d635cac5d..28f6deb77ce 100644
--- a/tests/ui/associated-types/impl-wf-cycle-6.rs
+++ b/tests/ui/associated-types/impl-wf-cycle-6.rs
@@ -1,9 +1,11 @@
 // run-rustfix
 
+#[allow(dead_code)]
 trait Baz {}
 impl Baz for () {}
 impl<T> Baz for (T,) {}
 
+#[allow(dead_code)]
 trait Fiz {}
 impl Fiz for bool {}
 
diff --git a/tests/ui/associated-types/impl-wf-cycle-6.stderr b/tests/ui/associated-types/impl-wf-cycle-6.stderr
index c9b5d8060be..1c749503318 100644
--- a/tests/ui/associated-types/impl-wf-cycle-6.stderr
+++ b/tests/ui/associated-types/impl-wf-cycle-6.stderr
@@ -1,5 +1,5 @@
 error[E0275]: overflow evaluating the requirement `<(T,) as Grault>::A == _`
-  --> $DIR/impl-wf-cycle-6.rs:20:1
+  --> $DIR/impl-wf-cycle-6.rs:22:1
    |
 LL | / impl<T: Grault> Grault for (T,)
 LL | |
@@ -11,7 +11,7 @@ LL |       type A = ();
    |       ------ associated type `<(T,) as Grault>::A` is specified here
    |
 note: required for `(T,)` to implement `Grault`
-  --> $DIR/impl-wf-cycle-6.rs:20:17
+  --> $DIR/impl-wf-cycle-6.rs:22:17
    |
 LL | impl<T: Grault> Grault for (T,)
    |                 ^^^^^^     ^^^^
diff --git a/tests/ui/auto-traits/auto-trait-validation.fixed b/tests/ui/auto-traits/auto-trait-validation.fixed
index da878ac6222..e37fed9faab 100644
--- a/tests/ui/auto-traits/auto-trait-validation.fixed
+++ b/tests/ui/auto-traits/auto-trait-validation.fixed
@@ -1,4 +1,5 @@
 #![feature(auto_traits)]
+#![allow(dead_code)]
 
 // run-rustfix
 
diff --git a/tests/ui/auto-traits/auto-trait-validation.rs b/tests/ui/auto-traits/auto-trait-validation.rs
index d43055e270b..e209aa13220 100644
--- a/tests/ui/auto-traits/auto-trait-validation.rs
+++ b/tests/ui/auto-traits/auto-trait-validation.rs
@@ -1,4 +1,5 @@
 #![feature(auto_traits)]
+#![allow(dead_code)]
 
 // run-rustfix
 
diff --git a/tests/ui/auto-traits/auto-trait-validation.stderr b/tests/ui/auto-traits/auto-trait-validation.stderr
index 89b63d23d4c..a6e5ac54869 100644
--- a/tests/ui/auto-traits/auto-trait-validation.stderr
+++ b/tests/ui/auto-traits/auto-trait-validation.stderr
@@ -1,5 +1,5 @@
 error[E0567]: auto traits cannot have generic parameters
-  --> $DIR/auto-trait-validation.rs:5:19
+  --> $DIR/auto-trait-validation.rs:6:19
    |
 LL | auto trait Generic<T> {}
    |            -------^^^ help: remove the parameters
@@ -7,7 +7,7 @@ LL | auto trait Generic<T> {}
    |            auto trait cannot have generic parameters
 
 error[E0568]: auto traits cannot have super traits or lifetime bounds
-  --> $DIR/auto-trait-validation.rs:7:17
+  --> $DIR/auto-trait-validation.rs:8:17
    |
 LL | auto trait Bound : Copy {}
    |            -----^^^^^^^ help: remove the super traits or lifetime bounds
@@ -15,7 +15,7 @@ LL | auto trait Bound : Copy {}
    |            auto traits cannot have super traits or lifetime bounds
 
 error[E0568]: auto traits cannot have super traits or lifetime bounds
-  --> $DIR/auto-trait-validation.rs:9:25
+  --> $DIR/auto-trait-validation.rs:10:25
    |
 LL | auto trait LifetimeBound : 'static {}
    |            -------------^^^^^^^^^^ help: remove the super traits or lifetime bounds
@@ -23,7 +23,7 @@ LL | auto trait LifetimeBound : 'static {}
    |            auto traits cannot have super traits or lifetime bounds
 
 error[E0380]: auto traits cannot have associated items
-  --> $DIR/auto-trait-validation.rs:11:25
+  --> $DIR/auto-trait-validation.rs:12:25
    |
 LL | auto trait MyTrait { fn foo() {} }
    |            -------   ---^^^-----
diff --git a/tests/ui/auto-traits/auto-traits.rs b/tests/ui/auto-traits/auto-traits.rs
index 6d8e1a52ec1..1e0fbcc1fdf 100644
--- a/tests/ui/auto-traits/auto-traits.rs
+++ b/tests/ui/auto-traits/auto-traits.rs
@@ -19,8 +19,8 @@ fn take_auto_unsafe<T: AutoUnsafe>(_: T) {}
 
 fn main() {
     // Parse inside functions.
-    auto trait AutoInner {}
-    unsafe auto trait AutoUnsafeInner {}
+    auto trait AutoInner {} //~ WARN trait `AutoInner` is never used
+    unsafe auto trait AutoUnsafeInner {} //~ WARN trait `AutoUnsafeInner` is never used
 
     take_auto(0);
     take_auto(AutoBool(true));
diff --git a/tests/ui/auto-traits/auto-traits.stderr b/tests/ui/auto-traits/auto-traits.stderr
new file mode 100644
index 00000000000..34be8d3f67b
--- /dev/null
+++ b/tests/ui/auto-traits/auto-traits.stderr
@@ -0,0 +1,16 @@
+warning: trait `AutoInner` is never used
+  --> $DIR/auto-traits.rs:22:16
+   |
+LL |     auto trait AutoInner {}
+   |                ^^^^^^^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: trait `AutoUnsafeInner` is never used
+  --> $DIR/auto-traits.rs:23:23
+   |
+LL |     unsafe auto trait AutoUnsafeInner {}
+   |                       ^^^^^^^^^^^^^^^
+
+warning: 2 warnings emitted
+
diff --git a/tests/ui/builtin-superkinds/builtin-superkinds-in-metadata2.rs b/tests/ui/builtin-superkinds/builtin-superkinds-in-metadata2.rs
index 2edc52c6f55..7e8820cb2c6 100644
--- a/tests/ui/builtin-superkinds/builtin-superkinds-in-metadata2.rs
+++ b/tests/ui/builtin-superkinds/builtin-superkinds-in-metadata2.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 
 #![allow(unused_imports)]
 
diff --git a/tests/ui/builtin-superkinds/builtin-superkinds-simple2.rs b/tests/ui/builtin-superkinds/builtin-superkinds-simple2.rs
index 8d247715784..50914b1de53 100644
--- a/tests/ui/builtin-superkinds/builtin-superkinds-simple2.rs
+++ b/tests/ui/builtin-superkinds/builtin-superkinds-simple2.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 // Simple test case of implementing a trait with super-builtin-kinds.
 
 // pretty-expanded FIXME #23616
diff --git a/tests/ui/builtin-superkinds/builtin-superkinds-typaram.rs b/tests/ui/builtin-superkinds/builtin-superkinds-typaram.rs
index f999dfff786..0577acc572a 100644
--- a/tests/ui/builtin-superkinds/builtin-superkinds-typaram.rs
+++ b/tests/ui/builtin-superkinds/builtin-superkinds-typaram.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 // Tests correct implementation of traits with super-builtin-kinds
 // using a bounded type parameter.
 
diff --git a/tests/ui/cast/cast-rfc0401-vtable-kinds.rs b/tests/ui/cast/cast-rfc0401-vtable-kinds.rs
index 249481467e6..be6a6bb8b17 100644
--- a/tests/ui/cast/cast-rfc0401-vtable-kinds.rs
+++ b/tests/ui/cast/cast-rfc0401-vtable-kinds.rs
@@ -8,7 +8,7 @@ trait Foo<T> {
     fn foo(&self, _: T) -> u32 { 42 }
 }
 
-trait Bar {
+trait Bar { //~ WARN trait `Bar` is never used
     fn bar(&self) { println!("Bar!"); }
 }
 
diff --git a/tests/ui/cast/cast-rfc0401-vtable-kinds.stderr b/tests/ui/cast/cast-rfc0401-vtable-kinds.stderr
new file mode 100644
index 00000000000..952687e98d0
--- /dev/null
+++ b/tests/ui/cast/cast-rfc0401-vtable-kinds.stderr
@@ -0,0 +1,10 @@
+warning: trait `Bar` is never used
+  --> $DIR/cast-rfc0401-vtable-kinds.rs:11:7
+   |
+LL | trait Bar {
+   |       ^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/cast/fat-ptr-cast-rpass.rs b/tests/ui/cast/fat-ptr-cast-rpass.rs
index f5747eb8b96..c79468caddd 100644
--- a/tests/ui/cast/fat-ptr-cast-rpass.rs
+++ b/tests/ui/cast/fat-ptr-cast-rpass.rs
@@ -3,7 +3,7 @@
 #![feature(ptr_metadata)]
 
 trait Foo {
-    fn foo(&self) {}
+    fn foo(&self) {} //~ WARN method `foo` is never used
 }
 
 struct Bar;
diff --git a/tests/ui/cast/fat-ptr-cast-rpass.stderr b/tests/ui/cast/fat-ptr-cast-rpass.stderr
new file mode 100644
index 00000000000..d01688e0cc3
--- /dev/null
+++ b/tests/ui/cast/fat-ptr-cast-rpass.stderr
@@ -0,0 +1,12 @@
+warning: method `foo` is never used
+  --> $DIR/fat-ptr-cast-rpass.rs:6:8
+   |
+LL | trait Foo {
+   |       --- method in this trait
+LL |     fn foo(&self) {}
+   |        ^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/coercion/issue-14589.rs b/tests/ui/coercion/issue-14589.rs
index f92385f8d72..6f95b30be06 100644
--- a/tests/ui/coercion/issue-14589.rs
+++ b/tests/ui/coercion/issue-14589.rs
@@ -19,6 +19,6 @@ impl<T> Test<T> {
     fn send(&self, _: T) {}
 }
 
-trait Foo { fn dummy(&self) { }}
+trait Foo { fn dummy(&self) { }} //~ WARN method `dummy` is never used
 struct Output(#[allow(dead_code)] isize);
 impl Foo for Output {}
diff --git a/tests/ui/coercion/issue-14589.stderr b/tests/ui/coercion/issue-14589.stderr
new file mode 100644
index 00000000000..37b7fce7462
--- /dev/null
+++ b/tests/ui/coercion/issue-14589.stderr
@@ -0,0 +1,12 @@
+warning: method `dummy` is never used
+  --> $DIR/issue-14589.rs:22:16
+   |
+LL | trait Foo { fn dummy(&self) { }}
+   |       ---      ^^^^^
+   |       |
+   |       method in this trait
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/coherence/coherence-multidispatch-tuple.rs b/tests/ui/coherence/coherence-multidispatch-tuple.rs
index fa1d4bbb496..b04b2a296b5 100644
--- a/tests/ui/coherence/coherence-multidispatch-tuple.rs
+++ b/tests/ui/coherence/coherence-multidispatch-tuple.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 #![allow(unused_imports)]
 // pretty-expanded FIXME #23616
 
diff --git a/tests/ui/const-generics/associated-type-bound.rs b/tests/ui/const-generics/associated-type-bound.rs
index 3044736b47e..0a57352c10d 100644
--- a/tests/ui/const-generics/associated-type-bound.rs
+++ b/tests/ui/const-generics/associated-type-bound.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 trait Bar<const N: usize> {}
 
 trait Foo<const N: usize> {
diff --git a/tests/ui/const-generics/condition-in-trait-const-arg.rs b/tests/ui/const-generics/condition-in-trait-const-arg.rs
index 6f85237cf0a..74a663a53ec 100644
--- a/tests/ui/const-generics/condition-in-trait-const-arg.rs
+++ b/tests/ui/const-generics/condition-in-trait-const-arg.rs
@@ -1,5 +1,5 @@
 // Checks that `impl Trait<{anon_const}> for Type` evaluates successfully.
-// run-pass
+// check-pass
 // revisions: full min
 
 #![cfg_attr(full, feature(generic_const_exprs))]
diff --git a/tests/ui/const-generics/dyn-supertraits.rs b/tests/ui/const-generics/dyn-supertraits.rs
index 3dee326a186..bb492452982 100644
--- a/tests/ui/const-generics/dyn-supertraits.rs
+++ b/tests/ui/const-generics/dyn-supertraits.rs
@@ -4,7 +4,7 @@ trait Foo<const N: usize> {
     fn myfun(&self) -> usize;
 }
 trait Bar<const N: usize> : Foo<N> {}
-trait Baz: Foo<3> {}
+trait Baz: Foo<3> {} //~ WARN trait `Baz` is never used
 
 struct FooType<const N: usize>;
 struct BarType<const N: usize>;
@@ -23,10 +23,10 @@ impl Foo<3> for BazType {
 impl Baz for BazType {}
 
 trait Foz {}
-trait Boz: Foo<3> + Foz {}
+trait Boz: Foo<3> + Foz {} //~ WARN trait `Boz` is never used
 trait Bok<const N: usize>: Foo<N> + Foz {}
 
-struct FozType;
+struct FozType; //~ WARN struct `FozType` is never constructed
 struct BozType;
 struct BokType<const N: usize>;
 
diff --git a/tests/ui/const-generics/dyn-supertraits.stderr b/tests/ui/const-generics/dyn-supertraits.stderr
new file mode 100644
index 00000000000..38b67ef4403
--- /dev/null
+++ b/tests/ui/const-generics/dyn-supertraits.stderr
@@ -0,0 +1,22 @@
+warning: trait `Baz` is never used
+  --> $DIR/dyn-supertraits.rs:7:7
+   |
+LL | trait Baz: Foo<3> {}
+   |       ^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: trait `Boz` is never used
+  --> $DIR/dyn-supertraits.rs:26:7
+   |
+LL | trait Boz: Foo<3> + Foz {}
+   |       ^^^
+
+warning: struct `FozType` is never constructed
+  --> $DIR/dyn-supertraits.rs:29:8
+   |
+LL | struct FozType;
+   |        ^^^^^^^
+
+warning: 3 warnings emitted
+
diff --git a/tests/ui/const-generics/issues/issue-69654-run-pass.rs b/tests/ui/const-generics/issues/issue-69654-run-pass.rs
index 63d7fde78ac..21d6270b1fa 100644
--- a/tests/ui/const-generics/issues/issue-69654-run-pass.rs
+++ b/tests/ui/const-generics/issues/issue-69654-run-pass.rs
@@ -1,5 +1,5 @@
 // run-pass
-trait Bar<T> {}
+trait Bar<T> {} //~ WARN trait `Bar` is never used
 impl<T> Bar<T> for [u8; 7] {}
 
 struct Foo<const N: usize> {}
diff --git a/tests/ui/const-generics/issues/issue-69654-run-pass.stderr b/tests/ui/const-generics/issues/issue-69654-run-pass.stderr
new file mode 100644
index 00000000000..7b3cd4f375f
--- /dev/null
+++ b/tests/ui/const-generics/issues/issue-69654-run-pass.stderr
@@ -0,0 +1,10 @@
+warning: trait `Bar` is never used
+  --> $DIR/issue-69654-run-pass.rs:2:7
+   |
+LL | trait Bar<T> {}
+   |       ^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/consts/const-block-item.rs b/tests/ui/consts/const-block-item.rs
index cf0d4441d4a..a04f4db263b 100644
--- a/tests/ui/consts/const-block-item.rs
+++ b/tests/ui/consts/const-block-item.rs
@@ -2,7 +2,7 @@
 #![allow(unused_imports)]
 
 mod foo {
-    pub trait Value {
+    pub trait Value { //~ WARN trait `Value` is never used
         fn value(&self) -> usize;
     }
 }
diff --git a/tests/ui/consts/const-block-item.stderr b/tests/ui/consts/const-block-item.stderr
new file mode 100644
index 00000000000..04658742b56
--- /dev/null
+++ b/tests/ui/consts/const-block-item.stderr
@@ -0,0 +1,10 @@
+warning: trait `Value` is never used
+  --> $DIR/const-block-item.rs:5:15
+   |
+LL |     pub trait Value {
+   |               ^^^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/consts/underscore_const_names.rs b/tests/ui/consts/underscore_const_names.rs
index d0e625bf199..e2ae5a9d53a 100644
--- a/tests/ui/consts/underscore_const_names.rs
+++ b/tests/ui/consts/underscore_const_names.rs
@@ -2,12 +2,12 @@
 
 #![deny(unused)]
 
-trait Trt {}
+pub trait Trt {}
 pub struct Str {}
 impl Trt for Str {}
 
 macro_rules! check_impl {
-    ($struct:ident,$trait:ident) => {
+    ($struct:ident, $trait:ident) => {
         const _ : () = {
             use std::marker::PhantomData;
             struct ImplementsTrait<T: $trait>(PhantomData<T>);
diff --git a/tests/ui/default-method-parsing.rs b/tests/ui/default-method-parsing.rs
index 9ffb8d94a59..5001d58f0a4 100644
--- a/tests/ui/default-method-parsing.rs
+++ b/tests/ui/default-method-parsing.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 // pretty-expanded FIXME #23616
 
 trait Foo {
diff --git a/tests/ui/delegation/target-expr-pass.rs b/tests/ui/delegation/target-expr-pass.rs
index 56068dfce01..4ccb81c292a 100644
--- a/tests/ui/delegation/target-expr-pass.rs
+++ b/tests/ui/delegation/target-expr-pass.rs
@@ -14,14 +14,14 @@ reuse to_reuse::foo {{
     x + self
 }}
 
-trait Trait {
+trait Trait { //~ WARN trait `Trait` is never used
     fn bar(&self, x: i32) -> i32 { x }
 }
 
-struct F;
+struct F; //~ WARN struct `F` is never constructed
 impl Trait for F {}
 
-struct S(F);
+struct S(F); //~ WARN struct `S` is never constructed
 impl Trait for S {
     reuse <F as Trait>::bar {
         #[allow(unused_imports)]
diff --git a/tests/ui/delegation/target-expr-pass.stderr b/tests/ui/delegation/target-expr-pass.stderr
index ea594f8a26a..dd1f3a14e0b 100644
--- a/tests/ui/delegation/target-expr-pass.stderr
+++ b/tests/ui/delegation/target-expr-pass.stderr
@@ -7,5 +7,25 @@ LL | #![feature(fn_delegation)]
    = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information
    = note: `#[warn(incomplete_features)]` on by default
 
-warning: 1 warning emitted
+warning: trait `Trait` is never used
+  --> $DIR/target-expr-pass.rs:17:7
+   |
+LL | trait Trait {
+   |       ^^^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: struct `F` is never constructed
+  --> $DIR/target-expr-pass.rs:21:8
+   |
+LL | struct F;
+   |        ^
+
+warning: struct `S` is never constructed
+  --> $DIR/target-expr-pass.rs:24:8
+   |
+LL | struct S(F);
+   |        ^
+
+warning: 4 warnings emitted
 
diff --git a/tests/ui/deriving/deriving-bounds.rs b/tests/ui/deriving/deriving-bounds.rs
index f0b921d0e7c..f3e7cf99437 100644
--- a/tests/ui/deriving/deriving-bounds.rs
+++ b/tests/ui/deriving/deriving-bounds.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 #[derive(Copy, Clone)]
 struct Test;
 
diff --git a/tests/ui/drop/drop-struct-as-object.rs b/tests/ui/drop/drop-struct-as-object.rs
index 377027a4fc5..1aa68777042 100644
--- a/tests/ui/drop/drop-struct-as-object.rs
+++ b/tests/ui/drop/drop-struct-as-object.rs
@@ -12,7 +12,7 @@ struct Cat {
 }
 
 trait Dummy {
-    fn get(&self) -> usize;
+    fn get(&self) -> usize; //~ WARN method `get` is never used
 }
 
 impl Dummy for Cat {
diff --git a/tests/ui/drop/drop-struct-as-object.stderr b/tests/ui/drop/drop-struct-as-object.stderr
new file mode 100644
index 00000000000..10527c968ed
--- /dev/null
+++ b/tests/ui/drop/drop-struct-as-object.stderr
@@ -0,0 +1,12 @@
+warning: method `get` is never used
+  --> $DIR/drop-struct-as-object.rs:15:8
+   |
+LL | trait Dummy {
+   |       ----- method in this trait
+LL |     fn get(&self) -> usize;
+   |        ^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/dynamically-sized-types/dst-coercions.rs b/tests/ui/dynamically-sized-types/dst-coercions.rs
index 66688e93fb8..1efdf1de0e6 100644
--- a/tests/ui/dynamically-sized-types/dst-coercions.rs
+++ b/tests/ui/dynamically-sized-types/dst-coercions.rs
@@ -5,7 +5,7 @@
 // pretty-expanded FIXME #23616
 
 struct S;
-trait T { fn dummy(&self) { } }
+trait T { fn dummy(&self) { } } //~ WARN method `dummy` is never used
 impl T for S {}
 
 pub fn main() {
diff --git a/tests/ui/dynamically-sized-types/dst-coercions.stderr b/tests/ui/dynamically-sized-types/dst-coercions.stderr
new file mode 100644
index 00000000000..e4721ce50a0
--- /dev/null
+++ b/tests/ui/dynamically-sized-types/dst-coercions.stderr
@@ -0,0 +1,12 @@
+warning: method `dummy` is never used
+  --> $DIR/dst-coercions.rs:8:14
+   |
+LL | trait T { fn dummy(&self) { } }
+   |       -      ^^^^^
+   |       |
+   |       method in this trait
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/empty-type-parameter-list.rs b/tests/ui/empty-type-parameter-list.rs
index e168cd03b27..23d09fbf281 100644
--- a/tests/ui/empty-type-parameter-list.rs
+++ b/tests/ui/empty-type-parameter-list.rs
@@ -3,7 +3,7 @@
 // no type parameters at all
 
 struct S<>;
-trait T<> {}
+trait T<> {} //~ WARN trait `T` is never used
 enum E<> { V }
 impl<> T<> for S<> {}
 impl T for E {}
diff --git a/tests/ui/empty-type-parameter-list.stderr b/tests/ui/empty-type-parameter-list.stderr
new file mode 100644
index 00000000000..31a5015e993
--- /dev/null
+++ b/tests/ui/empty-type-parameter-list.stderr
@@ -0,0 +1,10 @@
+warning: trait `T` is never used
+  --> $DIR/empty-type-parameter-list.rs:6:7
+   |
+LL | trait T<> {}
+   |       ^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/explicit/explicit-call-to-supertrait-dtor.fixed b/tests/ui/explicit/explicit-call-to-supertrait-dtor.fixed
index bb093a4af4a..3c71587c8e3 100644
--- a/tests/ui/explicit/explicit-call-to-supertrait-dtor.fixed
+++ b/tests/ui/explicit/explicit-call-to-supertrait-dtor.fixed
@@ -1,5 +1,6 @@
 // run-rustfix
 
+#![allow(dead_code)]
 #![allow(dropping_references)]
 
 struct Foo {
diff --git a/tests/ui/explicit/explicit-call-to-supertrait-dtor.rs b/tests/ui/explicit/explicit-call-to-supertrait-dtor.rs
index 1a9f89c054f..075d4cbe02b 100644
--- a/tests/ui/explicit/explicit-call-to-supertrait-dtor.rs
+++ b/tests/ui/explicit/explicit-call-to-supertrait-dtor.rs
@@ -1,5 +1,6 @@
 // run-rustfix
 
+#![allow(dead_code)]
 #![allow(dropping_references)]
 
 struct Foo {
diff --git a/tests/ui/explicit/explicit-call-to-supertrait-dtor.stderr b/tests/ui/explicit/explicit-call-to-supertrait-dtor.stderr
index d2d69ce6daf..13b6ee9987e 100644
--- a/tests/ui/explicit/explicit-call-to-supertrait-dtor.stderr
+++ b/tests/ui/explicit/explicit-call-to-supertrait-dtor.stderr
@@ -1,5 +1,5 @@
 error[E0040]: explicit use of destructor method
-  --> $DIR/explicit-call-to-supertrait-dtor.rs:22:14
+  --> $DIR/explicit-call-to-supertrait-dtor.rs:23:14
    |
 LL |         self.drop();
    |              ^^^^ explicit destructor calls not allowed
diff --git a/tests/ui/extern/no-mangle-associated-fn.rs b/tests/ui/extern/no-mangle-associated-fn.rs
index ecd44abbf26..56afd8b9092 100644
--- a/tests/ui/extern/no-mangle-associated-fn.rs
+++ b/tests/ui/extern/no-mangle-associated-fn.rs
@@ -12,7 +12,7 @@ impl Foo {
     }
 }
 
-trait Bar {
+trait Bar { //~ WARN trait `Bar` is never used
     fn qux() -> u8;
 }
 
diff --git a/tests/ui/extern/no-mangle-associated-fn.stderr b/tests/ui/extern/no-mangle-associated-fn.stderr
new file mode 100644
index 00000000000..772cbf6cf7d
--- /dev/null
+++ b/tests/ui/extern/no-mangle-associated-fn.stderr
@@ -0,0 +1,10 @@
+warning: trait `Bar` is never used
+  --> $DIR/no-mangle-associated-fn.rs:15:7
+   |
+LL | trait Bar {
+   |       ^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/generic-associated-types/issue-88360.fixed b/tests/ui/generic-associated-types/issue-88360.fixed
index 3dea8bf7ac8..6fb1e2559c0 100644
--- a/tests/ui/generic-associated-types/issue-88360.fixed
+++ b/tests/ui/generic-associated-types/issue-88360.fixed
@@ -1,4 +1,5 @@
 // run-rustfix
+#![allow(dead_code)]
 
 trait GatTrait {
     type Gat<'a> where Self: 'a;
diff --git a/tests/ui/generic-associated-types/issue-88360.rs b/tests/ui/generic-associated-types/issue-88360.rs
index 4d4c7ea3180..c8f07955b61 100644
--- a/tests/ui/generic-associated-types/issue-88360.rs
+++ b/tests/ui/generic-associated-types/issue-88360.rs
@@ -1,4 +1,5 @@
 // run-rustfix
+#![allow(dead_code)]
 
 trait GatTrait {
     type Gat<'a> where Self: 'a;
diff --git a/tests/ui/generic-associated-types/issue-88360.stderr b/tests/ui/generic-associated-types/issue-88360.stderr
index 49d36acadd6..488e50d2843 100644
--- a/tests/ui/generic-associated-types/issue-88360.stderr
+++ b/tests/ui/generic-associated-types/issue-88360.stderr
@@ -1,5 +1,5 @@
 error[E0308]: mismatched types
-  --> $DIR/issue-88360.rs:15:9
+  --> $DIR/issue-88360.rs:16:9
    |
 LL | trait SuperTrait<T>
    |                  - found this type parameter
diff --git a/tests/ui/generics/generic-no-mangle.fixed b/tests/ui/generics/generic-no-mangle.fixed
index aa6d6310f5f..f51040358c0 100644
--- a/tests/ui/generics/generic-no-mangle.fixed
+++ b/tests/ui/generics/generic-no-mangle.fixed
@@ -1,5 +1,5 @@
 // run-rustfix
-
+#![allow(dead_code)]
 #![deny(no_mangle_generic_items)]
 
 
diff --git a/tests/ui/generics/generic-no-mangle.rs b/tests/ui/generics/generic-no-mangle.rs
index 8a59ca75aaf..02015331c57 100644
--- a/tests/ui/generics/generic-no-mangle.rs
+++ b/tests/ui/generics/generic-no-mangle.rs
@@ -1,5 +1,5 @@
 // run-rustfix
-
+#![allow(dead_code)]
 #![deny(no_mangle_generic_items)]
 
 #[no_mangle]
diff --git a/tests/ui/impl-trait/example-st.rs b/tests/ui/impl-trait/example-st.rs
index 4e1aa3a0859..1e6ebc52365 100644
--- a/tests/ui/impl-trait/example-st.rs
+++ b/tests/ui/impl-trait/example-st.rs
@@ -3,7 +3,7 @@
 struct State;
 type Error = ();
 
-trait Bind<F> {
+trait Bind<F> { //~ WARN trait `Bind` is never used
     type Output;
     fn bind(self, f: F) -> Self::Output;
 }
diff --git a/tests/ui/impl-trait/example-st.stderr b/tests/ui/impl-trait/example-st.stderr
new file mode 100644
index 00000000000..f722d7f6582
--- /dev/null
+++ b/tests/ui/impl-trait/example-st.stderr
@@ -0,0 +1,10 @@
+warning: trait `Bind` is never used
+  --> $DIR/example-st.rs:6:7
+   |
+LL | trait Bind<F> {
+   |       ^^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/impl-trait/in-trait/suggest-missing-item.fixed b/tests/ui/impl-trait/in-trait/suggest-missing-item.fixed
index 8dc8e045d47..ecc8488a152 100644
--- a/tests/ui/impl-trait/in-trait/suggest-missing-item.fixed
+++ b/tests/ui/impl-trait/in-trait/suggest-missing-item.fixed
@@ -1,6 +1,7 @@
 // edition:2021
 // run-rustfix
 
+#![allow(dead_code)]
 trait Trait {
     #[allow(async_fn_in_trait)]
     async fn foo();
diff --git a/tests/ui/impl-trait/in-trait/suggest-missing-item.rs b/tests/ui/impl-trait/in-trait/suggest-missing-item.rs
index 30b04d87b9a..860fea07df9 100644
--- a/tests/ui/impl-trait/in-trait/suggest-missing-item.rs
+++ b/tests/ui/impl-trait/in-trait/suggest-missing-item.rs
@@ -1,6 +1,7 @@
 // edition:2021
 // run-rustfix
 
+#![allow(dead_code)]
 trait Trait {
     #[allow(async_fn_in_trait)]
     async fn foo();
diff --git a/tests/ui/impl-trait/in-trait/suggest-missing-item.stderr b/tests/ui/impl-trait/in-trait/suggest-missing-item.stderr
index cf68ed87030..45fd79badb3 100644
--- a/tests/ui/impl-trait/in-trait/suggest-missing-item.stderr
+++ b/tests/ui/impl-trait/in-trait/suggest-missing-item.stderr
@@ -1,5 +1,5 @@
 error[E0046]: not all trait items implemented, missing: `foo`, `bar`, `test`, `baz`
-  --> $DIR/suggest-missing-item.rs:19:1
+  --> $DIR/suggest-missing-item.rs:20:1
    |
 LL |     async fn foo();
    |     --------------- `foo` from trait
diff --git a/tests/ui/impl-trait/type-alias-generic-param.rs b/tests/ui/impl-trait/type-alias-generic-param.rs
index 1211625dac9..e4b2e412420 100644
--- a/tests/ui/impl-trait/type-alias-generic-param.rs
+++ b/tests/ui/impl-trait/type-alias-generic-param.rs
@@ -5,7 +5,7 @@
 // run-pass
 #![feature(impl_trait_in_assoc_type)]
 
-trait Meow {
+trait Meow { //~ WARN trait `Meow` is never used
     type MeowType;
     fn meow(self) -> Self::MeowType;
 }
diff --git a/tests/ui/impl-trait/type-alias-generic-param.stderr b/tests/ui/impl-trait/type-alias-generic-param.stderr
new file mode 100644
index 00000000000..e4115dc1319
--- /dev/null
+++ b/tests/ui/impl-trait/type-alias-generic-param.stderr
@@ -0,0 +1,10 @@
+warning: trait `Meow` is never used
+  --> $DIR/type-alias-generic-param.rs:8:7
+   |
+LL | trait Meow {
+   |       ^^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/issues/issue-14399.rs b/tests/ui/issues/issue-14399.rs
index 7b32bf8e4cb..0c6c4d8dc6b 100644
--- a/tests/ui/issues/issue-14399.rs
+++ b/tests/ui/issues/issue-14399.rs
@@ -9,7 +9,7 @@
 #[derive(Clone)]
 struct B1;
 
-trait A { fn foo(&self) {} }
+trait A { fn foo(&self) {} } //~ WARN method `foo` is never used
 impl A for B1 {}
 
 fn main() {
diff --git a/tests/ui/issues/issue-14399.stderr b/tests/ui/issues/issue-14399.stderr
new file mode 100644
index 00000000000..d226ece6fb0
--- /dev/null
+++ b/tests/ui/issues/issue-14399.stderr
@@ -0,0 +1,12 @@
+warning: method `foo` is never used
+  --> $DIR/issue-14399.rs:12:14
+   |
+LL | trait A { fn foo(&self) {} }
+   |       -      ^^^
+   |       |
+   |       method in this trait
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/issues/issue-15858.rs b/tests/ui/issues/issue-15858.rs
index 77941c07671..e3e3c293d7a 100644
--- a/tests/ui/issues/issue-15858.rs
+++ b/tests/ui/issues/issue-15858.rs
@@ -2,7 +2,7 @@
 static mut DROP_RAN: bool = false;
 
 trait Bar {
-    fn do_something(&mut self);
+    fn do_something(&mut self); //~ WARN method `do_something` is never used
 }
 
 struct BarImpl;
diff --git a/tests/ui/issues/issue-15858.stderr b/tests/ui/issues/issue-15858.stderr
new file mode 100644
index 00000000000..f36bcc21bd7
--- /dev/null
+++ b/tests/ui/issues/issue-15858.stderr
@@ -0,0 +1,12 @@
+warning: method `do_something` is never used
+  --> $DIR/issue-15858.rs:5:8
+   |
+LL | trait Bar {
+   |       --- method in this trait
+LL |     fn do_something(&mut self);
+   |        ^^^^^^^^^^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/issues/issue-17351.rs b/tests/ui/issues/issue-17351.rs
index 62f6bcf15e3..12bb8a73b7b 100644
--- a/tests/ui/issues/issue-17351.rs
+++ b/tests/ui/issues/issue-17351.rs
@@ -1,7 +1,7 @@
 // run-pass
 // pretty-expanded FIXME #23616
 
-trait Str { fn foo(&self) {} }
+trait Str { fn foo(&self) {} } //~ WARN method `foo` is never used
 impl Str for str {}
 impl<'a, S: ?Sized> Str for &'a S where S: Str {}
 
diff --git a/tests/ui/issues/issue-17351.stderr b/tests/ui/issues/issue-17351.stderr
new file mode 100644
index 00000000000..3242d578dab
--- /dev/null
+++ b/tests/ui/issues/issue-17351.stderr
@@ -0,0 +1,12 @@
+warning: method `foo` is never used
+  --> $DIR/issue-17351.rs:4:16
+   |
+LL | trait Str { fn foo(&self) {} }
+   |       ---      ^^^
+   |       |
+   |       method in this trait
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/issues/issue-18173.rs b/tests/ui/issues/issue-18173.rs
index 11468040ee5..010efee9f8a 100644
--- a/tests/ui/issues/issue-18173.rs
+++ b/tests/ui/issues/issue-18173.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 trait Foo {
     type T;
 }
diff --git a/tests/ui/issues/issue-20055-box-trait.rs b/tests/ui/issues/issue-20055-box-trait.rs
index 772cd9d7eda..36f597450ad 100644
--- a/tests/ui/issues/issue-20055-box-trait.rs
+++ b/tests/ui/issues/issue-20055-box-trait.rs
@@ -8,7 +8,7 @@
 // statement surrounding the `match`.
 
 trait Boo {
-    fn dummy(&self) { }
+    fn dummy(&self) { } //~ WARN method `dummy` is never used
 }
 
 impl Boo for [i8; 1] { }
diff --git a/tests/ui/issues/issue-20055-box-trait.stderr b/tests/ui/issues/issue-20055-box-trait.stderr
new file mode 100644
index 00000000000..db9d359e225
--- /dev/null
+++ b/tests/ui/issues/issue-20055-box-trait.stderr
@@ -0,0 +1,12 @@
+warning: method `dummy` is never used
+  --> $DIR/issue-20055-box-trait.rs:11:8
+   |
+LL | trait Boo {
+   |       --- method in this trait
+LL |     fn dummy(&self) { }
+   |        ^^^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/issues/issue-21909.rs b/tests/ui/issues/issue-21909.rs
index 7cb558d9a4f..6a6cdcfee15 100644
--- a/tests/ui/issues/issue-21909.rs
+++ b/tests/ui/issues/issue-21909.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 // pretty-expanded FIXME #23616
 
 trait A<X> {
diff --git a/tests/ui/issues/issue-23485.rs b/tests/ui/issues/issue-23485.rs
index 1dd3d9293bc..07ed0f1b00d 100644
--- a/tests/ui/issues/issue-23485.rs
+++ b/tests/ui/issues/issue-23485.rs
@@ -17,7 +17,7 @@ trait Iterator {
 
     fn next(&mut self) -> Option<Self::Item>;
 
-    fn clone_first(mut self) -> Option<<Self::Item as Deref>::Target> where
+    fn clone_first(mut self) -> Option<<Self::Item as Deref>::Target> where //~ WARN method `clone_first` is never used
         Self: Sized,
         Self::Item: Deref,
         <Self::Item as Deref>::Target: Clone,
diff --git a/tests/ui/issues/issue-23485.stderr b/tests/ui/issues/issue-23485.stderr
new file mode 100644
index 00000000000..ed2d2400d0d
--- /dev/null
+++ b/tests/ui/issues/issue-23485.stderr
@@ -0,0 +1,13 @@
+warning: method `clone_first` is never used
+  --> $DIR/issue-23485.rs:20:8
+   |
+LL | trait Iterator {
+   |       -------- method in this trait
+...
+LL |     fn clone_first(mut self) -> Option<<Self::Item as Deref>::Target> where
+   |        ^^^^^^^^^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/issues/issue-2989.rs b/tests/ui/issues/issue-2989.rs
index c0b67374370..a9586751407 100644
--- a/tests/ui/issues/issue-2989.rs
+++ b/tests/ui/issues/issue-2989.rs
@@ -1,8 +1,8 @@
 // run-pass
 #![allow(non_camel_case_types)]
 
-trait methods {
-    fn to_bytes(&self) -> Vec<u8> ;
+trait methods { //~ WARN trait `methods` is never used
+    fn to_bytes(&self) -> Vec<u8>;
 }
 
 impl methods for () {
diff --git a/tests/ui/issues/issue-2989.stderr b/tests/ui/issues/issue-2989.stderr
new file mode 100644
index 00000000000..57181607cec
--- /dev/null
+++ b/tests/ui/issues/issue-2989.stderr
@@ -0,0 +1,10 @@
+warning: trait `methods` is never used
+  --> $DIR/issue-2989.rs:4:7
+   |
+LL | trait methods {
+   |       ^^^^^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/issues/issue-34074.rs b/tests/ui/issues/issue-34074.rs
index 0600d3937c1..ca7d7b49a04 100644
--- a/tests/ui/issues/issue-34074.rs
+++ b/tests/ui/issues/issue-34074.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 // Make sure several unnamed function parameters don't conflict with each other
 
 trait Tr {
diff --git a/tests/ui/issues/issue-34503.rs b/tests/ui/issues/issue-34503.rs
index 26e7358408f..d2c95d990ec 100644
--- a/tests/ui/issues/issue-34503.rs
+++ b/tests/ui/issues/issue-34503.rs
@@ -2,7 +2,7 @@
 fn main() {
     struct X;
     trait Foo<T> {
-        fn foo(&self) where (T, Option<T>): Ord {}
+        fn foo(&self) where (T, Option<T>): Ord {} //~ WARN methods `foo` and `bar` are never used
         fn bar(&self, x: &Option<T>) -> bool
         where Option<T>: Ord { *x < *x }
     }
diff --git a/tests/ui/issues/issue-34503.stderr b/tests/ui/issues/issue-34503.stderr
new file mode 100644
index 00000000000..60d8d76a619
--- /dev/null
+++ b/tests/ui/issues/issue-34503.stderr
@@ -0,0 +1,14 @@
+warning: methods `foo` and `bar` are never used
+  --> $DIR/issue-34503.rs:5:12
+   |
+LL |     trait Foo<T> {
+   |           --- methods in this trait
+LL |         fn foo(&self) where (T, Option<T>): Ord {}
+   |            ^^^
+LL |         fn bar(&self, x: &Option<T>) -> bool
+   |            ^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/issues/issue-3563-3.rs b/tests/ui/issues/issue-3563-3.rs
index bedfdab97d5..6346b82167c 100644
--- a/tests/ui/issues/issue-3563-3.rs
+++ b/tests/ui/issues/issue-3563-3.rs
@@ -112,7 +112,7 @@ trait Canvas {
 
     // Unlike interfaces traits support default implementations.
     // Got an ICE as soon as I added this method.
-    fn add_points(&mut self, shapes: &[Point]) {
+    fn add_points(&mut self, shapes: &[Point]) { //~ WARN method `add_points` is never used
         for pt in shapes {self.add_point(*pt)};
     }
 }
diff --git a/tests/ui/issues/issue-3563-3.stderr b/tests/ui/issues/issue-3563-3.stderr
new file mode 100644
index 00000000000..bd65c1e3fd5
--- /dev/null
+++ b/tests/ui/issues/issue-3563-3.stderr
@@ -0,0 +1,13 @@
+warning: method `add_points` is never used
+  --> $DIR/issue-3563-3.rs:115:8
+   |
+LL | trait Canvas {
+   |       ------ method in this trait
+...
+LL |     fn add_points(&mut self, shapes: &[Point]) {
+   |        ^^^^^^^^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/issues/issue-50571.fixed b/tests/ui/issues/issue-50571.fixed
index 2f8c925b853..13c830cd0d4 100644
--- a/tests/ui/issues/issue-50571.fixed
+++ b/tests/ui/issues/issue-50571.fixed
@@ -1,5 +1,6 @@
 // run-rustfix
 
+#![allow(dead_code)]
 trait Foo {
     fn foo(_: [i32; 2]) {}
     //~^ ERROR: patterns aren't allowed in methods without bodies
diff --git a/tests/ui/issues/issue-50571.rs b/tests/ui/issues/issue-50571.rs
index 56f422e7d58..6fe13e3f707 100644
--- a/tests/ui/issues/issue-50571.rs
+++ b/tests/ui/issues/issue-50571.rs
@@ -1,5 +1,6 @@
 // run-rustfix
 
+#![allow(dead_code)]
 trait Foo {
     fn foo([a, b]: [i32; 2]) {}
     //~^ ERROR: patterns aren't allowed in methods without bodies
diff --git a/tests/ui/issues/issue-50571.stderr b/tests/ui/issues/issue-50571.stderr
index fe47790f1dd..12256ded1c0 100644
--- a/tests/ui/issues/issue-50571.stderr
+++ b/tests/ui/issues/issue-50571.stderr
@@ -1,5 +1,5 @@
 error[E0642]: patterns aren't allowed in methods without bodies
-  --> $DIR/issue-50571.rs:4:12
+  --> $DIR/issue-50571.rs:5:12
    |
 LL |     fn foo([a, b]: [i32; 2]) {}
    |            ^^^^^^
diff --git a/tests/ui/issues/issue-7575.rs b/tests/ui/issues/issue-7575.rs
index ac69f2b1c80..0074f660c4e 100644
--- a/tests/ui/issues/issue-7575.rs
+++ b/tests/ui/issues/issue-7575.rs
@@ -1,6 +1,6 @@
 // run-pass
 
-trait Foo {
+trait Foo { //~ WARN trait `Foo` is never used
     fn new() -> bool { false }
     fn dummy(&self) { }
 }
diff --git a/tests/ui/issues/issue-7575.stderr b/tests/ui/issues/issue-7575.stderr
new file mode 100644
index 00000000000..2f987d19c80
--- /dev/null
+++ b/tests/ui/issues/issue-7575.stderr
@@ -0,0 +1,10 @@
+warning: trait `Foo` is never used
+  --> $DIR/issue-7575.rs:3:7
+   |
+LL | trait Foo {
+   |       ^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/issues/issue-7911.rs b/tests/ui/issues/issue-7911.rs
index d4db3b0776b..114574b9009 100644
--- a/tests/ui/issues/issue-7911.rs
+++ b/tests/ui/issues/issue-7911.rs
@@ -4,7 +4,7 @@
 
 #![allow(unused_variables)] // unused foobar_immut + foobar_mut
 trait FooBar {
-    fn dummy(&self) { }
+    fn dummy(&self) { } //~ WARN method `dummy` is never used
 }
 struct Bar(#[allow(dead_code)] i32);
 struct Foo { bar: Bar }
diff --git a/tests/ui/issues/issue-7911.stderr b/tests/ui/issues/issue-7911.stderr
new file mode 100644
index 00000000000..ead7ee191ac
--- /dev/null
+++ b/tests/ui/issues/issue-7911.stderr
@@ -0,0 +1,12 @@
+warning: method `dummy` is never used
+  --> $DIR/issue-7911.rs:7:8
+   |
+LL | trait FooBar {
+   |       ------ method in this trait
+LL |     fn dummy(&self) { }
+   |        ^^^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/issues/issue-8248.rs b/tests/ui/issues/issue-8248.rs
index 31a305c31be..94b1a5203b4 100644
--- a/tests/ui/issues/issue-8248.rs
+++ b/tests/ui/issues/issue-8248.rs
@@ -2,7 +2,7 @@
 // pretty-expanded FIXME #23616
 
 trait A {
-    fn dummy(&self) { }
+    fn dummy(&self) { } //~ WARN method `dummy` is never used
 }
 struct B;
 impl A for B {}
diff --git a/tests/ui/issues/issue-8248.stderr b/tests/ui/issues/issue-8248.stderr
new file mode 100644
index 00000000000..a0098bcb771
--- /dev/null
+++ b/tests/ui/issues/issue-8248.stderr
@@ -0,0 +1,12 @@
+warning: method `dummy` is never used
+  --> $DIR/issue-8248.rs:5:8
+   |
+LL | trait A {
+   |       - method in this trait
+LL |     fn dummy(&self) { }
+   |        ^^^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/issues/issue-9951.rs b/tests/ui/issues/issue-9951.rs
index 2698a3b17c6..5db3f74efaa 100644
--- a/tests/ui/issues/issue-9951.rs
+++ b/tests/ui/issues/issue-9951.rs
@@ -4,7 +4,7 @@
 #![allow(unused_variables)]
 
 trait Bar {
-  fn noop(&self);
+  fn noop(&self); //~ WARN method `noop` is never used
 }
 impl Bar for u8 {
   fn noop(&self) {}
diff --git a/tests/ui/issues/issue-9951.stderr b/tests/ui/issues/issue-9951.stderr
new file mode 100644
index 00000000000..475f2817914
--- /dev/null
+++ b/tests/ui/issues/issue-9951.stderr
@@ -0,0 +1,12 @@
+warning: method `noop` is never used
+  --> $DIR/issue-9951.rs:7:6
+   |
+LL | trait Bar {
+   |       --- method in this trait
+LL |   fn noop(&self);
+   |      ^^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/lint/dead-code/associated-type.rs b/tests/ui/lint/dead-code/associated-type.rs
index 1cf66e75a95..25106a66e7e 100644
--- a/tests/ui/lint/dead-code/associated-type.rs
+++ b/tests/ui/lint/dead-code/associated-type.rs
@@ -15,5 +15,5 @@ impl Foo for Ex {
 }
 
 pub fn main() {
-    let _x = Ex;
+    let _x: &dyn Foo<Bar = <Ex as Foo>::Bar> = &Ex;
 }
diff --git a/tests/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.rs b/tests/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.rs
index 942c5516500..2d6364aa0cd 100644
--- a/tests/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.rs
+++ b/tests/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.rs
@@ -17,7 +17,7 @@ struct Bar {
 
 // Issue 119267: this should not ICE.
 #[derive(Debug)]
-struct Foo(usize, #[allow(unused)] usize); //~ WARN field `0` is never read
+struct Foo(usize, #[allow(unused)] usize); //~ WARN struct `Foo` is never constructed
 
 fn main() {
     Bar {
diff --git a/tests/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.stderr b/tests/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.stderr
index 06f9b229c18..b992005318f 100644
--- a/tests/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.stderr
+++ b/tests/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.stderr
@@ -51,19 +51,13 @@ note: the lint level is defined here
 LL |     #[forbid(dead_code)]
    |              ^^^^^^^^^
 
-warning: field `0` is never read
-  --> $DIR/multiple-dead-codes-in-the-same-struct.rs:20:12
+warning: struct `Foo` is never constructed
+  --> $DIR/multiple-dead-codes-in-the-same-struct.rs:20:8
    |
 LL | struct Foo(usize, #[allow(unused)] usize);
-   |        --- ^^^^^
-   |        |
-   |        field in this struct
+   |        ^^^
    |
    = note: `Foo` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
-help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
-   |
-LL | struct Foo((), #[allow(unused)] usize);
-   |            ~~
 
 error: aborting due to 2 previous errors; 2 warnings emitted
 
diff --git a/tests/ui/lint/issue-20343.rs b/tests/ui/lint/issue-20343.rs
index 000b6398442..f0f4eccc676 100644
--- a/tests/ui/lint/issue-20343.rs
+++ b/tests/ui/lint/issue-20343.rs
@@ -22,6 +22,8 @@ impl B {
 
     // test for unused code in generics
     fn baz<A: T<D>>() {}
+
+    fn foz<A: T<D>>(a: A) { a.dummy(D); }
 }
 
 pub fn main() {
@@ -29,4 +31,5 @@ pub fn main() {
     B::foo(b);
     B::bar();
     B::baz::<()>();
+    B::foz::<()>(());
 }
diff --git a/tests/ui/macros/issue-22463.rs b/tests/ui/macros/issue-22463.rs
index fdf5a2fca72..8f7b27cb9a0 100644
--- a/tests/ui/macros/issue-22463.rs
+++ b/tests/ui/macros/issue-22463.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 macro_rules! items {
     () => {
         type A = ();
diff --git a/tests/ui/methods/method-lookup-order.rs b/tests/ui/methods/method-lookup-order.rs
index 986fe103cdc..5a46cf35dec 100644
--- a/tests/ui/methods/method-lookup-order.rs
+++ b/tests/ui/methods/method-lookup-order.rs
@@ -1,6 +1,7 @@
 // ignore-tidy-linelength
 
 // run-pass
+#![allow(dead_code)]
 
 // There are five cfg's below. I explored the set of all non-empty combinations
 // of the below five cfg's, which is 2^5 - 1 = 31 combinations.
diff --git a/tests/ui/methods/method-recursive-blanket-impl.rs b/tests/ui/methods/method-recursive-blanket-impl.rs
index a2db75b4e85..e7e83cbec77 100644
--- a/tests/ui/methods/method-recursive-blanket-impl.rs
+++ b/tests/ui/methods/method-recursive-blanket-impl.rs
@@ -11,7 +11,7 @@
 use std::marker::Sized;
 
 // Note: this must be generic for the problem to show up
-trait Foo<A> {
+trait Foo<A> { //~ WARN trait `Foo` is never used
     fn foo(&self, a: A);
 }
 
diff --git a/tests/ui/methods/method-recursive-blanket-impl.stderr b/tests/ui/methods/method-recursive-blanket-impl.stderr
new file mode 100644
index 00000000000..9797a8f6c83
--- /dev/null
+++ b/tests/ui/methods/method-recursive-blanket-impl.stderr
@@ -0,0 +1,10 @@
+warning: trait `Foo` is never used
+  --> $DIR/method-recursive-blanket-impl.rs:14:7
+   |
+LL | trait Foo<A> {
+   |       ^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/methods/method-two-trait-defer-resolution-2.rs b/tests/ui/methods/method-two-trait-defer-resolution-2.rs
index fc5766da971..d6076126732 100644
--- a/tests/ui/methods/method-two-trait-defer-resolution-2.rs
+++ b/tests/ui/methods/method-two-trait-defer-resolution-2.rs
@@ -14,7 +14,7 @@ trait Foo {
     fn foo(&self) -> isize;
 }
 
-trait MyCopy { fn foo(&self) { } }
+trait MyCopy { fn foo(&self) { } } //~ WARN method `foo` is never used
 impl MyCopy for i32 { }
 
 impl<T:MyCopy> Foo for Vec<T> {
diff --git a/tests/ui/methods/method-two-trait-defer-resolution-2.stderr b/tests/ui/methods/method-two-trait-defer-resolution-2.stderr
new file mode 100644
index 00000000000..4501ea5d243
--- /dev/null
+++ b/tests/ui/methods/method-two-trait-defer-resolution-2.stderr
@@ -0,0 +1,12 @@
+warning: method `foo` is never used
+  --> $DIR/method-two-trait-defer-resolution-2.rs:17:19
+   |
+LL | trait MyCopy { fn foo(&self) { } }
+   |       ------      ^^^
+   |       |
+   |       method in this trait
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/methods/method-two-traits-distinguished-via-where-clause.rs b/tests/ui/methods/method-two-traits-distinguished-via-where-clause.rs
index d820d2ad08a..2fd6c3bfab8 100644
--- a/tests/ui/methods/method-two-traits-distinguished-via-where-clause.rs
+++ b/tests/ui/methods/method-two-traits-distinguished-via-where-clause.rs
@@ -4,7 +4,7 @@
 
 // pretty-expanded FIXME #23616
 
-trait A {
+trait A { //~ WARN trait `A` is never used
     fn foo(self);
 }
 
diff --git a/tests/ui/methods/method-two-traits-distinguished-via-where-clause.stderr b/tests/ui/methods/method-two-traits-distinguished-via-where-clause.stderr
new file mode 100644
index 00000000000..0a60c6242bb
--- /dev/null
+++ b/tests/ui/methods/method-two-traits-distinguished-via-where-clause.stderr
@@ -0,0 +1,10 @@
+warning: trait `A` is never used
+  --> $DIR/method-two-traits-distinguished-via-where-clause.rs:7:7
+   |
+LL | trait A {
+   |       ^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/mir/mir_raw_fat_ptr.rs b/tests/ui/mir/mir_raw_fat_ptr.rs
index 8e5a2043dc6..e141aa03aa9 100644
--- a/tests/ui/mir/mir_raw_fat_ptr.rs
+++ b/tests/ui/mir/mir_raw_fat_ptr.rs
@@ -98,7 +98,7 @@ fn assert_inorder<T: Copy>(a: &[T],
     }
 }
 
-trait Foo { fn foo(&self) -> usize; }
+trait Foo { fn foo(&self) -> usize; } //~ WARN method `foo` is never used
 impl<T> Foo for T {
     fn foo(&self) -> usize {
         mem::size_of::<T>()
diff --git a/tests/ui/mir/mir_raw_fat_ptr.stderr b/tests/ui/mir/mir_raw_fat_ptr.stderr
new file mode 100644
index 00000000000..a9e9dd66ebd
--- /dev/null
+++ b/tests/ui/mir/mir_raw_fat_ptr.stderr
@@ -0,0 +1,12 @@
+warning: method `foo` is never used
+  --> $DIR/mir_raw_fat_ptr.rs:101:16
+   |
+LL | trait Foo { fn foo(&self) -> usize; }
+   |       ---      ^^^
+   |       |
+   |       method in this trait
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/moves/issue-22536-copy-mustnt-zero.rs b/tests/ui/moves/issue-22536-copy-mustnt-zero.rs
index 017f36484c1..b3fc1a56f88 100644
--- a/tests/ui/moves/issue-22536-copy-mustnt-zero.rs
+++ b/tests/ui/moves/issue-22536-copy-mustnt-zero.rs
@@ -5,7 +5,7 @@
 
 trait Resources {
     type Buffer: Copy;
-    fn foo(&self) {}
+    fn foo(&self) {} //~ WARN method `foo` is never used
 }
 
 struct BufferHandle<R: Resources> {
diff --git a/tests/ui/moves/issue-22536-copy-mustnt-zero.stderr b/tests/ui/moves/issue-22536-copy-mustnt-zero.stderr
new file mode 100644
index 00000000000..b1fcdfa44c3
--- /dev/null
+++ b/tests/ui/moves/issue-22536-copy-mustnt-zero.stderr
@@ -0,0 +1,13 @@
+warning: method `foo` is never used
+  --> $DIR/issue-22536-copy-mustnt-zero.rs:8:8
+   |
+LL | trait Resources {
+   |       --------- method in this trait
+LL |     type Buffer: Copy;
+LL |     fn foo(&self) {}
+   |        ^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/object-safety/assoc_type_bounds_implicit_sized.fixed b/tests/ui/object-safety/assoc_type_bounds_implicit_sized.fixed
index 45c7e07a264..52046a8ab69 100644
--- a/tests/ui/object-safety/assoc_type_bounds_implicit_sized.fixed
+++ b/tests/ui/object-safety/assoc_type_bounds_implicit_sized.fixed
@@ -1,4 +1,5 @@
 // run-rustfix
+#![allow(dead_code)]
 trait TraitWithAType {
     type Item: ?Sized;
 }
diff --git a/tests/ui/object-safety/assoc_type_bounds_implicit_sized.rs b/tests/ui/object-safety/assoc_type_bounds_implicit_sized.rs
index c3e958f4983..96620c0abda 100644
--- a/tests/ui/object-safety/assoc_type_bounds_implicit_sized.rs
+++ b/tests/ui/object-safety/assoc_type_bounds_implicit_sized.rs
@@ -1,4 +1,5 @@
 // run-rustfix
+#![allow(dead_code)]
 trait TraitWithAType {
     type Item;
 }
diff --git a/tests/ui/object-safety/assoc_type_bounds_implicit_sized.stderr b/tests/ui/object-safety/assoc_type_bounds_implicit_sized.stderr
index cd2aa9fdbe3..9bb770ce431 100644
--- a/tests/ui/object-safety/assoc_type_bounds_implicit_sized.stderr
+++ b/tests/ui/object-safety/assoc_type_bounds_implicit_sized.stderr
@@ -1,12 +1,12 @@
 error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time
-  --> $DIR/assoc_type_bounds_implicit_sized.rs:8:17
+  --> $DIR/assoc_type_bounds_implicit_sized.rs:9:17
    |
 LL |     type Item = dyn Trait;
    |                 ^^^^^^^^^ doesn't have a size known at compile-time
    |
    = help: the trait `Sized` is not implemented for `(dyn Trait + 'static)`
 note: required by a bound in `TraitWithAType::Item`
-  --> $DIR/assoc_type_bounds_implicit_sized.rs:3:5
+  --> $DIR/assoc_type_bounds_implicit_sized.rs:4:5
    |
 LL |     type Item;
    |     ^^^^^^^^^^ required by this bound in `TraitWithAType::Item`
diff --git a/tests/ui/overloaded/issue-14958.rs b/tests/ui/overloaded/issue-14958.rs
index a12564ca9c0..80abf5e4e76 100644
--- a/tests/ui/overloaded/issue-14958.rs
+++ b/tests/ui/overloaded/issue-14958.rs
@@ -3,7 +3,7 @@
 
 #![feature(fn_traits, unboxed_closures)]
 
-trait Foo { fn dummy(&self) { }}
+trait Foo { fn dummy(&self) { }} //~ WARN method `dummy` is never used
 
 struct Bar;
 
diff --git a/tests/ui/overloaded/issue-14958.stderr b/tests/ui/overloaded/issue-14958.stderr
new file mode 100644
index 00000000000..cc97730239c
--- /dev/null
+++ b/tests/ui/overloaded/issue-14958.stderr
@@ -0,0 +1,12 @@
+warning: method `dummy` is never used
+  --> $DIR/issue-14958.rs:6:16
+   |
+LL | trait Foo { fn dummy(&self) { }}
+   |       ---      ^^^^^
+   |       |
+   |       method in this trait
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/overloaded/overloaded-index-in-field.rs b/tests/ui/overloaded/overloaded-index-in-field.rs
index 8a1fa7deb99..0dc45ea8ca2 100644
--- a/tests/ui/overloaded/overloaded-index-in-field.rs
+++ b/tests/ui/overloaded/overloaded-index-in-field.rs
@@ -27,7 +27,7 @@ impl Index<isize> for Foo {
 
 trait Int {
     fn get(self) -> isize;
-    fn get_from_ref(&self) -> isize;
+    fn get_from_ref(&self) -> isize; //~ WARN methods `get_from_ref` and `inc` are never used
     fn inc(&mut self);
 }
 
diff --git a/tests/ui/overloaded/overloaded-index-in-field.stderr b/tests/ui/overloaded/overloaded-index-in-field.stderr
new file mode 100644
index 00000000000..10c0a3faeb5
--- /dev/null
+++ b/tests/ui/overloaded/overloaded-index-in-field.stderr
@@ -0,0 +1,15 @@
+warning: methods `get_from_ref` and `inc` are never used
+  --> $DIR/overloaded-index-in-field.rs:30:8
+   |
+LL | trait Int {
+   |       --- methods in this trait
+LL |     fn get(self) -> isize;
+LL |     fn get_from_ref(&self) -> isize;
+   |        ^^^^^^^^^^^^
+LL |     fn inc(&mut self);
+   |        ^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/parser/parse-assoc-type-lt.rs b/tests/ui/parser/parse-assoc-type-lt.rs
index d3fe6079a5d..913fcd920bd 100644
--- a/tests/ui/parser/parse-assoc-type-lt.rs
+++ b/tests/ui/parser/parse-assoc-type-lt.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 // pretty-expanded FIXME #23616
 
 trait Foo {
diff --git a/tests/ui/parser/suggest-assoc-const.fixed b/tests/ui/parser/suggest-assoc-const.fixed
index 259f37b23a5..4229135ebb2 100644
--- a/tests/ui/parser/suggest-assoc-const.fixed
+++ b/tests/ui/parser/suggest-assoc-const.fixed
@@ -1,5 +1,6 @@
 // Issue: 101797, Suggest associated const for incorrect use of let in traits
 // run-rustfix
+#![allow(dead_code)]
 trait Trait {
     const _X: i32;
     //~^ ERROR non-item in item list
diff --git a/tests/ui/parser/suggest-assoc-const.rs b/tests/ui/parser/suggest-assoc-const.rs
index c7be712ec07..0cf695bd40a 100644
--- a/tests/ui/parser/suggest-assoc-const.rs
+++ b/tests/ui/parser/suggest-assoc-const.rs
@@ -1,5 +1,6 @@
 // Issue: 101797, Suggest associated const for incorrect use of let in traits
 // run-rustfix
+#![allow(dead_code)]
 trait Trait {
     let _X: i32;
     //~^ ERROR non-item in item list
diff --git a/tests/ui/parser/suggest-assoc-const.stderr b/tests/ui/parser/suggest-assoc-const.stderr
index 7ba1dbdff7e..6e29fad98d4 100644
--- a/tests/ui/parser/suggest-assoc-const.stderr
+++ b/tests/ui/parser/suggest-assoc-const.stderr
@@ -1,5 +1,5 @@
 error: non-item in item list
-  --> $DIR/suggest-assoc-const.rs:4:5
+  --> $DIR/suggest-assoc-const.rs:5:5
    |
 LL |     let _X: i32;
    |     ^^^ help: consider using `const` instead of `let` for associated const: `const`
diff --git a/tests/ui/parser/suggest-removing-semicolon-after-impl-trait-items.fixed b/tests/ui/parser/suggest-removing-semicolon-after-impl-trait-items.fixed
index 63704735490..81ee6cdf0a7 100644
--- a/tests/ui/parser/suggest-removing-semicolon-after-impl-trait-items.fixed
+++ b/tests/ui/parser/suggest-removing-semicolon-after-impl-trait-items.fixed
@@ -1,4 +1,5 @@
 // run-rustfix
+#![allow(dead_code)]
 
 trait Foo {
     fn bar() {} //~ ERROR non-item in item list
diff --git a/tests/ui/parser/suggest-removing-semicolon-after-impl-trait-items.rs b/tests/ui/parser/suggest-removing-semicolon-after-impl-trait-items.rs
index 4650b05e20c..c8f525fc4f0 100644
--- a/tests/ui/parser/suggest-removing-semicolon-after-impl-trait-items.rs
+++ b/tests/ui/parser/suggest-removing-semicolon-after-impl-trait-items.rs
@@ -1,4 +1,5 @@
 // run-rustfix
+#![allow(dead_code)]
 
 trait Foo {
     fn bar() {}; //~ ERROR non-item in item list
diff --git a/tests/ui/parser/suggest-removing-semicolon-after-impl-trait-items.stderr b/tests/ui/parser/suggest-removing-semicolon-after-impl-trait-items.stderr
index c716d5908ea..396c76ac85f 100644
--- a/tests/ui/parser/suggest-removing-semicolon-after-impl-trait-items.stderr
+++ b/tests/ui/parser/suggest-removing-semicolon-after-impl-trait-items.stderr
@@ -1,5 +1,5 @@
 error: non-item in item list
-  --> $DIR/suggest-removing-semicolon-after-impl-trait-items.rs:4:16
+  --> $DIR/suggest-removing-semicolon-after-impl-trait-items.rs:5:16
    |
 LL | trait Foo {
    |           - item list starts here
diff --git a/tests/ui/pattern/issue-22546.rs b/tests/ui/pattern/issue-22546.rs
index c26e457f9e4..8a0f51d0b84 100644
--- a/tests/ui/pattern/issue-22546.rs
+++ b/tests/ui/pattern/issue-22546.rs
@@ -15,7 +15,7 @@ impl<T: ::std::fmt::Display> Foo<T> {
     }
 }
 
-trait Tr {
+trait Tr { //~ WARN trait `Tr` is never used
     type U;
 }
 
diff --git a/tests/ui/pattern/issue-22546.stderr b/tests/ui/pattern/issue-22546.stderr
new file mode 100644
index 00000000000..e067a95e422
--- /dev/null
+++ b/tests/ui/pattern/issue-22546.stderr
@@ -0,0 +1,10 @@
+warning: trait `Tr` is never used
+  --> $DIR/issue-22546.rs:18:7
+   |
+LL | trait Tr {
+   |       ^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/privacy/sealed-traits/re-exported-trait.fixed b/tests/ui/privacy/sealed-traits/re-exported-trait.fixed
index 79b6a6516ab..6de7b865a99 100644
--- a/tests/ui/privacy/sealed-traits/re-exported-trait.fixed
+++ b/tests/ui/privacy/sealed-traits/re-exported-trait.fixed
@@ -1,4 +1,5 @@
 // run-rustfix
+#![allow(dead_code)]
 
 pub mod a {
     pub use self::b::Trait;
diff --git a/tests/ui/privacy/sealed-traits/re-exported-trait.rs b/tests/ui/privacy/sealed-traits/re-exported-trait.rs
index 5f96dfdcbd6..bf07d666dff 100644
--- a/tests/ui/privacy/sealed-traits/re-exported-trait.rs
+++ b/tests/ui/privacy/sealed-traits/re-exported-trait.rs
@@ -1,4 +1,5 @@
 // run-rustfix
+#![allow(dead_code)]
 
 pub mod a {
     pub use self::b::Trait;
diff --git a/tests/ui/privacy/sealed-traits/re-exported-trait.stderr b/tests/ui/privacy/sealed-traits/re-exported-trait.stderr
index 9f2291e6825..6e2f36e3f38 100644
--- a/tests/ui/privacy/sealed-traits/re-exported-trait.stderr
+++ b/tests/ui/privacy/sealed-traits/re-exported-trait.stderr
@@ -1,11 +1,11 @@
 error[E0603]: module `b` is private
-  --> $DIR/re-exported-trait.rs:11:9
+  --> $DIR/re-exported-trait.rs:12:9
    |
 LL | impl a::b::Trait for S {}
    |         ^ private module
    |
 note: the module `b` is defined here
-  --> $DIR/re-exported-trait.rs:5:5
+  --> $DIR/re-exported-trait.rs:6:5
    |
 LL |     mod b {
    |     ^^^^^
diff --git a/tests/ui/proc-macro/issue-89566-suggest-fix-invalid-top-level-macro-attr.fixed b/tests/ui/proc-macro/issue-89566-suggest-fix-invalid-top-level-macro-attr.fixed
index ae5f9f86726..a61c868ed0a 100644
--- a/tests/ui/proc-macro/issue-89566-suggest-fix-invalid-top-level-macro-attr.fixed
+++ b/tests/ui/proc-macro/issue-89566-suggest-fix-invalid-top-level-macro-attr.fixed
@@ -1,6 +1,7 @@
 // run-rustfix
 
 #[derive(Debug)] //~ ERROR `derive` attribute cannot be used at crate level
+#[allow(dead_code)]
 struct Test {}
 
 fn main() {}
diff --git a/tests/ui/proc-macro/issue-89566-suggest-fix-invalid-top-level-macro-attr.rs b/tests/ui/proc-macro/issue-89566-suggest-fix-invalid-top-level-macro-attr.rs
index 639c64f8827..403f4470de7 100644
--- a/tests/ui/proc-macro/issue-89566-suggest-fix-invalid-top-level-macro-attr.rs
+++ b/tests/ui/proc-macro/issue-89566-suggest-fix-invalid-top-level-macro-attr.rs
@@ -1,6 +1,7 @@
 // run-rustfix
 
 #![derive(Debug)] //~ ERROR `derive` attribute cannot be used at crate level
+#[allow(dead_code)]
 struct Test {}
 
 fn main() {}
diff --git a/tests/ui/proc-macro/issue-89566-suggest-fix-invalid-top-level-macro-attr.stderr b/tests/ui/proc-macro/issue-89566-suggest-fix-invalid-top-level-macro-attr.stderr
index f62cdd14b87..09908160542 100644
--- a/tests/ui/proc-macro/issue-89566-suggest-fix-invalid-top-level-macro-attr.stderr
+++ b/tests/ui/proc-macro/issue-89566-suggest-fix-invalid-top-level-macro-attr.stderr
@@ -3,6 +3,7 @@ error: `derive` attribute cannot be used at crate level
    |
 LL | #![derive(Debug)]
    | ^^^^^^^^^^^^^^^^^
+LL | #[allow(dead_code)]
 LL | struct Test {}
    |        ---- the inner attribute doesn't annotate this struct
    |
diff --git a/tests/ui/regions/regions-no-variance-from-fn-generics.rs b/tests/ui/regions/regions-no-variance-from-fn-generics.rs
index 76706a82781..a455d4efd71 100644
--- a/tests/ui/regions/regions-no-variance-from-fn-generics.rs
+++ b/tests/ui/regions/regions-no-variance-from-fn-generics.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 #![allow(unused_variables)]
 // Issue #12856: a lifetime formal binding introduced by a generic fn
 // should not upset the variance inference for actual occurrences of
diff --git a/tests/ui/resolve/issue-113808-invalid-unused-qualifications-suggestion.fixed b/tests/ui/resolve/issue-113808-invalid-unused-qualifications-suggestion.fixed
index e730f94660b..a7ab88fe993 100644
--- a/tests/ui/resolve/issue-113808-invalid-unused-qualifications-suggestion.fixed
+++ b/tests/ui/resolve/issue-113808-invalid-unused-qualifications-suggestion.fixed
@@ -1,5 +1,6 @@
 // run-rustfix
 
+#![allow(dead_code)]
 #![deny(unused_qualifications)]
 #![feature(unsized_fn_params)]
 
diff --git a/tests/ui/resolve/issue-113808-invalid-unused-qualifications-suggestion.rs b/tests/ui/resolve/issue-113808-invalid-unused-qualifications-suggestion.rs
index 641c892e3de..05936b191ff 100644
--- a/tests/ui/resolve/issue-113808-invalid-unused-qualifications-suggestion.rs
+++ b/tests/ui/resolve/issue-113808-invalid-unused-qualifications-suggestion.rs
@@ -1,5 +1,6 @@
 // run-rustfix
 
+#![allow(dead_code)]
 #![deny(unused_qualifications)]
 #![feature(unsized_fn_params)]
 
diff --git a/tests/ui/resolve/issue-113808-invalid-unused-qualifications-suggestion.stderr b/tests/ui/resolve/issue-113808-invalid-unused-qualifications-suggestion.stderr
index d9c7fd21871..bcda7210712 100644
--- a/tests/ui/resolve/issue-113808-invalid-unused-qualifications-suggestion.stderr
+++ b/tests/ui/resolve/issue-113808-invalid-unused-qualifications-suggestion.stderr
@@ -1,11 +1,11 @@
 error: unnecessary qualification
-  --> $DIR/issue-113808-invalid-unused-qualifications-suggestion.rs:12:6
+  --> $DIR/issue-113808-invalid-unused-qualifications-suggestion.rs:13:6
    |
 LL | impl ops::Index<str> for A {
    |      ^^^^^^^^^^^^^^^
    |
 note: the lint level is defined here
-  --> $DIR/issue-113808-invalid-unused-qualifications-suggestion.rs:3:9
+  --> $DIR/issue-113808-invalid-unused-qualifications-suggestion.rs:4:9
    |
 LL | #![deny(unused_qualifications)]
    |         ^^^^^^^^^^^^^^^^^^^^^
@@ -16,7 +16,7 @@ LL + impl Index<str> for A {
    |
 
 error: unnecessary qualification
-  --> $DIR/issue-113808-invalid-unused-qualifications-suggestion.rs:28:6
+  --> $DIR/issue-113808-invalid-unused-qualifications-suggestion.rs:29:6
    |
 LL | impl inner::Trait<u8> for () {}
    |      ^^^^^^^^^^^^^^^^
diff --git a/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.current.stderr b/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.current.stderr
new file mode 100644
index 00000000000..4a219ff8b55
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.current.stderr
@@ -0,0 +1,15 @@
+warning: methods `good_virt` and `good_indirect` are never used
+  --> $DIR/manual-self-impl-for-unsafe-obj.rs:22:8
+   |
+LL | trait Good {
+   |       ---- methods in this trait
+LL |     fn good_virt(&self) -> char {
+   |        ^^^^^^^^^
+...
+LL |     fn good_indirect(&self) -> char {
+   |        ^^^^^^^^^^^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.next.stderr b/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.next.stderr
new file mode 100644
index 00000000000..4a219ff8b55
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.next.stderr
@@ -0,0 +1,15 @@
+warning: methods `good_virt` and `good_indirect` are never used
+  --> $DIR/manual-self-impl-for-unsafe-obj.rs:22:8
+   |
+LL | trait Good {
+   |       ---- methods in this trait
+LL |     fn good_virt(&self) -> char {
+   |        ^^^^^^^^^
+...
+LL |     fn good_indirect(&self) -> char {
+   |        ^^^^^^^^^^^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.rs b/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.rs
index c7665affb99..c8eee9835fe 100644
--- a/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.rs
+++ b/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.rs
@@ -19,7 +19,7 @@ trait Bad {
 }
 
 trait Good {
-    fn good_virt(&self) -> char {
+    fn good_virt(&self) -> char { //~ WARN methods `good_virt` and `good_indirect` are never used
         panic!()
     }
     fn good_indirect(&self) -> char {
diff --git a/tests/ui/rust-2018/issue-51008-1.rs b/tests/ui/rust-2018/issue-51008-1.rs
index da7b8ef65c5..67dfbf64601 100644
--- a/tests/ui/rust-2018/issue-51008-1.rs
+++ b/tests/ui/rust-2018/issue-51008-1.rs
@@ -2,7 +2,7 @@
 // being incorrectly considered part of the "elided lifetimes" from
 // the impl.
 //
-// run-pass
+// check-pass
 
 trait A {
 
diff --git a/tests/ui/rust-2018/issue-51008.rs b/tests/ui/rust-2018/issue-51008.rs
index 56517b9adee..f9e4bc14ec8 100644
--- a/tests/ui/rust-2018/issue-51008.rs
+++ b/tests/ui/rust-2018/issue-51008.rs
@@ -2,7 +2,7 @@
 // being incorrectly considered part of the "elided lifetimes" from
 // the impl.
 //
-// run-pass
+// check-pass
 
 trait A {
 
diff --git a/tests/ui/sized/coinductive-2.rs b/tests/ui/sized/coinductive-2.rs
index 212274d2e4b..43a5a28f710 100644
--- a/tests/ui/sized/coinductive-2.rs
+++ b/tests/ui/sized/coinductive-2.rs
@@ -11,7 +11,7 @@ impl<T> CollectionFactory<T> for Vec<()> {
     type Collection = Vec<T>;
 }
 
-trait Collection<T>: Sized {
+trait Collection<T>: Sized { //~ WARN trait `Collection` is never used
     fn push(&mut self, v: T);
 }
 
diff --git a/tests/ui/sized/coinductive-2.stderr b/tests/ui/sized/coinductive-2.stderr
new file mode 100644
index 00000000000..1390b1f8d7b
--- /dev/null
+++ b/tests/ui/sized/coinductive-2.stderr
@@ -0,0 +1,10 @@
+warning: trait `Collection` is never used
+  --> $DIR/coinductive-2.rs:14:7
+   |
+LL | trait Collection<T>: Sized {
+   |       ^^^^^^^^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/specialization/assoc-ty-graph-cycle.rs b/tests/ui/specialization/assoc-ty-graph-cycle.rs
index fc39b553a61..bec8cc187b4 100644
--- a/tests/ui/specialization/assoc-ty-graph-cycle.rs
+++ b/tests/ui/specialization/assoc-ty-graph-cycle.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 
 // Make sure we don't crash with a cycle error during coherence.
 
diff --git a/tests/ui/specialization/defaultimpl/out-of-order.rs b/tests/ui/specialization/defaultimpl/out-of-order.rs
index 13258ac8c9f..94b3905178f 100644
--- a/tests/ui/specialization/defaultimpl/out-of-order.rs
+++ b/tests/ui/specialization/defaultimpl/out-of-order.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 
 // Test that you can list the more specific impl before the more general one.
 
diff --git a/tests/ui/specialization/defaultimpl/overlap-projection.rs b/tests/ui/specialization/defaultimpl/overlap-projection.rs
index 0add4d5516c..46f54c466a8 100644
--- a/tests/ui/specialization/defaultimpl/overlap-projection.rs
+++ b/tests/ui/specialization/defaultimpl/overlap-projection.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 
 // Test that impls on projected self types can resolve overlap, even when the
 // projections involve specialization, so long as the associated type is
diff --git a/tests/ui/specialization/specialization-out-of-order.rs b/tests/ui/specialization/specialization-out-of-order.rs
index cb7563e2760..66e6c3c9eab 100644
--- a/tests/ui/specialization/specialization-out-of-order.rs
+++ b/tests/ui/specialization/specialization-out-of-order.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 
 // Test that you can list the more specific impl before the more general one.
 
diff --git a/tests/ui/specialization/specialization-overlap-projection.rs b/tests/ui/specialization/specialization-overlap-projection.rs
index b07efb2a5c1..cd21eab24c0 100644
--- a/tests/ui/specialization/specialization-overlap-projection.rs
+++ b/tests/ui/specialization/specialization-overlap-projection.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 
 // Test that impls on projected self types can resolve overlap, even when the
 // projections involve specialization, so long as the associated type is
diff --git a/tests/ui/specialization/specialization-supertraits.rs b/tests/ui/specialization/specialization-supertraits.rs
index fb85d801921..d0c9dbb1d40 100644
--- a/tests/ui/specialization/specialization-supertraits.rs
+++ b/tests/ui/specialization/specialization-supertraits.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 
 #![feature(specialization)] //~ WARN the feature `specialization` is incomplete
 
diff --git a/tests/ui/statics/static-impl.rs b/tests/ui/statics/static-impl.rs
index e7bdb38ee62..9e2db7e0caf 100644
--- a/tests/ui/statics/static-impl.rs
+++ b/tests/ui/statics/static-impl.rs
@@ -35,7 +35,7 @@ impl uint_utils for usize {
 
 trait vec_utils<T> {
     fn length_(&self, ) -> usize;
-    fn iter_<F>(&self, f: F) where F: FnMut(&T);
+    fn iter_<F>(&self, f: F) where F: FnMut(&T); //~ WARN method `iter_` is never used
     fn map_<U, F>(&self, f: F) -> Vec<U> where F: FnMut(&T) -> U;
 }
 
diff --git a/tests/ui/statics/static-impl.stderr b/tests/ui/statics/static-impl.stderr
new file mode 100644
index 00000000000..83c3ffbefe1
--- /dev/null
+++ b/tests/ui/statics/static-impl.stderr
@@ -0,0 +1,13 @@
+warning: method `iter_` is never used
+  --> $DIR/static-impl.rs:38:8
+   |
+LL | trait vec_utils<T> {
+   |       --------- method in this trait
+LL |     fn length_(&self, ) -> usize;
+LL |     fn iter_<F>(&self, f: F) where F: FnMut(&T);
+   |        ^^^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/stdlib-unit-tests/raw-fat-ptr.rs b/tests/ui/stdlib-unit-tests/raw-fat-ptr.rs
index 0f535523dcc..4a8289cb242 100644
--- a/tests/ui/stdlib-unit-tests/raw-fat-ptr.rs
+++ b/tests/ui/stdlib-unit-tests/raw-fat-ptr.rs
@@ -32,7 +32,7 @@ fn assert_inorder<T: PartialEq + PartialOrd>(a: &[T]) {
     }
 }
 
-trait Foo { fn foo(&self) -> usize; }
+trait Foo { fn foo(&self) -> usize; } //~ WARN method `foo` is never used
 impl<T> Foo for T {
     fn foo(&self) -> usize {
         mem::size_of::<T>()
diff --git a/tests/ui/stdlib-unit-tests/raw-fat-ptr.stderr b/tests/ui/stdlib-unit-tests/raw-fat-ptr.stderr
new file mode 100644
index 00000000000..670fa5bb922
--- /dev/null
+++ b/tests/ui/stdlib-unit-tests/raw-fat-ptr.stderr
@@ -0,0 +1,12 @@
+warning: method `foo` is never used
+  --> $DIR/raw-fat-ptr.rs:35:16
+   |
+LL | trait Foo { fn foo(&self) -> usize; }
+   |       ---      ^^^
+   |       |
+   |       method in this trait
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/structs-enums/enum-null-pointer-opt.rs b/tests/ui/structs-enums/enum-null-pointer-opt.rs
index 356f8a6dd36..21564eeec29 100644
--- a/tests/ui/structs-enums/enum-null-pointer-opt.rs
+++ b/tests/ui/structs-enums/enum-null-pointer-opt.rs
@@ -7,7 +7,7 @@ use std::ptr::NonNull;
 use std::rc::Rc;
 use std::sync::Arc;
 
-trait Trait { fn dummy(&self) { } }
+trait Trait { fn dummy(&self) { } } //~ WARN method `dummy` is never used
 trait Mirror { type Image; }
 impl<T> Mirror for T { type Image = T; }
 struct ParamTypeStruct<T>(#[allow(dead_code)] T);
diff --git a/tests/ui/structs-enums/enum-null-pointer-opt.stderr b/tests/ui/structs-enums/enum-null-pointer-opt.stderr
new file mode 100644
index 00000000000..64e93ffaffd
--- /dev/null
+++ b/tests/ui/structs-enums/enum-null-pointer-opt.stderr
@@ -0,0 +1,12 @@
+warning: method `dummy` is never used
+  --> $DIR/enum-null-pointer-opt.rs:10:18
+   |
+LL | trait Trait { fn dummy(&self) { } }
+   |       -----      ^^^^^
+   |       |
+   |       method in this trait
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/suggestions/bound-suggestions.fixed b/tests/ui/suggestions/bound-suggestions.fixed
index 17a019c6984..ef61fb9ad32 100644
--- a/tests/ui/suggestions/bound-suggestions.fixed
+++ b/tests/ui/suggestions/bound-suggestions.fixed
@@ -40,26 +40,31 @@ fn test_many_bounds_where<X>(x: X) where X: Sized + std::fmt::Debug, X: Sized {
     //~^ ERROR doesn't implement
 }
 
+#[allow(dead_code)]
 trait Foo<T>: Sized {
     const SIZE: usize = core::mem::size_of::<Self>();
     //~^ ERROR the size for values of type `Self` cannot be known at compilation time
 }
 
+#[allow(dead_code)]
 trait Bar: std::fmt::Display + Sized {
     const SIZE: usize = core::mem::size_of::<Self>();
     //~^ ERROR the size for values of type `Self` cannot be known at compilation time
 }
 
+#[allow(dead_code)]
 trait Baz: Sized where Self: std::fmt::Display {
     const SIZE: usize = core::mem::size_of::<Self>();
     //~^ ERROR the size for values of type `Self` cannot be known at compilation time
 }
 
+#[allow(dead_code)]
 trait Qux<T>: Sized where Self: std::fmt::Display {
     const SIZE: usize = core::mem::size_of::<Self>();
     //~^ ERROR the size for values of type `Self` cannot be known at compilation time
 }
 
+#[allow(dead_code)]
 trait Bat<T>: std::fmt::Display + Sized {
     const SIZE: usize = core::mem::size_of::<Self>();
     //~^ ERROR the size for values of type `Self` cannot be known at compilation time
diff --git a/tests/ui/suggestions/bound-suggestions.rs b/tests/ui/suggestions/bound-suggestions.rs
index 86f708d42f5..6d17fae6a08 100644
--- a/tests/ui/suggestions/bound-suggestions.rs
+++ b/tests/ui/suggestions/bound-suggestions.rs
@@ -40,26 +40,31 @@ fn test_many_bounds_where<X>(x: X) where X: Sized, X: Sized {
     //~^ ERROR doesn't implement
 }
 
+#[allow(dead_code)]
 trait Foo<T> {
     const SIZE: usize = core::mem::size_of::<Self>();
     //~^ ERROR the size for values of type `Self` cannot be known at compilation time
 }
 
+#[allow(dead_code)]
 trait Bar: std::fmt::Display {
     const SIZE: usize = core::mem::size_of::<Self>();
     //~^ ERROR the size for values of type `Self` cannot be known at compilation time
 }
 
+#[allow(dead_code)]
 trait Baz where Self: std::fmt::Display {
     const SIZE: usize = core::mem::size_of::<Self>();
     //~^ ERROR the size for values of type `Self` cannot be known at compilation time
 }
 
+#[allow(dead_code)]
 trait Qux<T> where Self: std::fmt::Display {
     const SIZE: usize = core::mem::size_of::<Self>();
     //~^ ERROR the size for values of type `Self` cannot be known at compilation time
 }
 
+#[allow(dead_code)]
 trait Bat<T>: std::fmt::Display {
     const SIZE: usize = core::mem::size_of::<Self>();
     //~^ ERROR the size for values of type `Self` cannot be known at compilation time
diff --git a/tests/ui/suggestions/bound-suggestions.stderr b/tests/ui/suggestions/bound-suggestions.stderr
index 7e58ccd461d..4965e7439f8 100644
--- a/tests/ui/suggestions/bound-suggestions.stderr
+++ b/tests/ui/suggestions/bound-suggestions.stderr
@@ -71,7 +71,7 @@ LL | fn test_many_bounds_where<X>(x: X) where X: Sized + std::fmt::Debug, X: Siz
    |                                                   +++++++++++++++++
 
 error[E0277]: the size for values of type `Self` cannot be known at compilation time
-  --> $DIR/bound-suggestions.rs:44:46
+  --> $DIR/bound-suggestions.rs:45:46
    |
 LL |     const SIZE: usize = core::mem::size_of::<Self>();
    |                                              ^^^^ doesn't have a size known at compile-time
@@ -84,7 +84,7 @@ LL | trait Foo<T>: Sized {
    |             +++++++
 
 error[E0277]: the size for values of type `Self` cannot be known at compilation time
-  --> $DIR/bound-suggestions.rs:49:46
+  --> $DIR/bound-suggestions.rs:51:46
    |
 LL |     const SIZE: usize = core::mem::size_of::<Self>();
    |                                              ^^^^ doesn't have a size known at compile-time
@@ -97,7 +97,7 @@ LL | trait Bar: std::fmt::Display + Sized {
    |                              +++++++
 
 error[E0277]: the size for values of type `Self` cannot be known at compilation time
-  --> $DIR/bound-suggestions.rs:54:46
+  --> $DIR/bound-suggestions.rs:57:46
    |
 LL |     const SIZE: usize = core::mem::size_of::<Self>();
    |                                              ^^^^ doesn't have a size known at compile-time
@@ -110,7 +110,7 @@ LL | trait Baz: Sized where Self: std::fmt::Display {
    |          +++++++
 
 error[E0277]: the size for values of type `Self` cannot be known at compilation time
-  --> $DIR/bound-suggestions.rs:59:46
+  --> $DIR/bound-suggestions.rs:63:46
    |
 LL |     const SIZE: usize = core::mem::size_of::<Self>();
    |                                              ^^^^ doesn't have a size known at compile-time
@@ -123,7 +123,7 @@ LL | trait Qux<T>: Sized where Self: std::fmt::Display {
    |             +++++++
 
 error[E0277]: the size for values of type `Self` cannot be known at compilation time
-  --> $DIR/bound-suggestions.rs:64:46
+  --> $DIR/bound-suggestions.rs:69:46
    |
 LL |     const SIZE: usize = core::mem::size_of::<Self>();
    |                                              ^^^^ doesn't have a size known at compile-time
diff --git a/tests/ui/suggestions/constrain-trait.fixed b/tests/ui/suggestions/constrain-trait.fixed
index f292f27f0f3..f7360efe4c5 100644
--- a/tests/ui/suggestions/constrain-trait.fixed
+++ b/tests/ui/suggestions/constrain-trait.fixed
@@ -1,5 +1,6 @@
 // run-rustfix
 // check-only
+#![allow(dead_code)]
 
 #[derive(Debug)]
 struct Demo {
diff --git a/tests/ui/suggestions/constrain-trait.rs b/tests/ui/suggestions/constrain-trait.rs
index 99ccf7a7f3b..799100669b6 100644
--- a/tests/ui/suggestions/constrain-trait.rs
+++ b/tests/ui/suggestions/constrain-trait.rs
@@ -1,5 +1,6 @@
 // run-rustfix
 // check-only
+#![allow(dead_code)]
 
 #[derive(Debug)]
 struct Demo {
diff --git a/tests/ui/suggestions/constrain-trait.stderr b/tests/ui/suggestions/constrain-trait.stderr
index a26f86917bc..b28972ecde0 100644
--- a/tests/ui/suggestions/constrain-trait.stderr
+++ b/tests/ui/suggestions/constrain-trait.stderr
@@ -1,5 +1,5 @@
 error[E0599]: no method named `get_a` found for reference `&Self` in the current scope
-  --> $DIR/constrain-trait.rs:15:31
+  --> $DIR/constrain-trait.rs:16:31
    |
 LL |         println!("{:?}", self.get_a());
    |                               ^^^^^ method not found in `&Self`
@@ -11,7 +11,7 @@ LL | trait UseString: std::fmt::Debug + GetString {
    |                                  +++++++++++
 
 error[E0599]: no method named `get_a` found for reference `&Self` in the current scope
-  --> $DIR/constrain-trait.rs:21:31
+  --> $DIR/constrain-trait.rs:22:31
    |
 LL |         println!("{:?}", self.get_a());
    |                               ^^^^^ method not found in `&Self`
diff --git a/tests/ui/suggestions/lifetimes/type-param-bound-scope.fixed b/tests/ui/suggestions/lifetimes/type-param-bound-scope.fixed
index 3257ea04c69..d4a8381fcb1 100644
--- a/tests/ui/suggestions/lifetimes/type-param-bound-scope.fixed
+++ b/tests/ui/suggestions/lifetimes/type-param-bound-scope.fixed
@@ -1,6 +1,7 @@
 // Make sure we suggest the bound `T: 'a` in the correct scope:
 // trait, impl or associated fn.
 // run-rustfix
+#![allow(dead_code)]
 
 struct Inv<'a>(#[allow(dead_code)] Option<*mut &'a u8>);
 
diff --git a/tests/ui/suggestions/lifetimes/type-param-bound-scope.rs b/tests/ui/suggestions/lifetimes/type-param-bound-scope.rs
index fcc13aad996..dc43e2df6dd 100644
--- a/tests/ui/suggestions/lifetimes/type-param-bound-scope.rs
+++ b/tests/ui/suggestions/lifetimes/type-param-bound-scope.rs
@@ -1,6 +1,7 @@
 // Make sure we suggest the bound `T: 'a` in the correct scope:
 // trait, impl or associated fn.
 // run-rustfix
+#![allow(dead_code)]
 
 struct Inv<'a>(#[allow(dead_code)] Option<*mut &'a u8>);
 
diff --git a/tests/ui/suggestions/lifetimes/type-param-bound-scope.stderr b/tests/ui/suggestions/lifetimes/type-param-bound-scope.stderr
index d3ca2cc1162..91054472c04 100644
--- a/tests/ui/suggestions/lifetimes/type-param-bound-scope.stderr
+++ b/tests/ui/suggestions/lifetimes/type-param-bound-scope.stderr
@@ -1,5 +1,5 @@
 error[E0309]: the parameter type `Self` may not live long enough
-  --> $DIR/type-param-bound-scope.rs:11:9
+  --> $DIR/type-param-bound-scope.rs:12:9
    |
 LL | trait Trait1<'a>: Sized {
    |              -- the parameter type `Self` must be valid for the lifetime `'a` as defined here...
@@ -13,7 +13,7 @@ LL | trait Trait1<'a>: Sized where Self: 'a {
    |                         ++++++++++++++
 
 error[E0309]: the parameter type `Self` may not live long enough
-  --> $DIR/type-param-bound-scope.rs:18:9
+  --> $DIR/type-param-bound-scope.rs:19:9
    |
 LL |     fn foo<'a>(self, lt: Inv<'a>) {
    |            -- the parameter type `Self` must be valid for the lifetime `'a` as defined here...
@@ -26,7 +26,7 @@ LL |     fn foo<'a>(self, lt: Inv<'a>) where Self: 'a {
    |                                   ++++++++++++++
 
 error[E0309]: the parameter type `T` may not live long enough
-  --> $DIR/type-param-bound-scope.rs:25:9
+  --> $DIR/type-param-bound-scope.rs:26:9
    |
 LL |     fn foo<'a>(arg: T, lt: Inv<'a>) {
    |            -- the parameter type `T` must be valid for the lifetime `'a` as defined here...
@@ -39,7 +39,7 @@ LL |     fn foo<'a>(arg: T, lt: Inv<'a>) where T: 'a {
    |                                     +++++++++++
 
 error[E0309]: the parameter type `T` may not live long enough
-  --> $DIR/type-param-bound-scope.rs:32:9
+  --> $DIR/type-param-bound-scope.rs:33:9
    |
 LL | trait Trait4<'a> {
    |              -- the parameter type `T` must be valid for the lifetime `'a` as defined here...
@@ -53,7 +53,7 @@ LL |     fn foo<T: 'a>(arg: T, lt: Inv<'a>) {
    |             ++++
 
 error[E0309]: the parameter type `T` may not live long enough
-  --> $DIR/type-param-bound-scope.rs:42:9
+  --> $DIR/type-param-bound-scope.rs:43:9
    |
 LL | impl<'a, T> Trait5<'a> for T {
    |      -- the parameter type `T` must be valid for the lifetime `'a` as defined here...
diff --git a/tests/ui/suggestions/missing-bound-in-manual-copy-impl-2.fixed b/tests/ui/suggestions/missing-bound-in-manual-copy-impl-2.fixed
index f32c61a99bb..90bc10d34c6 100644
--- a/tests/ui/suggestions/missing-bound-in-manual-copy-impl-2.fixed
+++ b/tests/ui/suggestions/missing-bound-in-manual-copy-impl-2.fixed
@@ -1,4 +1,5 @@
 // run-rustfix
+#![allow(dead_code)]
 
 #[derive(Clone)]
 struct Wrapper<T>(T);
diff --git a/tests/ui/suggestions/missing-bound-in-manual-copy-impl-2.rs b/tests/ui/suggestions/missing-bound-in-manual-copy-impl-2.rs
index d7725f4a374..34673852a9b 100644
--- a/tests/ui/suggestions/missing-bound-in-manual-copy-impl-2.rs
+++ b/tests/ui/suggestions/missing-bound-in-manual-copy-impl-2.rs
@@ -1,4 +1,5 @@
 // run-rustfix
+#![allow(dead_code)]
 
 #[derive(Clone)]
 struct Wrapper<T>(T);
diff --git a/tests/ui/suggestions/missing-bound-in-manual-copy-impl-2.stderr b/tests/ui/suggestions/missing-bound-in-manual-copy-impl-2.stderr
index 6dc512223d1..23a75154f20 100644
--- a/tests/ui/suggestions/missing-bound-in-manual-copy-impl-2.stderr
+++ b/tests/ui/suggestions/missing-bound-in-manual-copy-impl-2.stderr
@@ -1,5 +1,5 @@
 error[E0204]: the trait `Copy` cannot be implemented for this type
-  --> $DIR/missing-bound-in-manual-copy-impl-2.rs:16:18
+  --> $DIR/missing-bound-in-manual-copy-impl-2.rs:17:18
    |
 LL | struct Wrapper<T>(T);
    |                   - this field does not implement `Copy`
@@ -8,7 +8,7 @@ LL | impl<S> Copy for Wrapper<OnlyCopyIfDisplay<S>> {}
    |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
 note: the `Copy` impl for `OnlyCopyIfDisplay<S>` requires that `S: std::fmt::Display`
-  --> $DIR/missing-bound-in-manual-copy-impl-2.rs:4:19
+  --> $DIR/missing-bound-in-manual-copy-impl-2.rs:5:19
    |
 LL | struct Wrapper<T>(T);
    |                   ^
diff --git a/tests/ui/suggestions/missing-bound-in-manual-copy-impl.fixed b/tests/ui/suggestions/missing-bound-in-manual-copy-impl.fixed
index 1139b315313..ff84e42c947 100644
--- a/tests/ui/suggestions/missing-bound-in-manual-copy-impl.fixed
+++ b/tests/ui/suggestions/missing-bound-in-manual-copy-impl.fixed
@@ -1,4 +1,5 @@
 // run-rustfix
+#![allow(dead_code)]
 
 #[derive(Clone)]
 struct Wrapper<T>(T);
diff --git a/tests/ui/suggestions/missing-bound-in-manual-copy-impl.rs b/tests/ui/suggestions/missing-bound-in-manual-copy-impl.rs
index 19549248efc..35d0a9dda79 100644
--- a/tests/ui/suggestions/missing-bound-in-manual-copy-impl.rs
+++ b/tests/ui/suggestions/missing-bound-in-manual-copy-impl.rs
@@ -1,4 +1,5 @@
 // run-rustfix
+#![allow(dead_code)]
 
 #[derive(Clone)]
 struct Wrapper<T>(T);
diff --git a/tests/ui/suggestions/missing-bound-in-manual-copy-impl.stderr b/tests/ui/suggestions/missing-bound-in-manual-copy-impl.stderr
index fd38d4c64b4..c9f277fb350 100644
--- a/tests/ui/suggestions/missing-bound-in-manual-copy-impl.stderr
+++ b/tests/ui/suggestions/missing-bound-in-manual-copy-impl.stderr
@@ -1,5 +1,5 @@
 error[E0204]: the trait `Copy` cannot be implemented for this type
-  --> $DIR/missing-bound-in-manual-copy-impl.rs:6:18
+  --> $DIR/missing-bound-in-manual-copy-impl.rs:7:18
    |
 LL | struct Wrapper<T>(T);
    |                   - this field does not implement `Copy`
diff --git a/tests/ui/suggestions/missing-trait-item.fixed b/tests/ui/suggestions/missing-trait-item.fixed
index a1cf359ec91..ded4ec19760 100644
--- a/tests/ui/suggestions/missing-trait-item.fixed
+++ b/tests/ui/suggestions/missing-trait-item.fixed
@@ -1,4 +1,5 @@
 // run-rustfix
+#![allow(dead_code)]
 
 trait T {
     unsafe fn foo(a: &usize, b: &usize) -> usize;
diff --git a/tests/ui/suggestions/missing-trait-item.rs b/tests/ui/suggestions/missing-trait-item.rs
index b4fca25ba2f..de8974037ac 100644
--- a/tests/ui/suggestions/missing-trait-item.rs
+++ b/tests/ui/suggestions/missing-trait-item.rs
@@ -1,4 +1,5 @@
 // run-rustfix
+#![allow(dead_code)]
 
 trait T {
     unsafe fn foo(a: &usize, b: &usize) -> usize;
diff --git a/tests/ui/suggestions/missing-trait-item.stderr b/tests/ui/suggestions/missing-trait-item.stderr
index 4a9d7b472c9..298d0d16438 100644
--- a/tests/ui/suggestions/missing-trait-item.stderr
+++ b/tests/ui/suggestions/missing-trait-item.stderr
@@ -1,5 +1,5 @@
 error[E0046]: not all trait items implemented, missing: `foo`, `bar`
-  --> $DIR/missing-trait-item.rs:10:5
+  --> $DIR/missing-trait-item.rs:11:5
    |
 LL |     unsafe fn foo(a: &usize, b: &usize) -> usize;
    |     --------------------------------------------- `foo` from trait
@@ -10,7 +10,7 @@ LL |     impl T for () {}
    |     ^^^^^^^^^^^^^ missing `foo`, `bar` in implementation
 
 error[E0046]: not all trait items implemented, missing: `foo`, `bar`
-  --> $DIR/missing-trait-item.rs:12:5
+  --> $DIR/missing-trait-item.rs:13:5
    |
 LL |     unsafe fn foo(a: &usize, b: &usize) -> usize;
    |     --------------------------------------------- `foo` from trait
diff --git a/tests/ui/threads-sendsync/sync-send-atomics.rs b/tests/ui/threads-sendsync/sync-send-atomics.rs
index 0466f4f0e9d..6b260311a50 100644
--- a/tests/ui/threads-sendsync/sync-send-atomics.rs
+++ b/tests/ui/threads-sendsync/sync-send-atomics.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 
 // pretty-expanded FIXME #23616
 
diff --git a/tests/ui/traits/alias/bounds.rs b/tests/ui/traits/alias/bounds.rs
index b97eb38c5af..7b1920bc8f2 100644
--- a/tests/ui/traits/alias/bounds.rs
+++ b/tests/ui/traits/alias/bounds.rs
@@ -4,7 +4,7 @@
 
 use std::marker::PhantomData;
 
-trait Empty {}
+trait Empty {} //~ WARN trait `Empty` is never used
 trait EmptyAlias = Empty;
 trait CloneDefault = Clone + Default;
 trait SendSyncAlias = Send + Sync;
diff --git a/tests/ui/traits/alias/bounds.stderr b/tests/ui/traits/alias/bounds.stderr
new file mode 100644
index 00000000000..7fb8e918da3
--- /dev/null
+++ b/tests/ui/traits/alias/bounds.stderr
@@ -0,0 +1,10 @@
+warning: trait `Empty` is never used
+  --> $DIR/bounds.rs:7:7
+   |
+LL | trait Empty {}
+   |       ^^^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/traits/alias/syntax.rs b/tests/ui/traits/alias/syntax.rs
index 17557a51aa7..50c77d33c6b 100644
--- a/tests/ui/traits/alias/syntax.rs
+++ b/tests/ui/traits/alias/syntax.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 
 #![feature(trait_alias)]
 
diff --git a/tests/ui/traits/bound/impl-comparison-duplicates.rs b/tests/ui/traits/bound/impl-comparison-duplicates.rs
index de6c2afa2bb..a59662c2797 100644
--- a/tests/ui/traits/bound/impl-comparison-duplicates.rs
+++ b/tests/ui/traits/bound/impl-comparison-duplicates.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 // Tests that type parameter bounds on an implementation need not match the
 // trait exactly, as long as the implementation doesn't demand *more* bounds
 // than the trait.
diff --git a/tests/ui/traits/bound/recursion.rs b/tests/ui/traits/bound/recursion.rs
index 0023ff654e8..767040dff3f 100644
--- a/tests/ui/traits/bound/recursion.rs
+++ b/tests/ui/traits/bound/recursion.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 // pretty-expanded FIXME #23616
 
 trait I { fn i(&self) -> Self; }
diff --git a/tests/ui/traits/composition-trivial.rs b/tests/ui/traits/composition-trivial.rs
index 90e5dcd68e8..41e6a556074 100644
--- a/tests/ui/traits/composition-trivial.rs
+++ b/tests/ui/traits/composition-trivial.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 // pretty-expanded FIXME #23616
 
 trait Foo {
diff --git a/tests/ui/traits/cycle-generic-bound.rs b/tests/ui/traits/cycle-generic-bound.rs
index 9241f3789d7..77685c26da2 100644
--- a/tests/ui/traits/cycle-generic-bound.rs
+++ b/tests/ui/traits/cycle-generic-bound.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 // Regression test for #15477. This test just needs to compile.
 
 // pretty-expanded FIXME #23616
diff --git a/tests/ui/traits/default-method/bound-subst4.rs b/tests/ui/traits/default-method/bound-subst4.rs
index ef133064582..6bc4cf0ef80 100644
--- a/tests/ui/traits/default-method/bound-subst4.rs
+++ b/tests/ui/traits/default-method/bound-subst4.rs
@@ -4,7 +4,7 @@
 
 trait A<T> {
     fn g(&self, x: usize) -> usize { x }
-    fn h(&self, x: T) { }
+    fn h(&self, x: T) { } //~ WARN method `h` is never used
 }
 
 impl<T> A<T> for isize { }
diff --git a/tests/ui/traits/default-method/bound-subst4.stderr b/tests/ui/traits/default-method/bound-subst4.stderr
new file mode 100644
index 00000000000..548c46f1233
--- /dev/null
+++ b/tests/ui/traits/default-method/bound-subst4.stderr
@@ -0,0 +1,13 @@
+warning: method `h` is never used
+  --> $DIR/bound-subst4.rs:7:8
+   |
+LL | trait A<T> {
+   |       - method in this trait
+LL |     fn g(&self, x: usize) -> usize { x }
+LL |     fn h(&self, x: T) { }
+   |        ^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/traits/default-method/mut.rs b/tests/ui/traits/default-method/mut.rs
index 5f8e983b09c..3294b96561f 100644
--- a/tests/ui/traits/default-method/mut.rs
+++ b/tests/ui/traits/default-method/mut.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 #![allow(unused_assignments)]
 // pretty-expanded FIXME #23616
 
diff --git a/tests/ui/traits/impl-inherent-prefer-over-trait.rs b/tests/ui/traits/impl-inherent-prefer-over-trait.rs
index 82760788897..f03e730d091 100644
--- a/tests/ui/traits/impl-inherent-prefer-over-trait.rs
+++ b/tests/ui/traits/impl-inherent-prefer-over-trait.rs
@@ -3,7 +3,7 @@
 struct Foo;
 
 trait Trait {
-    fn bar(&self);
+    fn bar(&self); //~ WARN method `bar` is never used
 }
 
 // Inherent impls should be preferred over trait ones.
diff --git a/tests/ui/traits/impl-inherent-prefer-over-trait.stderr b/tests/ui/traits/impl-inherent-prefer-over-trait.stderr
new file mode 100644
index 00000000000..f0bb21402d8
--- /dev/null
+++ b/tests/ui/traits/impl-inherent-prefer-over-trait.stderr
@@ -0,0 +1,12 @@
+warning: method `bar` is never used
+  --> $DIR/impl-inherent-prefer-over-trait.rs:6:8
+   |
+LL | trait Trait {
+   |       ----- method in this trait
+LL |     fn bar(&self);
+   |        ^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/traits/impl-object-overlap-issue-23853.rs b/tests/ui/traits/impl-object-overlap-issue-23853.rs
index e490967b690..c0d3af11443 100644
--- a/tests/ui/traits/impl-object-overlap-issue-23853.rs
+++ b/tests/ui/traits/impl-object-overlap-issue-23853.rs
@@ -5,7 +5,7 @@
 // including `Bar`, but the object type `Bar` also implicitly supplies
 // this context.
 
-trait Foo { fn dummy(&self) { } }
+trait Foo { fn dummy(&self) { } } //~ WARN method `dummy` is never used
 
 trait Bar: Foo { }
 
diff --git a/tests/ui/traits/impl-object-overlap-issue-23853.stderr b/tests/ui/traits/impl-object-overlap-issue-23853.stderr
new file mode 100644
index 00000000000..9fa7a36816e
--- /dev/null
+++ b/tests/ui/traits/impl-object-overlap-issue-23853.stderr
@@ -0,0 +1,12 @@
+warning: method `dummy` is never used
+  --> $DIR/impl-object-overlap-issue-23853.rs:8:16
+   |
+LL | trait Foo { fn dummy(&self) { } }
+   |       ---      ^^^^^
+   |       |
+   |       method in this trait
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/traits/impl.rs b/tests/ui/traits/impl.rs
index f512d91ebeb..7bec1b6c9ff 100644
--- a/tests/ui/traits/impl.rs
+++ b/tests/ui/traits/impl.rs
@@ -9,7 +9,7 @@ use traitimpl::Bar;
 static mut COUNT: usize = 1;
 
 trait T {
-    fn t(&self) {}
+    fn t(&self) {} //~ WARN method `t` is never used
 }
 
 impl<'a> dyn T+'a {
diff --git a/tests/ui/traits/impl.stderr b/tests/ui/traits/impl.stderr
new file mode 100644
index 00000000000..98b6fb03d83
--- /dev/null
+++ b/tests/ui/traits/impl.stderr
@@ -0,0 +1,12 @@
+warning: method `t` is never used
+  --> $DIR/impl.rs:12:8
+   |
+LL | trait T {
+   |       - method in this trait
+LL |     fn t(&self) {}
+   |        ^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/traits/issue-38033.rs b/tests/ui/traits/issue-38033.rs
index 16b867ec88f..4d76df1e8d5 100644
--- a/tests/ui/traits/issue-38033.rs
+++ b/tests/ui/traits/issue-38033.rs
@@ -19,7 +19,7 @@ trait IntoFuture {
     type Item;
     type Error;
 
-    fn into_future(self) -> Self::Future;
+    fn into_future(self) -> Self::Future; //~ WARN method `into_future` is never used
 }
 
 impl<F: Future> IntoFuture for F {
diff --git a/tests/ui/traits/issue-38033.stderr b/tests/ui/traits/issue-38033.stderr
new file mode 100644
index 00000000000..05385e8cf4d
--- /dev/null
+++ b/tests/ui/traits/issue-38033.stderr
@@ -0,0 +1,13 @@
+warning: method `into_future` is never used
+  --> $DIR/issue-38033.rs:22:8
+   |
+LL | trait IntoFuture {
+   |       ---------- method in this trait
+...
+LL |     fn into_future(self) -> Self::Future;
+   |        ^^^^^^^^^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/traits/issue-56488.rs b/tests/ui/traits/issue-56488.rs
index e2f3996927b..8b68f314c04 100644
--- a/tests/ui/traits/issue-56488.rs
+++ b/tests/ui/traits/issue-56488.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 
 #![feature(trait_alias)]
 
diff --git a/tests/ui/traits/issue-59029-2.rs b/tests/ui/traits/issue-59029-2.rs
index 2bdb128d8c4..fca9f1f13c9 100644
--- a/tests/ui/traits/issue-59029-2.rs
+++ b/tests/ui/traits/issue-59029-2.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 #![feature(trait_alias)]
 
 trait Svc<Req> { type Res; }
diff --git a/tests/ui/traits/issue-6128.rs b/tests/ui/traits/issue-6128.rs
index 07d92f8f8a0..f5fa0de809a 100644
--- a/tests/ui/traits/issue-6128.rs
+++ b/tests/ui/traits/issue-6128.rs
@@ -3,7 +3,7 @@
 use std::collections::HashMap;
 
 trait Graph<Node, Edge> {
-    fn f(&self, _: Edge);
+    fn f(&self, _: Edge); //~ WARN methods `f` and `g` are never used
     fn g(&self, _: Node);
 }
 
diff --git a/tests/ui/traits/issue-6128.stderr b/tests/ui/traits/issue-6128.stderr
new file mode 100644
index 00000000000..c9518ea41ea
--- /dev/null
+++ b/tests/ui/traits/issue-6128.stderr
@@ -0,0 +1,14 @@
+warning: methods `f` and `g` are never used
+  --> $DIR/issue-6128.rs:6:8
+   |
+LL | trait Graph<Node, Edge> {
+   |       ----- methods in this trait
+LL |     fn f(&self, _: Edge);
+   |        ^
+LL |     fn g(&self, _: Node);
+   |        ^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/traits/multidispatch-conditional-impl-not-considered.rs b/tests/ui/traits/multidispatch-conditional-impl-not-considered.rs
index f845e198aa5..e9ae8ab012a 100644
--- a/tests/ui/traits/multidispatch-conditional-impl-not-considered.rs
+++ b/tests/ui/traits/multidispatch-conditional-impl-not-considered.rs
@@ -6,7 +6,7 @@
 
 use std::cell::RefCell;
 
-trait Foo {
+trait Foo { //~ WARN trait `Foo` is never used
     fn foo(&self) {}
 }
 
diff --git a/tests/ui/traits/multidispatch-conditional-impl-not-considered.stderr b/tests/ui/traits/multidispatch-conditional-impl-not-considered.stderr
new file mode 100644
index 00000000000..25313a477f7
--- /dev/null
+++ b/tests/ui/traits/multidispatch-conditional-impl-not-considered.stderr
@@ -0,0 +1,10 @@
+warning: trait `Foo` is never used
+  --> $DIR/multidispatch-conditional-impl-not-considered.rs:9:7
+   |
+LL | trait Foo {
+   |       ^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/traits/multidispatch-infer-convert-target.rs b/tests/ui/traits/multidispatch-infer-convert-target.rs
index 626e1ae71bc..a3653dea2cb 100644
--- a/tests/ui/traits/multidispatch-infer-convert-target.rs
+++ b/tests/ui/traits/multidispatch-infer-convert-target.rs
@@ -5,7 +5,7 @@
 use std::mem;
 
 trait Convert<Target> {
-    fn convert(&self) -> Target;
+    fn convert(&self) -> Target; //~ WARN method `convert` is never used
 }
 
 impl Convert<u32> for i16 {
diff --git a/tests/ui/traits/multidispatch-infer-convert-target.stderr b/tests/ui/traits/multidispatch-infer-convert-target.stderr
new file mode 100644
index 00000000000..c8c1b642719
--- /dev/null
+++ b/tests/ui/traits/multidispatch-infer-convert-target.stderr
@@ -0,0 +1,12 @@
+warning: method `convert` is never used
+  --> $DIR/multidispatch-infer-convert-target.rs:8:8
+   |
+LL | trait Convert<Target> {
+   |       ------- method in this trait
+LL |     fn convert(&self) -> Target;
+   |        ^^^^^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/traits/negative-impls/negative-specializes-negative.rs b/tests/ui/traits/negative-impls/negative-specializes-negative.rs
index 35297ab124e..01829e41301 100644
--- a/tests/ui/traits/negative-impls/negative-specializes-negative.rs
+++ b/tests/ui/traits/negative-impls/negative-specializes-negative.rs
@@ -3,7 +3,7 @@
 
 // Test a negative impl that "specializes" another negative impl.
 //
-// run-pass
+// check-pass
 
 trait MyTrait {}
 
diff --git a/tests/ui/traits/trait-upcasting/lifetime.rs b/tests/ui/traits/trait-upcasting/lifetime.rs
index 9825158c2dd..6486ec3891c 100644
--- a/tests/ui/traits/trait-upcasting/lifetime.rs
+++ b/tests/ui/traits/trait-upcasting/lifetime.rs
@@ -7,7 +7,7 @@ trait Foo: PartialEq<i32> + std::fmt::Debug + Send + Sync {
         10
     }
 
-    fn z(&self) -> i32 {
+    fn z(&self) -> i32 { //~ WARN methods `z` and `y` are never used
         11
     }
 
@@ -21,7 +21,7 @@ trait Bar: Foo {
         20
     }
 
-    fn w(&self) -> i32 {
+    fn w(&self) -> i32 { //~ WARN method `w` is never used
         21
     }
 }
diff --git a/tests/ui/traits/trait-upcasting/lifetime.stderr b/tests/ui/traits/trait-upcasting/lifetime.stderr
new file mode 100644
index 00000000000..ca8f9cf63f3
--- /dev/null
+++ b/tests/ui/traits/trait-upcasting/lifetime.stderr
@@ -0,0 +1,25 @@
+warning: methods `z` and `y` are never used
+  --> $DIR/lifetime.rs:10:8
+   |
+LL | trait Foo: PartialEq<i32> + std::fmt::Debug + Send + Sync {
+   |       --- methods in this trait
+...
+LL |     fn z(&self) -> i32 {
+   |        ^
+...
+LL |     fn y(&self) -> i32 {
+   |        ^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: method `w` is never used
+  --> $DIR/lifetime.rs:24:8
+   |
+LL | trait Bar: Foo {
+   |       --- method in this trait
+...
+LL |     fn w(&self) -> i32 {
+   |        ^
+
+warning: 2 warnings emitted
+
diff --git a/tests/ui/traits/trait-upcasting/replace-vptr.rs b/tests/ui/traits/trait-upcasting/replace-vptr.rs
index 9ccfc9306ac..5ef65786bb7 100644
--- a/tests/ui/traits/trait-upcasting/replace-vptr.rs
+++ b/tests/ui/traits/trait-upcasting/replace-vptr.rs
@@ -3,7 +3,7 @@
 #![feature(trait_upcasting)]
 
 trait A {
-    fn foo_a(&self);
+    fn foo_a(&self); //~ WARN method `foo_a` is never used
 }
 
 trait B {
@@ -11,7 +11,7 @@ trait B {
 }
 
 trait C: A + B {
-    fn foo_c(&self);
+    fn foo_c(&self); //~ WARN method `foo_c` is never used
 }
 
 struct S(i32);
diff --git a/tests/ui/traits/trait-upcasting/replace-vptr.stderr b/tests/ui/traits/trait-upcasting/replace-vptr.stderr
new file mode 100644
index 00000000000..823094761b3
--- /dev/null
+++ b/tests/ui/traits/trait-upcasting/replace-vptr.stderr
@@ -0,0 +1,20 @@
+warning: method `foo_a` is never used
+  --> $DIR/replace-vptr.rs:6:8
+   |
+LL | trait A {
+   |       - method in this trait
+LL |     fn foo_a(&self);
+   |        ^^^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: method `foo_c` is never used
+  --> $DIR/replace-vptr.rs:14:8
+   |
+LL | trait C: A + B {
+   |       - method in this trait
+LL |     fn foo_c(&self);
+   |        ^^^^^
+
+warning: 2 warnings emitted
+
diff --git a/tests/ui/traits/use-before-def.rs b/tests/ui/traits/use-before-def.rs
index 1ee2b941909..e52dc53fbab 100644
--- a/tests/ui/traits/use-before-def.rs
+++ b/tests/ui/traits/use-before-def.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 #![allow(non_camel_case_types)]
 
 // Issue #1761
diff --git a/tests/ui/traits/wf-object/reverse-order.rs b/tests/ui/traits/wf-object/reverse-order.rs
index 74b2ef48533..e90c8763d65 100644
--- a/tests/ui/traits/wf-object/reverse-order.rs
+++ b/tests/ui/traits/wf-object/reverse-order.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 
 // Ensure that `dyn $($AutoTrait)+ ObjSafe` is well-formed.
 
diff --git a/tests/ui/trivial_casts-rpass.rs b/tests/ui/trivial_casts-rpass.rs
index 8e49468bf0c..4653a8df802 100644
--- a/tests/ui/trivial_casts-rpass.rs
+++ b/tests/ui/trivial_casts-rpass.rs
@@ -4,7 +4,7 @@
 #![allow(trivial_casts, trivial_numeric_casts)]
 
 trait Foo {
-    fn foo(&self) {}
+    fn foo(&self) {} //~ WARN method `foo` is never used
 }
 
 pub struct Bar;
diff --git a/tests/ui/trivial_casts-rpass.stderr b/tests/ui/trivial_casts-rpass.stderr
new file mode 100644
index 00000000000..74698b61ab4
--- /dev/null
+++ b/tests/ui/trivial_casts-rpass.stderr
@@ -0,0 +1,12 @@
+warning: method `foo` is never used
+  --> $DIR/trivial_casts-rpass.rs:7:8
+   |
+LL | trait Foo {
+   |       --- method in this trait
+LL |     fn foo(&self) {}
+   |        ^^^
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/type-alias-impl-trait/issue-58887.rs b/tests/ui/type-alias-impl-trait/issue-58887.rs
index 9675867656a..68d85ed6b0f 100644
--- a/tests/ui/type-alias-impl-trait/issue-58887.rs
+++ b/tests/ui/type-alias-impl-trait/issue-58887.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 
 #![feature(impl_trait_in_assoc_type)]
 
diff --git a/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2015.fixed b/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2015.fixed
index 5be6ff8e7e1..700e4f25423 100644
--- a/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2015.fixed
+++ b/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2015.fixed
@@ -1,4 +1,5 @@
 // run-rustfix
+#![allow(dead_code)]
 
 trait WithType<T> {}
 trait WithRegion<'a> { }
diff --git a/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2015.rs b/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2015.rs
index d7072aa1181..66ba9b24dac 100644
--- a/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2015.rs
+++ b/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2015.rs
@@ -1,4 +1,5 @@
 // run-rustfix
+#![allow(dead_code)]
 
 trait WithType<T> {}
 trait WithRegion<'a> { }
diff --git a/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2015.stderr b/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2015.stderr
index 54e62f34fba..f012120e550 100644
--- a/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2015.stderr
+++ b/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2015.stderr
@@ -1,5 +1,5 @@
 error[E0637]: `&` without an explicit lifetime name cannot be used here
-  --> $DIR/where-clause-inherent-impl-ampersand-rust2015.rs:13:17
+  --> $DIR/where-clause-inherent-impl-ampersand-rust2015.rs:14:17
    |
 LL |     T: WithType<&u32>
    |                 ^ explicit lifetime name needed here
diff --git a/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2018.fixed b/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2018.fixed
index 0f1be586589..56682db3b0b 100644
--- a/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2018.fixed
+++ b/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2018.fixed
@@ -1,5 +1,6 @@
 // edition:2018
 // run-rustfix
+#![allow(dead_code)]
 
 trait WithType<T> {}
 trait WithRegion<'a> { }
diff --git a/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2018.rs b/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2018.rs
index 59f7e472e2d..5302b2f1576 100644
--- a/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2018.rs
+++ b/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2018.rs
@@ -1,5 +1,6 @@
 // edition:2018
 // run-rustfix
+#![allow(dead_code)]
 
 trait WithType<T> {}
 trait WithRegion<'a> { }
diff --git a/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2018.stderr b/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2018.stderr
index 36f3e9ef145..7d675dd41e9 100644
--- a/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2018.stderr
+++ b/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2018.stderr
@@ -1,5 +1,5 @@
 error[E0637]: `&` without an explicit lifetime name cannot be used here
-  --> $DIR/where-clause-inherent-impl-ampersand-rust2018.rs:14:17
+  --> $DIR/where-clause-inherent-impl-ampersand-rust2018.rs:15:17
    |
 LL |     T: WithType<&u32>
    |                 ^ explicit lifetime name needed here
diff --git a/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2015.fixed b/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2015.fixed
index 55c7470960e..f3adc7e7fad 100644
--- a/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2015.fixed
+++ b/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2015.fixed
@@ -1,4 +1,5 @@
 // run-rustfix
+#![allow(dead_code)]
 
 trait WithType<T> {}
 trait WithRegion<'a> { }
diff --git a/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2015.rs b/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2015.rs
index 42a35b02161..1e084e9ad41 100644
--- a/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2015.rs
+++ b/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2015.rs
@@ -1,4 +1,5 @@
 // run-rustfix
+#![allow(dead_code)]
 
 trait WithType<T> {}
 trait WithRegion<'a> { }
diff --git a/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2015.stderr b/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2015.stderr
index 92b7a9c2af8..8aa0e52c688 100644
--- a/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2015.stderr
+++ b/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2015.stderr
@@ -1,5 +1,5 @@
 error[E0637]: `&` without an explicit lifetime name cannot be used here
-  --> $DIR/where-clause-trait-impl-region-2015.rs:10:17
+  --> $DIR/where-clause-trait-impl-region-2015.rs:11:17
    |
 LL |     T: WithType<&u32>
    |                 ^ explicit lifetime name needed here
diff --git a/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2018.fixed b/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2018.fixed
index 09b96fe5ea4..dd8074abed7 100644
--- a/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2018.fixed
+++ b/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2018.fixed
@@ -1,6 +1,8 @@
 // run-rustfix
 // edition:2018
 
+#![allow(dead_code)]
+
 trait WithType<T> {}
 trait WithRegion<'a> { }
 
diff --git a/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2018.rs b/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2018.rs
index 445f38cbee1..4fc9c71b179 100644
--- a/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2018.rs
+++ b/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2018.rs
@@ -1,6 +1,8 @@
 // run-rustfix
 // edition:2018
 
+#![allow(dead_code)]
+
 trait WithType<T> {}
 trait WithRegion<'a> { }
 
diff --git a/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2018.stderr b/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2018.stderr
index 63d8b99ed18..22940d0b0b1 100644
--- a/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2018.stderr
+++ b/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2018.stderr
@@ -1,5 +1,5 @@
 error[E0637]: `&` without an explicit lifetime name cannot be used here
-  --> $DIR/where-clause-trait-impl-region-2018.rs:11:17
+  --> $DIR/where-clause-trait-impl-region-2018.rs:13:17
    |
 LL |     T: WithType<&u32>
    |                 ^ explicit lifetime name needed here
diff --git a/tests/ui/where-clauses/issue-50825-1.rs b/tests/ui/where-clauses/issue-50825-1.rs
index ee4316029a8..2ee34ad714e 100644
--- a/tests/ui/where-clauses/issue-50825-1.rs
+++ b/tests/ui/where-clauses/issue-50825-1.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 // regression test for issue #50825
 // Make sure that the `impl` bound (): X<T = ()> is preferred over
 // the (): X bound in the where clause.
diff --git a/tests/ui/where-clauses/where-clause-bounds-inconsistency.rs b/tests/ui/where-clauses/where-clause-bounds-inconsistency.rs
index ea60fa70876..65fd2f3096c 100644
--- a/tests/ui/where-clauses/where-clause-bounds-inconsistency.rs
+++ b/tests/ui/where-clauses/where-clause-bounds-inconsistency.rs
@@ -1,4 +1,4 @@
-// run-pass
+// check-pass
 // pretty-expanded FIXME #23616
 
 trait Bound {
diff --git a/tests/ui/where-clauses/where-clause-early-bound-lifetimes.rs b/tests/ui/where-clauses/where-clause-early-bound-lifetimes.rs
index 6fc570b9b5b..a7ce0590fcd 100644
--- a/tests/ui/where-clauses/where-clause-early-bound-lifetimes.rs
+++ b/tests/ui/where-clauses/where-clause-early-bound-lifetimes.rs
@@ -3,7 +3,7 @@
 
 // pretty-expanded FIXME #23616
 
-trait TheTrait { fn dummy(&self) { } }
+trait TheTrait { fn dummy(&self) { } } //~ WARN method `dummy` is never used
 
 impl TheTrait for &'static isize { }
 
diff --git a/tests/ui/where-clauses/where-clause-early-bound-lifetimes.stderr b/tests/ui/where-clauses/where-clause-early-bound-lifetimes.stderr
new file mode 100644
index 00000000000..a9fe11ea6b3
--- /dev/null
+++ b/tests/ui/where-clauses/where-clause-early-bound-lifetimes.stderr
@@ -0,0 +1,12 @@
+warning: method `dummy` is never used
+  --> $DIR/where-clause-early-bound-lifetimes.rs:6:21
+   |
+LL | trait TheTrait { fn dummy(&self) { } }
+   |       --------      ^^^^^
+   |       |
+   |       method in this trait
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/where-clauses/where-clause-method-substituion-rpass.rs b/tests/ui/where-clauses/where-clause-method-substituion-rpass.rs
index daa3c8dd8e3..8f9c6fbff3d 100644
--- a/tests/ui/where-clauses/where-clause-method-substituion-rpass.rs
+++ b/tests/ui/where-clauses/where-clause-method-substituion-rpass.rs
@@ -2,7 +2,7 @@
 #![allow(unused_variables)]
 // pretty-expanded FIXME #23616
 
-trait Foo<T> { fn dummy(&self, arg: T) { } }
+trait Foo<T> { fn dummy(&self, arg: T) { } } //~ WARN method `dummy` is never used
 
 trait Bar<A> {
     fn method<B>(&self) where A: Foo<B>;
diff --git a/tests/ui/where-clauses/where-clause-method-substituion-rpass.stderr b/tests/ui/where-clauses/where-clause-method-substituion-rpass.stderr
new file mode 100644
index 00000000000..0d09cb9de3f
--- /dev/null
+++ b/tests/ui/where-clauses/where-clause-method-substituion-rpass.stderr
@@ -0,0 +1,12 @@
+warning: method `dummy` is never used
+  --> $DIR/where-clause-method-substituion-rpass.rs:5:19
+   |
+LL | trait Foo<T> { fn dummy(&self, arg: T) { } }
+   |       ---         ^^^^^
+   |       |
+   |       method in this trait
+   |
+   = note: `#[warn(dead_code)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.fixed b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.fixed
index 2f47c0d91fa..4e1aa59aac0 100644
--- a/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.fixed
+++ b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.fixed
@@ -1,6 +1,8 @@
 // check-pass
 // run-rustfix
 
+#![allow(dead_code)]
+
 trait Trait {
     // Fine.
     type Assoc where u32: Copy;
diff --git a/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.rs b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.rs
index b20aa9398b5..05b2f8c82a4 100644
--- a/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.rs
+++ b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.rs
@@ -1,6 +1,8 @@
 // check-pass
 // run-rustfix
 
+#![allow(dead_code)]
+
 trait Trait {
     // Fine.
     type Assoc where u32: Copy;
diff --git a/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.stderr b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.stderr
index b4de051845f..6ff9d2dd73b 100644
--- a/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.stderr
+++ b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.stderr
@@ -1,5 +1,5 @@
 warning: where clause not allowed here
-  --> $DIR/where-clause-placement-assoc-type-in-impl.rs:13:16
+  --> $DIR/where-clause-placement-assoc-type-in-impl.rs:15:16
    |
 LL |     type Assoc where u32: Copy = ();
    |                ^^^^^^^^^^^^^^^
@@ -13,7 +13,7 @@ LL +     type Assoc  = () where u32: Copy;
    |
 
 warning: where clause not allowed here
-  --> $DIR/where-clause-placement-assoc-type-in-impl.rs:16:17
+  --> $DIR/where-clause-placement-assoc-type-in-impl.rs:18:17
    |
 LL |     type Assoc2 where u32: Copy = () where i32: Copy;
    |                 ^^^^^^^^^^^^^^^
@@ -26,7 +26,7 @@ LL +     type Assoc2  = () where i32: Copy, u32: Copy;
    |
 
 warning: where clause not allowed here
-  --> $DIR/where-clause-placement-assoc-type-in-impl.rs:24:17
+  --> $DIR/where-clause-placement-assoc-type-in-impl.rs:26:17
    |
 LL |     type Assoc2 where u32: Copy, i32: Copy = ();
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.fixed b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.fixed
index d171eba50b7..940e2cc8e97 100644
--- a/tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.fixed
+++ b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.fixed
@@ -1,6 +1,7 @@
 // check-pass
 // run-rustfix
 
+#![allow(dead_code)]
 #![feature(associated_type_defaults)]
 
 trait Trait {
diff --git a/tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.rs b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.rs
index 59afee65794..7001a9245a5 100644
--- a/tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.rs
+++ b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.rs
@@ -1,6 +1,7 @@
 // check-pass
 // run-rustfix
 
+#![allow(dead_code)]
 #![feature(associated_type_defaults)]
 
 trait Trait {
diff --git a/tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.stderr b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.stderr
index a81cb8c8cd6..9e9967ef739 100644
--- a/tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.stderr
+++ b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.stderr
@@ -1,5 +1,5 @@
 warning: where clause not allowed here
-  --> $DIR/where-clause-placement-assoc-type-in-trait.rs:8:16
+  --> $DIR/where-clause-placement-assoc-type-in-trait.rs:9:16
    |
 LL |     type Assoc where u32: Copy = ();
    |                ^^^^^^^^^^^^^^^
@@ -13,7 +13,7 @@ LL +     type Assoc  = () where u32: Copy;
    |
 
 warning: where clause not allowed here
-  --> $DIR/where-clause-placement-assoc-type-in-trait.rs:11:17
+  --> $DIR/where-clause-placement-assoc-type-in-trait.rs:12:17
    |
 LL |     type Assoc2 where u32: Copy = () where i32: Copy;
    |                 ^^^^^^^^^^^^^^^