about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--.git-blame-ignore-revs2
-rw-r--r--compiler/rustc_borrowck/src/diagnostics/region_errors.rs2
-rw-r--r--compiler/rustc_error_messages/locales/en-US/passes.ftl3
-rw-r--r--compiler/rustc_hir_analysis/src/check/wfcheck.rs15
-rw-r--r--compiler/rustc_hir_analysis/src/hir_wf_check.rs46
-rw-r--r--compiler/rustc_infer/src/infer/error_reporting/mod.rs4
-rw-r--r--compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs10
-rw-r--r--compiler/rustc_middle/src/ty/sty.rs2
-rw-r--r--compiler/rustc_middle/src/ty/subst.rs2
-rw-r--r--compiler/rustc_passes/src/check_attr.rs11
-rw-r--r--compiler/rustc_passes/src/errors.rs7
-rw-r--r--compiler/rustc_resolve/src/diagnostics.rs2
-rw-r--r--compiler/rustc_resolve/src/late/diagnostics.rs6
-rw-r--r--compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs7
-rw-r--r--src/tools/clippy/tests/ui/crashes/ice-6252.stderr9
-rw-r--r--tests/ui/builtin-superkinds/builtin-superkinds-double-superkind.stderr8
-rw-r--r--tests/ui/builtin-superkinds/builtin-superkinds-in-metadata.stderr4
-rw-r--r--tests/ui/builtin-superkinds/builtin-superkinds-simple.stderr4
-rw-r--r--tests/ui/builtin-superkinds/builtin-superkinds-typaram-not-send.stderr4
-rw-r--r--tests/ui/chalkify/impl_wf.stderr8
-rw-r--r--tests/ui/coherence/coherence-overlap-trait-alias.stderr4
-rw-r--r--tests/ui/dst/dst-sized-trait-param.stderr4
-rw-r--r--tests/ui/error-codes/E0308-2.stderr4
-rw-r--r--tests/ui/functions-closures/fn-help-with-err-generic-is-not-function.stderr9
-rw-r--r--tests/ui/issues/issue-58712.stderr9
-rw-r--r--tests/ui/issues/issue-65230.stderr4
-rw-r--r--tests/ui/issues/issue-77919.stderr9
-rw-r--r--tests/ui/issues/issue-86756.stderr2
-rw-r--r--tests/ui/marker_trait_attr/overlap-marker-trait-with-underscore-lifetime.stderr8
-rw-r--r--tests/ui/marker_trait_attr/region-overlap.stderr8
-rw-r--r--tests/ui/parser/dyn-trait-compatibility.stderr12
-rw-r--r--tests/ui/rfc-2397-do-not-recommend/incorrect-locations.rs45
-rw-r--r--tests/ui/rfc-2397-do-not-recommend/incorrect-locations.stderr50
-rw-r--r--tests/ui/rfc-2397-do-not-recommend/unstable-feature.rs5
-rw-r--r--tests/ui/rfc-2397-do-not-recommend/unstable-feature.stderr2
-rw-r--r--tests/ui/rfc-2632-const-trait-impl/super-traits-fail.stderr8
-rw-r--r--tests/ui/span/issue-71363.stderr8
-rw-r--r--tests/ui/specialization/min_specialization/issue-79224.stderr4
-rw-r--r--tests/ui/suggestions/type-not-found-in-adt-field.stderr7
-rw-r--r--tests/ui/trait-bounds/unsized-bound.stderr28
-rw-r--r--tests/ui/traits/ignore-err-impls.stderr9
-rw-r--r--tests/ui/traits/impl-bounds-checking.stderr4
-rw-r--r--tests/ui/traits/impl-of-supertrait-has-wrong-lifetime-parameters.stderr8
-rw-r--r--tests/ui/traits/issue-43784-supertrait.stderr4
-rw-r--r--tests/ui/traits/issue-50480.stderr27
-rw-r--r--tests/ui/traits/issue-75627.stderr9
-rw-r--r--tests/ui/traits/issue-78372.stderr9
-rw-r--r--tests/ui/traits/issue-91594.stderr4
-rw-r--r--tests/ui/transmutability/malformed-program-gracefulness/unknown_dst.stderr8
-rw-r--r--tests/ui/transmutability/malformed-program-gracefulness/unknown_src.stderr8
-rw-r--r--tests/ui/typeck/autoderef-with-param-env-error.stderr8
-rw-r--r--tests/ui/typeck/issue-104513-ice.stderr7
52 files changed, 338 insertions, 153 deletions
diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs
index 71adf9b0091..d20f19e60e8 100644
--- a/.git-blame-ignore-revs
+++ b/.git-blame-ignore-revs
@@ -8,3 +8,5 @@ a06baa56b95674fc626b3c3fd680d6a65357fe60
 283abbf0e7d20176f76006825b5c52e9a4234e4c
 # format libstd/sys
 c34fbfaad38cf5829ef5cfe780dc9d58480adeaa
