about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev+love@gmail.com>2023-01-13 16:54:24 +0900
committerGitHub <noreply@github.com>2023-01-13 16:54:24 +0900
commit5adc7a5e3792edd4151685ab3cbf84c129123713 (patch)
tree38e2f7465c362038e01c7360df6fb6589517d5e7
parent796847a3da6951219f3ca76a407489b8c5e09619 (diff)
parent5924c2511e43dd077df78d9936ccd0d76168ad30 (diff)
Rollup merge of #106785 - compiler-errors:better-impl-wf-spans, r=estebank
Make blame spans better for impl wfcheck

r? types
-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--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/issues/issue-65230.stderr4
-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/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/trait-bounds/unsized-bound.stderr28
-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-91594.stderr4
21 files changed, 106 insertions, 83 deletions
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/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/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/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/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/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/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-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>`