+# move tests
+cf2dff2b1e3fa55fa5415d524200070d0d7aacfe
diff --git a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs
index e8a4d1c37c1..f3050a6ef3f 100644
--- a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs
@@ -79,7 +79,7 @@ impl<'tcx> RegionErrors<'tcx> {
     #[track_caller]
     pub fn push(&mut self, val: impl Into<RegionErrorKind<'tcx>>) {
         let val = val.into();
-        self.1.sess.delay_span_bug(DUMMY_SP, "{val:?}");
+        self.1.sess.delay_span_bug(DUMMY_SP, format!("{val:?}"));
         self.0.push(val);
     }
     pub fn is_empty(&self) -> bool {
diff --git a/compiler/rustc_error_messages/locales/en-US/passes.ftl b/compiler/rustc_error_messages/locales/en-US/passes.ftl
index 001e53d1d0e..91857dd227d 100644
--- a/compiler/rustc_error_messages/locales/en-US/passes.ftl
+++ b/compiler/rustc_error_messages/locales/en-US/passes.ftl
@@ -4,6 +4,9 @@
 -passes_see_issue =
     see issue #{$issue} <https://github.com/rust-lang/rust/issues/{$issue}> for more information
 
+passes_incorrect_do_not_recommend_location =
+    `#[do_not_recommend]` can only be placed on trait implementations
+
 passes_outer_crate_level_attr =
     crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
 
diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs
index d1f4dbc8d84..92fd4625ee8 100644
--- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs
+++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs
@@ -1254,7 +1254,11 @@ fn check_impl<'tcx>(
                 // therefore don't need to be WF (the trait's `Self: Trait` predicate
                 // won't hold).
                 let trait_ref = tcx.impl_trait_ref(item.owner_id).unwrap();
-                let trait_ref = wfcx.normalize(ast_trait_ref.path.span, None, trait_ref);
+                let trait_ref = wfcx.normalize(
+                    ast_trait_ref.path.span,
+                    Some(WellFormedLoc::Ty(item.hir_id().expect_owner().def_id)),
+                    trait_ref,
+                );
                 let trait_pred = ty::TraitPredicate {
                     trait_ref,
                     constness: match constness {
@@ -1263,7 +1267,7 @@ fn check_impl<'tcx>(
                     },
                     polarity: ty::ImplPolarity::Positive,
                 };
-                let obligations = traits::wf::trait_obligations(
+                let mut obligations = traits::wf::trait_obligations(
                     wfcx.infcx,
                     wfcx.param_env,
                     wfcx.body_id,
@@ -1271,6 +1275,13 @@ fn check_impl<'tcx>(
                     ast_trait_ref.path.span,
                     item,
                 );
+                for obligation in &mut obligations {
+                    if let Some(pred) = obligation.predicate.to_opt_poly_trait_pred()
+                        && pred.self_ty().skip_binder() == trait_ref.self_ty()
+                    {
+                        obligation.cause.span = ast_self_ty.span;
+                    }
+                }
                 debug!(?obligations);
                 wfcx.register_obligations(obligations);
             }
diff --git a/compiler/rustc_hir_analysis/src/hir_wf_check.rs b/compiler/rustc_hir_analysis/src/hir_wf_check.rs
index 4f9d5826583..2dbfc1bc9a2 100644
--- a/compiler/rustc_hir_analysis/src/hir_wf_check.rs
+++ b/compiler/rustc_hir_analysis/src/hir_wf_check.rs
@@ -114,34 +114,46 @@ fn diagnostic_hir_wf_check<'tcx>(
     // Get the starting `hir::Ty` using our `WellFormedLoc`.
     // We will walk 'into' this type to try to find
     // a more precise span for our predicate.
-    let ty = match loc {
+    let tys = match loc {
         WellFormedLoc::Ty(_) => match hir.get(hir_id) {
             hir::Node::ImplItem(item) => match item.kind {
-                hir::ImplItemKind::Type(ty) => Some(ty),
-                hir::ImplItemKind::Const(ty, _) => Some(ty),
+                hir::ImplItemKind::Type(ty) => vec![ty],
+                hir::ImplItemKind::Const(ty, _) => vec![ty],
                 ref item => bug!("Unexpected ImplItem {:?}", item),
             },
             hir::Node::TraitItem(item) => match item.kind {
-                hir::TraitItemKind::Type(_, ty) => ty,
-                hir::TraitItemKind::Const(ty, _) => Some(ty),
+                hir::TraitItemKind::Type(_, ty) => ty.into_iter().collect(),
+                hir::TraitItemKind::Const(ty, _) => vec![ty],
                 ref item => bug!("Unexpected TraitItem {:?}", item),
             },
             hir::Node::Item(item) => match item.kind {
-                hir::ItemKind::Static(ty, _, _) | hir::ItemKind::Const(ty, _) => Some(ty),
-                hir::ItemKind::Impl(ref impl_) => {
-                    assert!(impl_.of_trait.is_none(), "Unexpected trait impl: {:?}", impl_);
-                    Some(impl_.self_ty)
-                }
+                hir::ItemKind::Static(ty, _, _) | hir::ItemKind::Const(ty, _) => vec![ty],
+                hir::ItemKind::Impl(ref impl_) => match &impl_.of_trait {
+                    Some(t) => t
+                        .path
+                        .segments
+                        .last()
+                        .iter()
+                        .flat_map(|seg| seg.args().args)
+                        .filter_map(|arg| {
+                            if let hir::GenericArg::Type(ty) = arg { Some(*ty) } else { None }
+                        })
+                        .chain([impl_.self_ty])
+                        .collect(),
+                    None => {
+                        vec![impl_.self_ty]
+                    }
+                },
                 ref item => bug!("Unexpected item {:?}", item),
             },
-            hir::Node::Field(field) => Some(field.ty),
+            hir::Node::Field(field) => vec![field.ty],
             hir::Node::ForeignItem(ForeignItem {
                 kind: ForeignItemKind::Static(ty, _), ..
-            }) => Some(*ty),
+            }) => vec![*ty],
             hir::Node::GenericParam(hir::GenericParam {
                 kind: hir::GenericParamKind::Type { default: Some(ty), .. },
                 ..
-            }) => Some(*ty),
+            }) => vec![*ty],
             ref node => bug!("Unexpected node {:?}", node),
         },
         WellFormedLoc::Param { function: _, param_idx } => {
@@ -149,16 +161,16 @@ fn diagnostic_hir_wf_check<'tcx>(
             // Get return type
             if param_idx as usize == fn_decl.inputs.len() {
                 match fn_decl.output {
-                    hir::FnRetTy::Return(ty) => Some(ty),
+                    hir::FnRetTy::Return(ty) => vec![ty],
                     // The unit type `()` is always well-formed
-                    hir::FnRetTy::DefaultReturn(_span) => None,
+                    hir::FnRetTy::DefaultReturn(_span) => vec![],
                 }
             } else {
-                Some(&fn_decl.inputs[param_idx as usize])
+                vec![&fn_decl.inputs[param_idx as usize]]
             }
         }
     };
-    if let Some(ty) = ty {
+    for ty in tys {
         visitor.visit_ty(ty);
     }
     visitor.cause
diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs
index 080ae6b9466..533a3c768eb 100644
--- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs
+++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs
@@ -1782,9 +1782,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
                             // like when you have two references but one is `usize` and the other
                             // is `f32`. In those cases we still want to show the `note`. If the
                             // value from `ef` is `Infer(_)`, then we ignore it.
-                            if !ef.expected.is_ty_infer() {
+                            if !ef.expected.is_ty_or_numeric_infer() {
                                 ef.expected != values.expected
-                            } else if !ef.found.is_ty_infer() {
+                            } else if !ef.found.is_ty_or_numeric_infer() {
                                 ef.found != values.found
                             } else {
                                 false
diff --git a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs
index a4c36b4c9cd..b8c843a8a5a 100644
--- a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs
+++ b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs
@@ -78,7 +78,7 @@ impl InferenceDiagnosticsData {
     }
 
     fn where_x_is_kind(&self, in_type: Ty<'_>) -> &'static str {
-        if in_type.is_ty_infer() {
+        if in_type.is_ty_or_numeric_infer() {
             ""
         } else if self.name == "_" {
             // FIXME: Consider specializing this message if there is a single `_`
@@ -195,12 +195,12 @@ fn ty_to_string<'tcx>(
         // invalid pseudo-syntax, we want the `fn`-pointer output instead.
         (ty::FnDef(..), _) => ty.fn_sig(infcx.tcx).print(printer).unwrap().into_buffer(),
         (_, Some(def_id))
-            if ty.is_ty_infer()
+            if ty.is_ty_or_numeric_infer()
                 && infcx.tcx.get_diagnostic_item(sym::iterator_collect_fn) == Some(def_id) =>
         {
             "Vec<_>".to_string()
         }
-        _ if ty.is_ty_infer() => "/* Type */".to_string(),
+        _ if ty.is_ty_or_numeric_infer() => "/* Type */".to_string(),
         // FIXME: The same thing for closures, but this only works when the closure
         // does not capture anything.
         //
@@ -680,7 +680,7 @@ impl<'tcx> InferSourceKind<'tcx> {
             | InferSourceKind::ClosureReturn { ty, .. } => {
                 if ty.is_closure() {
                     ("closure", closure_as_fn_str(infcx, ty))
-                } else if !ty.is_ty_infer() {
+                } else if !ty.is_ty_or_numeric_infer() {
                     ("normal", ty_to_string(infcx, ty, None))
                 } else {
                     ("other", String::new())
@@ -813,7 +813,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
         self.attempt += 1;
         if let Some(InferSource { kind: InferSourceKind::GenericArg { def_id: did, ..}, .. }) = self.infer_source
             && let InferSourceKind::LetBinding { ref ty, ref mut def_id, ..} = new_source.kind
-            && ty.is_ty_infer()
+            && ty.is_ty_or_numeric_infer()
         {
             // Customize the output so we talk about `let x: Vec<_> = iter.collect();` instead of
             // `let x: _ = iter.collect();`, as this is a very common case.
diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs
index f7e4c821569..bd5b04d5b2b 100644
--- a/compiler/rustc_middle/src/ty/sty.rs
+++ b/compiler/rustc_middle/src/ty/sty.rs
@@ -1686,7 +1686,7 @@ impl<'tcx> Ty<'tcx> {
     }
 
     #[inline]
-    pub fn is_ty_infer(self) -> bool {
+    pub fn is_ty_or_numeric_infer(self) -> bool {
         matches!(self.kind(), Infer(_))
     }
 
diff --git a/compiler/rustc_middle/src/ty/subst.rs b/compiler/rustc_middle/src/ty/subst.rs
index 0c33e5bda1a..2dec58ea82a 100644
--- a/compiler/rustc_middle/src/ty/subst.rs
+++ b/compiler/rustc_middle/src/ty/subst.rs
@@ -202,7 +202,7 @@ impl<'tcx> GenericArg<'tcx> {
     pub fn is_non_region_infer(self) -> bool {
         match self.unpack() {
             GenericArgKind::Lifetime(_) => false,
-            GenericArgKind::Type(ty) => ty.is_ty_infer(),
+            GenericArgKind::Type(ty) => ty.is_ty_or_numeric_infer(),
             GenericArgKind::Const(ct) => ct.is_ct_infer(),
         }
     }
diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs
index c59c06ac31e..f9f9799d3e4 100644
--- a/compiler/rustc_passes/src/check_attr.rs
+++ b/compiler/rustc_passes/src/check_attr.rs
@@ -82,6 +82,7 @@ impl CheckAttrVisitor<'_> {
         let attrs = self.tcx.hir().attrs(hir_id);
         for attr in attrs {
             let attr_is_valid = match attr.name_or_empty() {
+                sym::do_not_recommend => self.check_do_not_recommend(attr.span, target),
                 sym::inline => self.check_inline(hir_id, attr, span, target),
                 sym::no_coverage => self.check_no_coverage(hir_id, attr, span, target),
                 sym::non_exhaustive => self.check_non_exhaustive(hir_id, attr, span, target),
@@ -241,6 +242,16 @@ impl CheckAttrVisitor<'_> {
         );
     }
 
+    /// Checks if `#[do_not_recommend]` is applied on a trait impl.
+    fn check_do_not_recommend(&self, attr_span: Span, target: Target) -> bool {
+        if let Target::Impl = target {
+            true
+        } else {
+            self.tcx.sess.emit_err(errors::IncorrectDoNotRecommendLocation { span: attr_span });
+            false
+        }
+    }
+
     /// Checks if an `#[inline]` is applied to a function or a closure. Returns `true` if valid.
     fn check_inline(&self, hir_id: HirId, attr: &Attribute, span: Span, target: Target) -> bool {
         match target {
diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs
index c6cd69add28..9c6519ea4bb 100644
--- a/compiler/rustc_passes/src/errors.rs
+++ b/compiler/rustc_passes/src/errors.rs
@@ -14,6 +14,13 @@ use rustc_span::{Span, Symbol, DUMMY_SP};
 
 use crate::lang_items::Duplicate;
 
+#[derive(Diagnostic)]
+#[diag(passes_incorrect_do_not_recommend_location)]
+pub struct IncorrectDoNotRecommendLocation {
+    #[primary_span]
+    pub span: Span,
+}
+
 #[derive(LintDiagnostic)]
 #[diag(passes_outer_crate_level_attr)]
 pub struct OuterCrateLevelAttr;
diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs
index 1a852de8eed..fb2aebbd18a 100644
--- a/compiler/rustc_resolve/src/diagnostics.rs
+++ b/compiler/rustc_resolve/src/diagnostics.rs
@@ -167,7 +167,7 @@ impl<'a> Resolver<'a> {
                 );
                 err.emit();
             } else if let Some((span, msg, sugg, appl)) = suggestion {
-                err.span_suggestion(span, msg, sugg, appl);
+                err.span_suggestion_verbose(span, msg, sugg, appl);
                 err.emit();
             } else if let [segment] = path.as_slice() && is_call {
                 err.stash(segment.ident.span, rustc_errors::StashKey::CallIntoMethod);
diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs
index d92f5a7c05e..d92b046d0b9 100644
--- a/compiler/rustc_resolve/src/late/diagnostics.rs
+++ b/compiler/rustc_resolve/src/late/diagnostics.rs
@@ -2065,7 +2065,11 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
         path: &[Segment],
     ) -> Option<(Span, &'static str, String, Applicability)> {
         let (ident, span) = match path {
-            [segment] if !segment.has_generic_args && segment.ident.name != kw::SelfUpper => {
+            [segment]
+                if !segment.has_generic_args
+                    && segment.ident.name != kw::SelfUpper
+                    && segment.ident.name != kw::Dyn =>
+            {
                 (segment.ident.to_string(), segment.ident.span)
             }
             _ => return None,
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
index 20bede22c34..0c7ffb056cc 100644
--- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
+++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
@@ -2252,8 +2252,11 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
                     Ok(None) => {
                         let ambiguities =
                             ambiguity::recompute_applicable_impls(self.infcx, &obligation);
-                        let has_non_region_infer =
-                            trait_ref.skip_binder().substs.types().any(|t| !t.is_ty_infer());
+                        let has_non_region_infer = trait_ref
+                            .skip_binder()
+                            .substs
+                            .types()
+                            .any(|t| !t.is_ty_or_numeric_infer());
                         // It doesn't make sense to talk about applicable impls if there are more
                         // than a handful of them.
                         if ambiguities.len() > 1 && ambiguities.len() < 10 && has_non_region_infer {
diff --git a/src/tools/clippy/tests/ui/crashes/ice-6252.stderr b/src/tools/clippy/tests/ui/crashes/ice-6252.stderr
index 638e4a54849..efdd56dd47d 100644
--- a/src/tools/clippy/tests/ui/crashes/ice-6252.stderr
+++ b/src/tools/clippy/tests/ui/crashes/ice-6252.stderr
@@ -17,9 +17,12 @@ error[E0412]: cannot find type `VAL` in this scope
   --> $DIR/ice-6252.rs:10:63
    |
 LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
-   |          -                                                    ^^^ not found in this scope
-   |          |
-   |          help: you might be missing a type parameter: `, VAL`
+   |                                                               ^^^ not found in this scope
+   |
+help: you might be missing a type parameter
+   |
+LL | impl<N, M, VAL> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
+   |          +++++
 
 error[E0046]: not all trait items implemented, missing: `VAL`
   --> $DIR/ice-6252.rs:10:1
diff --git a/tests/ui/builtin-superkinds/builtin-superkinds-double-superkind.stderr b/tests/ui/builtin-superkinds/builtin-superkinds-double-superkind.stderr
index 492316f0027..592aa4369ce 100644
--- a/tests/ui/builtin-superkinds/builtin-superkinds-double-superkind.stderr
+++ b/tests/ui/builtin-superkinds/builtin-superkinds-double-superkind.stderr
@@ -1,8 +1,8 @@
 error[E0277]: `T` cannot be sent between threads safely
-  --> $DIR/builtin-superkinds-double-superkind.rs:6:24
+  --> $DIR/builtin-superkinds-double-superkind.rs:6:32
    |
 LL | impl <T: Sync+'static> Foo for (T,) { }
-   |                        ^^^ `T` cannot be sent between threads safely
+   |                                ^^^^ `T` cannot be sent between threads safely
    |
    = note: required because it appears within the type `(T,)`
 note: required by a bound in `Foo`
@@ -16,10 +16,10 @@ LL | impl <T: Sync+'static + std::marker::Send> Foo for (T,) { }
    |                       +++++++++++++++++++
 
 error[E0277]: `T` cannot be shared between threads safely
-  --> $DIR/builtin-superkinds-double-superkind.rs:9:16
+  --> $DIR/builtin-superkinds-double-superkind.rs:9:24
    |
 LL | impl <T: Send> Foo for (T,T) { }
-   |                ^^^ `T` cannot be shared between threads safely
+   |                        ^^^^^ `T` cannot be shared between threads safely
    |
    = note: required because it appears within the type `(T, T)`
 note: required by a bound in `Foo`
diff --git a/tests/ui/builtin-superkinds/builtin-superkinds-in-metadata.stderr b/tests/ui/builtin-superkinds/builtin-superkinds-in-metadata.stderr
index a46e4b2337c..f9d548bb8fb 100644
--- a/tests/ui/builtin-superkinds/builtin-superkinds-in-metadata.stderr
+++ b/tests/ui/builtin-superkinds/builtin-superkinds-in-metadata.stderr
@@ -1,8 +1,8 @@
 error[E0277]: `T` cannot be sent between threads safely
-  --> $DIR/builtin-superkinds-in-metadata.rs:13:23
+  --> $DIR/builtin-superkinds-in-metadata.rs:13:56
    |
 LL | impl <T:Sync+'static> RequiresRequiresShareAndSend for X<T> { }
-   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `T` cannot be sent between threads safely
+   |                                                        ^^^^ `T` cannot be sent between threads safely
    |
 note: required because it appears within the type `X<T>`
   --> $DIR/builtin-superkinds-in-metadata.rs:9:8
diff --git a/tests/ui/builtin-superkinds/builtin-superkinds-simple.stderr b/tests/ui/builtin-superkinds/builtin-superkinds-simple.stderr
index 9db9cbfdb91..8b19170b0f1 100644
--- a/tests/ui/builtin-superkinds/builtin-superkinds-simple.stderr
+++ b/tests/ui/builtin-superkinds/builtin-superkinds-simple.stderr
@@ -1,8 +1,8 @@
 error[E0277]: `Rc<i8>` cannot be sent between threads safely
-  --> $DIR/builtin-superkinds-simple.rs:6:6
+  --> $DIR/builtin-superkinds-simple.rs:6:14
    |
 LL | impl Foo for std::rc::Rc<i8> { }
-   |      ^^^ `Rc<i8>` cannot be sent between threads safely
+   |              ^^^^^^^^^^^^^^^ `Rc<i8>` cannot be sent between threads safely
    |
    = help: the trait `Send` is not implemented for `Rc<i8>`
 note: required by a bound in `Foo`
diff --git a/tests/ui/builtin-superkinds/builtin-superkinds-typaram-not-send.stderr b/tests/ui/builtin-superkinds/builtin-superkinds-typaram-not-send.stderr
index 3ec0b907d0c..0cfea72d5f1 100644
--- a/tests/ui/builtin-superkinds/builtin-superkinds-typaram-not-send.stderr
+++ b/tests/ui/builtin-superkinds/builtin-superkinds-typaram-not-send.stderr
@@ -1,8 +1,8 @@
 error[E0277]: `T` cannot be sent between threads safely
-  --> $DIR/builtin-superkinds-typaram-not-send.rs:5:24
+  --> $DIR/builtin-superkinds-typaram-not-send.rs:5:32
    |
 LL | impl <T: Sync+'static> Foo for T { }
-   |                        ^^^ `T` cannot be sent between threads safely
+   |                                ^ `T` cannot be sent between threads safely
    |
 note: required by a bound in `Foo`
   --> $DIR/builtin-superkinds-typaram-not-send.rs:3:13
diff --git a/tests/ui/chalkify/impl_wf.stderr b/tests/ui/chalkify/impl_wf.stderr
index a142459bcb4..84c32fa3771 100644
--- a/tests/ui/chalkify/impl_wf.stderr
+++ b/tests/ui/chalkify/impl_wf.stderr
@@ -1,8 +1,8 @@
 error[E0277]: the size for values of type `str` cannot be known at compilation time
-  --> $DIR/impl_wf.rs:11:6
+  --> $DIR/impl_wf.rs:11:14
    |
 LL | impl Foo for str { }
-   |      ^^^ doesn't have a size known at compile-time
+   |              ^^^ doesn't have a size known at compile-time
    |
    = help: the trait `Sized` is not implemented for `str`
 note: required by a bound in `Foo`
@@ -12,10 +12,10 @@ LL | trait Foo: Sized { }
    |            ^^^^^ required by this bound in `Foo`
 
 error[E0277]: the trait bound `f32: Foo` is not satisfied
-  --> $DIR/impl_wf.rs:22:6
+  --> $DIR/impl_wf.rs:22:19
    |
 LL | impl Baz<f32> for f32 { }
-   |      ^^^^^^^^ the trait `Foo` is not implemented for `f32`
+   |                   ^^^ the trait `Foo` is not implemented for `f32`
    |
    = help: the trait `Foo` is implemented for `i32`
 note: required by a bound in `Baz`
diff --git a/tests/ui/coherence/coherence-overlap-trait-alias.stderr b/tests/ui/coherence/coherence-overlap-trait-alias.stderr
index e324c1e799f..668b8319b38 100644
--- a/tests/ui/coherence/coherence-overlap-trait-alias.stderr
+++ b/tests/ui/coherence/coherence-overlap-trait-alias.stderr
@@ -1,8 +1,8 @@
 error[E0283]: type annotations needed: cannot satisfy `u32: C`
-  --> $DIR/coherence-overlap-trait-alias.rs:15:6
+  --> $DIR/coherence-overlap-trait-alias.rs:15:12
    |
 LL | impl C for u32 {}
-   |      ^
+   |            ^^^
    |
 note: multiple `impl`s satisfying `u32: C` found
   --> $DIR/coherence-overlap-trait-alias.rs:14:1
diff --git a/tests/ui/dst/dst-sized-trait-param.stderr b/tests/ui/dst/dst-sized-trait-param.stderr
index 8ec94f5a3c0..60e9de90332 100644
--- a/tests/ui/dst/dst-sized-trait-param.stderr
+++ b/tests/ui/dst/dst-sized-trait-param.stderr
@@ -16,10 +16,10 @@ LL | trait Foo<T: ?Sized> : Sized { fn take(self, x: &T) { } } // Note: T is siz
    |            ++++++++
 
 error[E0277]: the size for values of type `[usize]` cannot be known at compilation time
-  --> $DIR/dst-sized-trait-param.rs:10:6
+  --> $DIR/dst-sized-trait-param.rs:10:21
    |
 LL | impl Foo<isize> for [usize] { }
-   |      ^^^^^^^^^^ doesn't have a size known at compile-time
+   |                     ^^^^^^^ doesn't have a size known at compile-time
    |
    = help: the trait `Sized` is not implemented for `[usize]`
 note: required by a bound in `Foo`
diff --git a/tests/ui/error-codes/E0308-2.stderr b/tests/ui/error-codes/E0308-2.stderr
index de54a417253..3a8a81a73a6 100644
--- a/tests/ui/error-codes/E0308-2.stderr
+++ b/tests/ui/error-codes/E0308-2.stderr
@@ -1,8 +1,8 @@
 error[E0308]: mismatched types
-  --> $DIR/E0308-2.rs:9:6
+  --> $DIR/E0308-2.rs:9:13
    |
 LL | impl Eq for &dyn DynEq {}
-   |      ^^ lifetime mismatch
+   |             ^^^^^^^^^^ lifetime mismatch
    |
    = note: expected trait `<&dyn DynEq as PartialEq>`
               found trait `<&(dyn DynEq + 'static) as PartialEq>`
diff --git a/tests/ui/functions-closures/fn-help-with-err-generic-is-not-function.stderr b/tests/ui/functions-closures/fn-help-with-err-generic-is-not-function.stderr
index 26bdf460f5e..9d4ea01152c 100644
--- a/tests/ui/functions-closures/fn-help-with-err-generic-is-not-function.stderr
+++ b/tests/ui/functions-closures/fn-help-with-err-generic-is-not-function.stderr
@@ -2,9 +2,12 @@ error[E0412]: cannot find type `T` in this scope
   --> $DIR/fn-help-with-err-generic-is-not-function.rs:2:13
    |
 LL | impl Struct<T>
-   |     -       ^ not found in this scope
-   |     |
-   |     help: you might be missing a type parameter: `<T>`
+   |             ^ not found in this scope
+   |
+help: you might be missing a type parameter
+   |
+LL | impl<T> Struct<T>
+   |     +++
 
 error[E0412]: cannot find type `T` in this scope
   --> $DIR/fn-help-with-err-generic-is-not-function.rs:7:5
diff --git a/tests/ui/issues/issue-58712.stderr b/tests/ui/issues/issue-58712.stderr
index 87c16aa993b..f4bd4d1e826 100644
--- a/tests/ui/issues/issue-58712.stderr
+++ b/tests/ui/issues/issue-58712.stderr
@@ -2,9 +2,12 @@ error[E0412]: cannot find type `DeviceId` in this scope
   --> $DIR/issue-58712.rs:6:20
    |
 LL | impl<H> AddrVec<H, DeviceId> {
-   |       -            ^^^^^^^^ not found in this scope
-   |       |
-   |       help: you might be missing a type parameter: `, DeviceId`
+   |                    ^^^^^^^^ not found in this scope
+   |
+help: you might be missing a type parameter
+   |
+LL | impl<H, DeviceId> AddrVec<H, DeviceId> {
+   |       ++++++++++
 
 error[E0412]: cannot find type `DeviceId` in this scope
   --> $DIR/issue-58712.rs:8:29
diff --git a/tests/ui/issues/issue-65230.stderr b/tests/ui/issues/issue-65230.stderr
index fcabcdea74f..7ccab889483 100644
--- a/tests/ui/issues/issue-65230.stderr
+++ b/tests/ui/issues/issue-65230.stderr
@@ -1,8 +1,8 @@
 error[E0308]: mismatched types
-  --> $DIR/issue-65230.rs:8:6
+  --> $DIR/issue-65230.rs:8:13
    |
 LL | impl T1 for &dyn T2 {}
-   |      ^^ lifetime mismatch
+   |             ^^^^^^^ lifetime mismatch
    |
    = note: expected trait `<&dyn T2 as T0>`
               found trait `<&(dyn T2 + 'static) as T0>`
diff --git a/tests/ui/issues/issue-77919.stderr b/tests/ui/issues/issue-77919.stderr
index ca256847b1f..d154bfe0cb5 100644
--- a/tests/ui/issues/issue-77919.stderr
+++ b/tests/ui/issues/issue-77919.stderr
@@ -13,9 +13,12 @@ error[E0412]: cannot find type `VAL` in this scope
   --> $DIR/issue-77919.rs:11:63
    |
 LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
-   |          -                                                    ^^^ not found in this scope
-   |          |
-   |          help: you might be missing a type parameter: `, VAL`
+   |                                                               ^^^ not found in this scope
+   |
+help: you might be missing a type parameter
+   |
+LL | impl<N, M, VAL> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
+   |          +++++
 
 error[E0046]: not all trait items implemented, missing: `VAL`
   --> $DIR/issue-77919.rs:11:1
diff --git a/tests/ui/issues/issue-86756.stderr b/tests/ui/issues/issue-86756.stderr
index 6c5917bdf6e..bfa7459ab4a 100644
--- a/tests/ui/issues/issue-86756.stderr
+++ b/tests/ui/issues/issue-86756.stderr
@@ -9,8 +9,6 @@ LL | trait Foo<T, T = T> {}
 error[E0412]: cannot find type `dyn` in this scope
   --> $DIR/issue-86756.rs:5:10
    |
-LL | fn eq<A, B>() {
-   |           - help: you might be missing a type parameter: `, dyn`
 LL |     eq::<dyn, Foo>
    |          ^^^ not found in this scope
 
diff --git a/tests/ui/marker_trait_attr/overlap-marker-trait-with-underscore-lifetime.stderr b/tests/ui/marker_trait_attr/overlap-marker-trait-with-underscore-lifetime.stderr
index 235c89e200a..3cd59d6926e 100644
--- a/tests/ui/marker_trait_attr/overlap-marker-trait-with-underscore-lifetime.stderr
+++ b/tests/ui/marker_trait_attr/overlap-marker-trait-with-underscore-lifetime.stderr
@@ -1,8 +1,8 @@
 error[E0283]: type annotations needed: cannot satisfy `&(): Marker`
-  --> $DIR/overlap-marker-trait-with-underscore-lifetime.rs:6:6
+  --> $DIR/overlap-marker-trait-with-underscore-lifetime.rs:6:17
    |
 LL | impl Marker for &'_ () {}
-   |      ^^^^^^
+   |                 ^^^^^^
    |
 note: multiple `impl`s satisfying `&(): Marker` found
   --> $DIR/overlap-marker-trait-with-underscore-lifetime.rs:6:1
@@ -13,10 +13,10 @@ LL | impl Marker for &'_ () {}
    | ^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0283]: type annotations needed: cannot satisfy `&(): Marker`
-  --> $DIR/overlap-marker-trait-with-underscore-lifetime.rs:7:6
+  --> $DIR/overlap-marker-trait-with-underscore-lifetime.rs:7:17
    |
 LL | impl Marker for &'_ () {}
-   |      ^^^^^^
+   |                 ^^^^^^
    |
 note: multiple `impl`s satisfying `&(): Marker` found
   --> $DIR/overlap-marker-trait-with-underscore-lifetime.rs:6:1
diff --git a/tests/ui/marker_trait_attr/region-overlap.stderr b/tests/ui/marker_trait_attr/region-overlap.stderr
index 6631fe987e2..c6497b4669d 100644
--- a/tests/ui/marker_trait_attr/region-overlap.stderr
+++ b/tests/ui/marker_trait_attr/region-overlap.stderr
@@ -1,8 +1,8 @@
 error[E0283]: type annotations needed: cannot satisfy `(&'static (), &'a ()): A`
-  --> $DIR/region-overlap.rs:5:10
+  --> $DIR/region-overlap.rs:5:16
    |
 LL | impl<'a> A for (&'static (), &'a ()) {}
-   |          ^
+   |                ^^^^^^^^^^^^^^^^^^^^^
    |
 note: multiple `impl`s satisfying `(&'static (), &'a ()): A` found
   --> $DIR/region-overlap.rs:5:1
@@ -13,10 +13,10 @@ LL | impl<'a> A for (&'a (), &'static ()) {}
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0283]: type annotations needed: cannot satisfy `(&'a (), &'static ()): A`
-  --> $DIR/region-overlap.rs:6:10
+  --> $DIR/region-overlap.rs:6:16
    |
 LL | impl<'a> A for (&'a (), &'static ()) {}
-   |          ^
+   |                ^^^^^^^^^^^^^^^^^^^^^
    |
 note: multiple `impl`s satisfying `(&'a (), &'static ()): A` found
   --> $DIR/region-overlap.rs:5:1
diff --git a/tests/ui/parser/dyn-trait-compatibility.stderr b/tests/ui/parser/dyn-trait-compatibility.stderr
index 9218ae9d5da..0cae01bd1e3 100644
--- a/tests/ui/parser/dyn-trait-compatibility.stderr
+++ b/tests/ui/parser/dyn-trait-compatibility.stderr
@@ -26,17 +26,13 @@ error[E0412]: cannot find type `dyn` in this scope
   --> $DIR/dyn-trait-compatibility.rs:5:15
    |
 LL | type A2 = dyn<dyn, dyn>;
-   |        -      ^^^ not found in this scope
-   |        |
-   |        help: you might be missing a type parameter: `<dyn>`
+   |               ^^^ not found in this scope
 
 error[E0412]: cannot find type `dyn` in this scope
   --> $DIR/dyn-trait-compatibility.rs:5:20
    |
 LL | type A2 = dyn<dyn, dyn>;
-   |        -           ^^^ not found in this scope
-   |        |
-   |        help: you might be missing a type parameter: `<dyn>`
+   |                    ^^^ not found in this scope
 
 error[E0412]: cannot find type `dyn` in this scope
   --> $DIR/dyn-trait-compatibility.rs:9:11
@@ -48,9 +44,7 @@ error[E0412]: cannot find type `dyn` in this scope
   --> $DIR/dyn-trait-compatibility.rs:9:16
    |
 LL | type A3 = dyn<<dyn as dyn>::dyn>;
-   |        -       ^^^ not found in this scope
-   |        |
-   |        help: you might be missing a type parameter: `<dyn>`
+   |                ^^^ not found in this scope
 
 error: aborting due to 8 previous errors
 
diff --git a/tests/ui/rfc-2397-do-not-recommend/incorrect-locations.rs b/tests/ui/rfc-2397-do-not-recommend/incorrect-locations.rs
new file mode 100644
index 00000000000..91863f5e497
--- /dev/null
+++ b/tests/ui/rfc-2397-do-not-recommend/incorrect-locations.rs
@@ -0,0 +1,45 @@
+#![feature(do_not_recommend)]
+
+#[do_not_recommend]
+//~^ `#[do_not_recommend]` can only be placed
+const CONST: () = ();
+
+#[do_not_recommend]
+//~^ `#[do_not_recommend]` can only be placed
+static Static: () = ();
+
+#[do_not_recommend]
+//~^ `#[do_not_recommend]` can only be placed
+type Type = ();
+
+#[do_not_recommend]
+//~^ `#[do_not_recommend]` can only be placed
+enum Enum {
+}
+
+#[do_not_recommend]
+//~^ `#[do_not_recommend]` can only be placed
+extern {
+}
+
+#[do_not_recommend]
+//~^ `#[do_not_recommend]` can only be placed
+fn fun() {
+}
+
+#[do_not_recommend]
+//~^ `#[do_not_recommend]` can only be placed
+struct Struct {
+}
+
+#[do_not_recommend]
+//~^ `#[do_not_recommend]` can only be placed
+trait Trait {
+}
+
+#[do_not_recommend]
+impl Trait for i32 {
+}
+
+fn main() {
+}
diff --git a/tests/ui/rfc-2397-do-not-recommend/incorrect-locations.stderr b/tests/ui/rfc-2397-do-not-recommend/incorrect-locations.stderr
new file mode 100644
index 00000000000..01ebc23c86e
--- /dev/null
+++ b/tests/ui/rfc-2397-do-not-recommend/incorrect-locations.stderr
@@ -0,0 +1,50 @@
+error: `#[do_not_recommend]` can only be placed on trait implementations
+  --> $DIR/incorrect-locations.rs:3:1
+   |
+LL | #[do_not_recommend]
+   | ^^^^^^^^^^^^^^^^^^^
+
+error: `#[do_not_recommend]` can only be placed on trait implementations
+  --> $DIR/incorrect-locations.rs:7:1
+   |
+LL | #[do_not_recommend]
+   | ^^^^^^^^^^^^^^^^^^^
+
+error: `#[do_not_recommend]` can only be placed on trait implementations
+  --> $DIR/incorrect-locations.rs:11:1
+   |
+LL | #[do_not_recommend]
+   | ^^^^^^^^^^^^^^^^^^^
+
+error: `#[do_not_recommend]` can only be placed on trait implementations
+  --> $DIR/incorrect-locations.rs:15:1
+   |
+LL | #[do_not_recommend]
+   | ^^^^^^^^^^^^^^^^^^^
+
+error: `#[do_not_recommend]` can only be placed on trait implementations
+  --> $DIR/incorrect-locations.rs:20:1
+   |
+LL | #[do_not_recommend]
+   | ^^^^^^^^^^^^^^^^^^^
+
+error: `#[do_not_recommend]` can only be placed on trait implementations
+  --> $DIR/incorrect-locations.rs:25:1
+   |
+LL | #[do_not_recommend]
+   | ^^^^^^^^^^^^^^^^^^^
+
+error: `#[do_not_recommend]` can only be placed on trait implementations
+  --> $DIR/incorrect-locations.rs:30:1
+   |
+LL | #[do_not_recommend]
+   | ^^^^^^^^^^^^^^^^^^^
+
+error: `#[do_not_recommend]` can only be placed on trait implementations
+  --> $DIR/incorrect-locations.rs:35:1
+   |
+LL | #[do_not_recommend]
+   | ^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 8 previous errors
+
diff --git a/tests/ui/rfc-2397-do-not-recommend/unstable-feature.rs b/tests/ui/rfc-2397-do-not-recommend/unstable-feature.rs
index b816c4a19da..f0c5c222e78 100644
--- a/tests/ui/rfc-2397-do-not-recommend/unstable-feature.rs
+++ b/tests/ui/rfc-2397-do-not-recommend/unstable-feature.rs
@@ -1,6 +1,9 @@
+trait Foo {
+}
+
 #[do_not_recommend]
 //~^ ERROR the `#[do_not_recommend]` attribute is an experimental feature
-trait Foo {
+impl Foo for i32 {
 }
 
 fn main() {
diff --git a/tests/ui/rfc-2397-do-not-recommend/unstable-feature.stderr b/tests/ui/rfc-2397-do-not-recommend/unstable-feature.stderr
index 425d7e4bca0..1597e5be45f 100644
--- a/tests/ui/rfc-2397-do-not-recommend/unstable-feature.stderr
+++ b/tests/ui/rfc-2397-do-not-recommend/unstable-feature.stderr
@@ -1,5 +1,5 @@
 error[E0658]: the `#[do_not_recommend]` attribute is an experimental feature
-  --> $DIR/unstable-feature.rs:1:1
+  --> $DIR/unstable-feature.rs:4:1
    |
 LL | #[do_not_recommend]
    | ^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail.stderr b/tests/ui/rfc-2632-const-trait-impl/super-traits-fail.stderr
index 1f8f312df01..bf12ef1ca77 100644
--- a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail.stderr
+++ b/tests/ui/rfc-2632-const-trait-impl/super-traits-fail.stderr
@@ -1,14 +1,14 @@
 error[E0277]: the trait bound `S: ~const Foo` is not satisfied
-  --> $DIR/super-traits-fail.rs:15:12
+  --> $DIR/super-traits-fail.rs:15:20
    |
 LL | impl const Bar for S {}
-   |            ^^^ the trait `~const Foo` is not implemented for `S`
+   |                    ^ the trait `~const Foo` is not implemented for `S`
    |
 note: the trait `Foo` is implemented for `S`, but that implementation is not `const`
-  --> $DIR/super-traits-fail.rs:15:12
+  --> $DIR/super-traits-fail.rs:15:20
    |
 LL | impl const Bar for S {}
-   |            ^^^
+   |                    ^
 note: required by a bound in `Bar`
   --> $DIR/super-traits-fail.rs:8:12
    |
diff --git a/tests/ui/span/issue-71363.stderr b/tests/ui/span/issue-71363.stderr
index 6c7ea007ee0..cb5cc320276 100644
--- a/tests/ui/span/issue-71363.stderr
+++ b/tests/ui/span/issue-71363.stderr
@@ -1,8 +1,8 @@
 error[E0277]: `MyError` doesn't implement `std::fmt::Display`
- --> $DIR/issue-71363.rs:4:6
+ --> $DIR/issue-71363.rs:4:28
   |
 4 | impl std::error::Error for MyError {}
-  |      ^^^^^^^^^^^^^^^^^ `MyError` cannot be formatted with the default formatter
+  |                            ^^^^^^^ `MyError` cannot be formatted with the default formatter
   |
   = help: the trait `std::fmt::Display` is not implemented for `MyError`
   = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
@@ -10,10 +10,10 @@ note: required by a bound in `std::error::Error`
  --> $SRC_DIR/core/src/error.rs:LL:COL
 
 error[E0277]: `MyError` doesn't implement `Debug`
- --> $DIR/issue-71363.rs:4:6
+ --> $DIR/issue-71363.rs:4:28
   |
 4 | impl std::error::Error for MyError {}
-  |      ^^^^^^^^^^^^^^^^^ `MyError` cannot be formatted using `{:?}`
+  |                            ^^^^^^^ `MyError` cannot be formatted using `{:?}`
   |
   = help: the trait `Debug` is not implemented for `MyError`
   = note: add `#[derive(Debug)]` to `MyError` or manually `impl Debug for MyError`
diff --git a/tests/ui/specialization/min_specialization/issue-79224.stderr b/tests/ui/specialization/min_specialization/issue-79224.stderr
index be6f04ae62a..505baa23ca3 100644
--- a/tests/ui/specialization/min_specialization/issue-79224.stderr
+++ b/tests/ui/specialization/min_specialization/issue-79224.stderr
@@ -1,8 +1,8 @@
 error[E0277]: the trait bound `B: Clone` is not satisfied
-  --> $DIR/issue-79224.rs:18:17
+  --> $DIR/issue-79224.rs:18:29
    |
 LL | impl<B: ?Sized> Display for Cow<'_, B> {
-   |                 ^^^^^^^ the trait `Clone` is not implemented for `B`
+   |                             ^^^^^^^^^^ the trait `Clone` is not implemented for `B`
    |
    = note: required for `B` to implement `ToOwned`
 help: consider further restricting this bound
diff --git a/tests/ui/suggestions/type-not-found-in-adt-field.stderr b/tests/ui/suggestions/type-not-found-in-adt-field.stderr
index e990fb5ba12..934ba87bbaa 100644
--- a/tests/ui/suggestions/type-not-found-in-adt-field.stderr
+++ b/tests/ui/suggestions/type-not-found-in-adt-field.stderr
@@ -7,10 +7,13 @@ LL |     m: Vec<Someunknownname<String, ()>>,
 error[E0412]: cannot find type `K` in this scope
   --> $DIR/type-not-found-in-adt-field.rs:6:8
    |
-LL | struct OtherStruct {
-   |                   - help: you might be missing a type parameter: `<K>`
 LL |     m: K,
    |        ^ not found in this scope
+   |
+help: you might be missing a type parameter
+   |
+LL | struct OtherStruct<K> {
+   |                   +++
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/trait-bounds/unsized-bound.stderr b/tests/ui/trait-bounds/unsized-bound.stderr
index ec85ada7a8d..da27ba1c58d 100644
--- a/tests/ui/trait-bounds/unsized-bound.stderr
+++ b/tests/ui/trait-bounds/unsized-bound.stderr
@@ -1,8 +1,8 @@
 error[E0277]: the size for values of type `B` cannot be known at compilation time
-  --> $DIR/unsized-bound.rs:2:12
+  --> $DIR/unsized-bound.rs:2:30
    |
 LL | impl<A, B> Trait<(A, B)> for (A, B) where A: ?Sized, B: ?Sized, {}
-   |         -  ^^^^^^^^^^^^^ doesn't have a size known at compile-time
+   |         -                    ^^^^^^ doesn't have a size known at compile-time
    |         |
    |         this type parameter needs to be `std::marker::Sized`
    |
@@ -38,10 +38,10 @@ LL + impl<A, B> Trait<(A, B)> for (A, B) where B: ?Sized, {}
    |
 
 error[E0277]: the size for values of type `C` cannot be known at compilation time
-  --> $DIR/unsized-bound.rs:5:31
+  --> $DIR/unsized-bound.rs:5:52
    |
 LL | impl<A, B: ?Sized, C: ?Sized> Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {}
-   |                    -          ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
+   |                    -                               ^^^^^^^^^ doesn't have a size known at compile-time
    |                    |
    |                    this type parameter needs to be `std::marker::Sized`
    |
@@ -92,10 +92,10 @@ LL + impl<A, B, C: ?Sized> Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {}
    |
 
 error[E0277]: the size for values of type `B` cannot be known at compilation time
-  --> $DIR/unsized-bound.rs:10:28
+  --> $DIR/unsized-bound.rs:10:47
    |
 LL | impl<A: ?Sized, B: ?Sized> Trait2<(A, B)> for (A, B) {}
-   |                 -          ^^^^^^^^^^^^^^ doesn't have a size known at compile-time
+   |                 -                             ^^^^^^ doesn't have a size known at compile-time
    |                 |
    |                 this type parameter needs to be `std::marker::Sized`
    |
@@ -131,10 +131,10 @@ LL + impl<A, B: ?Sized> Trait2<(A, B)> for (A, B) {}
    |
 
 error[E0277]: the size for values of type `A` cannot be known at compilation time
-  --> $DIR/unsized-bound.rs:14:9
+  --> $DIR/unsized-bound.rs:14:23
    |
 LL | impl<A> Trait3<A> for A where A: ?Sized {}
-   |      -  ^^^^^^^^^ doesn't have a size known at compile-time
+   |      -                ^ doesn't have a size known at compile-time
    |      |
    |      this type parameter needs to be `std::marker::Sized`
    |
@@ -154,10 +154,10 @@ LL | trait Trait3<A: ?Sized> {}
    |               ++++++++
 
 error[E0277]: the size for values of type `A` cannot be known at compilation time
-  --> $DIR/unsized-bound.rs:17:17
+  --> $DIR/unsized-bound.rs:17:31
    |
 LL | impl<A: ?Sized> Trait4<A> for A {}
-   |      -          ^^^^^^^^^ doesn't have a size known at compile-time
+   |      -                        ^ doesn't have a size known at compile-time
    |      |
    |      this type parameter needs to be `std::marker::Sized`
    |
@@ -177,10 +177,10 @@ LL | trait Trait4<A: ?Sized> {}
    |               ++++++++
 
 error[E0277]: the size for values of type `X` cannot be known at compilation time
-  --> $DIR/unsized-bound.rs:20:12
+  --> $DIR/unsized-bound.rs:20:29
    |
 LL | impl<X, Y> Trait5<X, Y> for X where X: ?Sized {}
-   |      -     ^^^^^^^^^^^^ doesn't have a size known at compile-time
+   |      -                      ^ doesn't have a size known at compile-time
    |      |
    |      this type parameter needs to be `std::marker::Sized`
    |
@@ -200,10 +200,10 @@ LL | trait Trait5<A: ?Sized, B> {}
    |               ++++++++
 
 error[E0277]: the size for values of type `X` cannot be known at compilation time
-  --> $DIR/unsized-bound.rs:23:20
+  --> $DIR/unsized-bound.rs:23:37
    |
 LL | impl<X: ?Sized, Y> Trait6<X, Y> for X {}
-   |      -             ^^^^^^^^^^^^ doesn't have a size known at compile-time
+   |      -                              ^ doesn't have a size known at compile-time
    |      |
    |      this type parameter needs to be `std::marker::Sized`
    |
diff --git a/tests/ui/traits/ignore-err-impls.stderr b/tests/ui/traits/ignore-err-impls.stderr
index 1390106a291..45bd533b5c6 100644
--- a/tests/ui/traits/ignore-err-impls.stderr
+++ b/tests/ui/traits/ignore-err-impls.stderr
@@ -2,9 +2,12 @@ error[E0412]: cannot find type `Type` in this scope
   --> $DIR/ignore-err-impls.rs:6:14
    |
 LL | impl Generic<Type> for S {}
-   |     -        ^^^^ not found in this scope
-   |     |
-   |     help: you might be missing a type parameter: `<Type>`
+   |              ^^^^ not found in this scope
+   |
+help: you might be missing a type parameter
+   |
+LL | impl<Type> Generic<Type> for S {}
+   |     ++++++
 
 error: aborting due to previous error
 
diff --git a/tests/ui/traits/impl-bounds-checking.stderr b/tests/ui/traits/impl-bounds-checking.stderr
index b01bacdb87d..1f969efe114 100644
--- a/tests/ui/traits/impl-bounds-checking.stderr
+++ b/tests/ui/traits/impl-bounds-checking.stderr
@@ -1,8 +1,8 @@
 error[E0277]: the trait bound `isize: Clone2` is not satisfied
-  --> $DIR/impl-bounds-checking.rs:10:6
+  --> $DIR/impl-bounds-checking.rs:10:24
    |
 LL | impl Getter<isize> for isize {
-   |      ^^^^^^^^^^^^^ the trait `Clone2` is not implemented for `isize`
+   |                        ^^^^^ the trait `Clone2` is not implemented for `isize`
    |
 note: required by a bound in `Getter`
   --> $DIR/impl-bounds-checking.rs:6:17
diff --git a/tests/ui/traits/impl-of-supertrait-has-wrong-lifetime-parameters.stderr b/tests/ui/traits/impl-of-supertrait-has-wrong-lifetime-parameters.stderr
index 5572c6515ff..1bace8ab286 100644
--- a/tests/ui/traits/impl-of-supertrait-has-wrong-lifetime-parameters.stderr
+++ b/tests/ui/traits/impl-of-supertrait-has-wrong-lifetime-parameters.stderr
@@ -1,8 +1,8 @@
 error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'b` due to conflicting requirements
-  --> $DIR/impl-of-supertrait-has-wrong-lifetime-parameters.rs:24:13
+  --> $DIR/impl-of-supertrait-has-wrong-lifetime-parameters.rs:24:28
    |
 LL | impl<'a,'b> T2<'a, 'b> for S<'a, 'b> {
-   |             ^^^^^^^^^^
+   |                            ^^^^^^^^^
    |
 note: first, the lifetime cannot outlive the lifetime `'a` as defined here...
   --> $DIR/impl-of-supertrait-has-wrong-lifetime-parameters.rs:24:6
@@ -15,10 +15,10 @@ note: ...but the lifetime must also be valid for the lifetime `'b` as defined he
 LL | impl<'a,'b> T2<'a, 'b> for S<'a, 'b> {
    |         ^^
 note: ...so that the types are compatible
-  --> $DIR/impl-of-supertrait-has-wrong-lifetime-parameters.rs:24:13
+  --> $DIR/impl-of-supertrait-has-wrong-lifetime-parameters.rs:24:28
    |
 LL | impl<'a,'b> T2<'a, 'b> for S<'a, 'b> {
-   |             ^^^^^^^^^^
+   |                            ^^^^^^^^^
    = note: expected `T1<'a>`
               found `T1<'_>`
 
diff --git a/tests/ui/traits/issue-43784-supertrait.stderr b/tests/ui/traits/issue-43784-supertrait.stderr
index bb890cb99ee..4fe12731475 100644
--- a/tests/ui/traits/issue-43784-supertrait.stderr
+++ b/tests/ui/traits/issue-43784-supertrait.stderr
@@ -1,8 +1,8 @@
 error[E0277]: the trait bound `T: Copy` is not satisfied
-  --> $DIR/issue-43784-supertrait.rs:8:9
+  --> $DIR/issue-43784-supertrait.rs:8:22
    |
 LL | impl<T> Complete for T {}
-   |         ^^^^^^^^ the trait `Copy` is not implemented for `T`
+   |                      ^ the trait `Copy` is not implemented for `T`
    |
 note: required by a bound in `Complete`
   --> $DIR/issue-43784-supertrait.rs:4:21
diff --git a/tests/ui/traits/issue-50480.stderr b/tests/ui/traits/issue-50480.stderr
index 0bb1f9ae035..aa8384e9805 100644
--- a/tests/ui/traits/issue-50480.stderr
+++ b/tests/ui/traits/issue-50480.stderr
@@ -2,9 +2,12 @@ error[E0412]: cannot find type `N` in this scope
   --> $DIR/issue-50480.rs:3:12
    |
 LL | struct Foo(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
-   |           -^ not found in this scope
-   |           |
-   |           help: you might be missing a type parameter: `<N>`
+   |            ^ not found in this scope
+   |
+help: you might be missing a type parameter
+   |
+LL | struct Foo<N>(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
+   |           +++
 
 error[E0412]: cannot find type `NotDefined` in this scope
   --> $DIR/issue-50480.rs:3:15
@@ -16,17 +19,23 @@ error[E0412]: cannot find type `N` in this scope
   --> $DIR/issue-50480.rs:3:12
    |
 LL | struct Foo(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
-   |           -^ not found in this scope
-   |           |
-   |           help: you might be missing a type parameter: `<N>`
+   |            ^ not found in this scope
+   |
+help: you might be missing a type parameter
+   |
+LL | struct Foo<N>(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
+   |           +++
 
 error[E0412]: cannot find type `NotDefined` in this scope
   --> $DIR/issue-50480.rs:3:15
    |
 LL | struct Foo(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
-   |           -   ^^^^^^^^^^ not found in this scope
-   |           |
-   |           help: you might be missing a type parameter: `<NotDefined>`
+   |               ^^^^^^^^^^ not found in this scope
+   |
+help: you might be missing a type parameter
+   |
+LL | struct Foo<NotDefined>(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
+   |           ++++++++++++
 
 error[E0412]: cannot find type `N` in this scope
   --> $DIR/issue-50480.rs:12:18
diff --git a/tests/ui/traits/issue-75627.stderr b/tests/ui/traits/issue-75627.stderr
index 432ddf2dcdb..1675edc9ff0 100644
--- a/tests/ui/traits/issue-75627.stderr
+++ b/tests/ui/traits/issue-75627.stderr
@@ -2,9 +2,12 @@ error[E0412]: cannot find type `T` in this scope
   --> $DIR/issue-75627.rs:3:26
    |
 LL | unsafe impl Send for Foo<T> {}
-   |            -             ^ not found in this scope
-   |            |
-   |            help: you might be missing a type parameter: `<T>`
+   |                          ^ not found in this scope
+   |
+help: you might be missing a type parameter
+   |
+LL | unsafe impl<T> Send for Foo<T> {}
+   |            +++
 
 error: aborting due to previous error
 
diff --git a/tests/ui/traits/issue-78372.stderr b/tests/ui/traits/issue-78372.stderr
index 7e781016e1f..8e7fd5f2557 100644
--- a/tests/ui/traits/issue-78372.stderr
+++ b/tests/ui/traits/issue-78372.stderr
@@ -30,9 +30,12 @@ error[E0412]: cannot find type `MISC` in this scope
   --> $DIR/issue-78372.rs:3:34
    |
 LL | impl<T> DispatchFromDyn<Smaht<U, MISC>> for T {}
-   |       -                          ^^^^ not found in this scope
-   |       |
-   |       help: you might be missing a type parameter: `, MISC`
+   |                                  ^^^^ not found in this scope
+   |
+help: you might be missing a type parameter
+   |
+LL | impl<T, MISC> DispatchFromDyn<Smaht<U, MISC>> for T {}
+   |       ++++++
 
 error[E0658]: use of unstable library feature 'dispatch_from_dyn'
   --> $DIR/issue-78372.rs:1:5
diff --git a/tests/ui/traits/issue-91594.stderr b/tests/ui/traits/issue-91594.stderr
index 6b314fa586d..85d903fadd1 100644
--- a/tests/ui/traits/issue-91594.stderr
+++ b/tests/ui/traits/issue-91594.stderr
@@ -1,8 +1,8 @@
 error[E0277]: the trait bound `Foo: HasComponent<()>` is not satisfied
-  --> $DIR/issue-91594.rs:10:6
+  --> $DIR/issue-91594.rs:10:19
    |
 LL | impl HasComponent<<Foo as Component<Foo>>::Interface> for Foo {}
-   |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `HasComponent<()>` is not implemented for `Foo`
+   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `HasComponent<()>` is not implemented for `Foo`
    |
    = help: the trait `HasComponent<<Foo as Component<Foo>>::Interface>` is implemented for `Foo`
 note: required for `Foo` to implement `Component<Foo>`
diff --git a/tests/ui/transmutability/malformed-program-gracefulness/unknown_dst.stderr b/tests/ui/transmutability/malformed-program-gracefulness/unknown_dst.stderr
index 85087282d3a..b4591778f8e 100644
--- a/tests/ui/transmutability/malformed-program-gracefulness/unknown_dst.stderr
+++ b/tests/ui/transmutability/malformed-program-gracefulness/unknown_dst.stderr
@@ -1,11 +1,13 @@
 error[E0412]: cannot find type `Dst` in this scope
   --> $DIR/unknown_dst.rs:20:36
    |
-LL | fn should_gracefully_handle_unknown_dst() {
-   |                                        - help: you might be missing a type parameter: `<Dst>`
-...
 LL |     assert::is_transmutable::<Src, Dst, Context>();
    |                                    ^^^ not found in this scope
+   |
+help: you might be missing a type parameter
+   |
+LL | fn should_gracefully_handle_unknown_dst<Dst>() {
+   |                                        +++++
 
 error: aborting due to previous error
 
diff --git a/tests/ui/transmutability/malformed-program-gracefulness/unknown_src.stderr b/tests/ui/transmutability/malformed-program-gracefulness/unknown_src.stderr
index 9bedbe87c3f..a55d71d8068 100644
--- a/tests/ui/transmutability/malformed-program-gracefulness/unknown_src.stderr
+++ b/tests/ui/transmutability/malformed-program-gracefulness/unknown_src.stderr
@@ -1,11 +1,13 @@
 error[E0412]: cannot find type `Src` in this scope
   --> $DIR/unknown_src.rs:20:31
    |
-LL | fn should_gracefully_handle_unknown_src() {
-   |                                        - help: you might be missing a type parameter: `<Src>`
-...
 LL |     assert::is_transmutable::<Src, Dst, Context>();
    |                               ^^^ not found in this scope
+   |
+help: you might be missing a type parameter
+   |
+LL | fn should_gracefully_handle_unknown_src<Src>() {
+   |                                        +++++
 
 error: aborting due to previous error
 
diff --git a/tests/ui/typeck/autoderef-with-param-env-error.stderr b/tests/ui/typeck/autoderef-with-param-env-error.stderr
index cde800336dd..182612d5ee7 100644
--- a/tests/ui/typeck/autoderef-with-param-env-error.stderr
+++ b/tests/ui/typeck/autoderef-with-param-env-error.stderr
@@ -1,11 +1,13 @@
 error[E0412]: cannot find type `T` in this scope
   --> $DIR/autoderef-with-param-env-error.rs:3:5
    |
-LL | fn foo()
-   |       - help: you might be missing a type parameter: `<T>`
-LL | where
 LL |     T: Send,
    |     ^ not found in this scope
+   |
+help: you might be missing a type parameter
+   |
+LL | fn foo<T>()
+   |       +++
 
 error: aborting due to previous error
 
diff --git a/tests/ui/typeck/issue-104513-ice.stderr b/tests/ui/typeck/issue-104513-ice.stderr
index 2b3b1b9efdf..5561673f3c6 100644
--- a/tests/ui/typeck/issue-104513-ice.stderr
+++ b/tests/ui/typeck/issue-104513-ice.stderr
@@ -1,10 +1,13 @@
 error[E0405]: cannot find trait `Oops` in this scope
   --> $DIR/issue-104513-ice.rs:3:19
    |
-LL | fn f() {
-   |     - help: you might be missing a type parameter: `<Oops>`
 LL |     let _: S<impl Oops> = S;
    |                   ^^^^ not found in this scope
+   |
+help: you might be missing a type parameter
+   |
+LL | fn f<Oops>() {
+   |     ++++++
 
 error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding
   --> $DIR/issue-104513-ice.rs:3:14