From ad1c23c993dc65810b535bed8c305643c892a2a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 6 Mar 2020 16:24:08 -0800 Subject: [PATCH 1/4] Maintain chain of derived obligations When evaluating the derived obligations from super traits, maintain a reference to the original obligation in order to give more actionable context in the output. --- src/librustc_trait_selection/traits/wf.rs | 10 +++++++ .../bad-bounds-on-assoc-in-trait.stderr | 7 +++++ .../defaults-unsound-62211-1.stderr | 28 +++++++++++++++++++ .../defaults-unsound-62211-2.stderr | 28 +++++++++++++++++++ .../ui/associated-types/issue-43924.stderr | 14 ++++++++++ .../ui/associated-types/issue-65774-1.stderr | 7 +++++ .../ui/associated-types/issue-65774-2.stderr | 7 +++++ ...builtin-superkinds-double-superkind.stderr | 8 ++++++ .../builtin-superkinds-in-metadata.stderr | 6 ++++ .../builtin-superkinds-simple.stderr | 4 +++ ...builtin-superkinds-typaram-not-send.stderr | 4 +++ src/test/ui/dst/dst-sized-trait-param.stderr | 8 ++++++ .../construct_with_other_type.stderr | 7 +++++ ...e-param-can-reference-self-in-trait.stderr | 4 +++ src/test/ui/impl-bounds-checking.stderr | 5 ++++ src/test/ui/issues/issue-10412.stderr | 4 +++ .../ui/issues/issue-43784-supertrait.stderr | 1 + .../malformed/malformed-derive-entry.stderr | 12 ++++++++ .../defaultimpl/specialization-wfcheck.stderr | 4 +++ ...traits-assoc-type-in-supertrait-bad.stderr | 5 ++++ .../unsized-trait-impl-trait-arg.stderr | 4 +++ src/test/ui/unsized7.stderr | 4 +++ 22 files changed, 181 insertions(+) diff --git a/src/librustc_trait_selection/traits/wf.rs b/src/librustc_trait_selection/traits/wf.rs index 63a6720b97daf..d341909ef7f8b 100644 --- a/src/librustc_trait_selection/traits/wf.rs +++ b/src/librustc_trait_selection/traits/wf.rs @@ -8,6 +8,7 @@ use rustc_middle::ty::subst::{GenericArgKind, SubstsRef}; use rustc_middle::ty::{self, ToPredicate, Ty, TyCtxt, TypeFoldable, WithConstness}; use rustc_span::symbol::{kw, Ident}; use rustc_span::Span; +use std::rc::Rc; /// Returns the set of obligations needed to make `ty` well-formed. /// If `ty` contains unresolved inference variables, this may include @@ -315,6 +316,15 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { let implied_obligations = traits::util::elaborate_obligations(tcx, obligations.clone()); let implied_obligations = implied_obligations.map(|obligation| { let mut cause = cause.clone(); + let parent_trait_ref = obligation + .predicate + .to_opt_poly_trait_ref() + .unwrap_or_else(|| ty::Binder::dummy(*trait_ref)); + let derived_cause = traits::DerivedObligationCause { + parent_trait_ref, + parent_code: Rc::new(obligation.cause.code.clone()), + }; + cause.code = traits::ObligationCauseCode::ImplDerivedObligation(derived_cause); extend_cause_with_original_assoc_item_obligation( tcx, trait_ref, diff --git a/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr b/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr index d5066e39ebc82..dd2f30e6dc040 100644 --- a/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr +++ b/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr @@ -1,10 +1,17 @@ error[E0277]: `>::App` doesn't implement `std::fmt::Debug` --> $DIR/bad-bounds-on-assoc-in-trait.rs:31:6 | +LL | trait Case1 { + | ----- +... +LL | Debug + | ----- required by this bound in `Case1` +... LL | impl Case1 for S1 { | ^^^^^ `>::App` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` | = help: the trait `for<'a> std::fmt::Debug` is not implemented for `>::App` + = note: required because of the requirements on the impl of `for<'a> std::fmt::Debug` for `<<<::C as std::iter::Iterator>::Item as std::iter::Iterator>::Item as Lam<&'a u8>>::App` error[E0277]: `<::C as std::iter::Iterator>::Item` is not an iterator --> $DIR/bad-bounds-on-assoc-in-trait.rs:36:20 diff --git a/src/test/ui/associated-types/defaults-unsound-62211-1.stderr b/src/test/ui/associated-types/defaults-unsound-62211-1.stderr index cfca7cc101107..c4ab7b6e26e51 100644 --- a/src/test/ui/associated-types/defaults-unsound-62211-1.stderr +++ b/src/test/ui/associated-types/defaults-unsound-62211-1.stderr @@ -42,11 +42,18 @@ LL | + Display = Self; error[E0277]: `T` doesn't implement `std::fmt::Display` --> $DIR/defaults-unsound-62211-1.rs:41:9 | +LL | trait UncheckedCopy: Sized { + | ------------- +... +LL | + Display = Self; + | ------- required by this bound in `UncheckedCopy` +... LL | impl UncheckedCopy for T {} | ^^^^^^^^^^^^^ `T` cannot be formatted with the default formatter | = help: the trait `std::fmt::Display` is not implemented for `T` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead + = note: required because of the requirements on the impl of `std::fmt::Display` for `::Output` help: consider restricting type parameter `T` | LL | impl UncheckedCopy for T {} @@ -55,9 +62,16 @@ LL | impl UncheckedCopy for T {} error[E0277]: the trait bound `T: std::ops::Deref` is not satisfied --> $DIR/defaults-unsound-62211-1.rs:41:9 | +LL | trait UncheckedCopy: Sized { + | ------------- +... +LL | + Deref + | ------------------- required by this bound in `UncheckedCopy` +... LL | impl UncheckedCopy for T {} | ^^^^^^^^^^^^^ the trait `std::ops::Deref` is not implemented for `T` | + = note: required because of the requirements on the impl of `std::ops::Deref` for `::Output` help: consider restricting type parameter `T` | LL | impl UncheckedCopy for T {} @@ -66,10 +80,17 @@ LL | impl UncheckedCopy for T {} error[E0277]: cannot add-assign `&'static str` to `T` --> $DIR/defaults-unsound-62211-1.rs:41:9 | +LL | trait UncheckedCopy: Sized { + | ------------- +... +LL | + AddAssign<&'static str> + | ----------------------- required by this bound in `UncheckedCopy` +... LL | impl UncheckedCopy for T {} | ^^^^^^^^^^^^^ no implementation for `T += &'static str` | = help: the trait `std::ops::AddAssign<&'static str>` is not implemented for `T` + = note: required because of the requirements on the impl of `std::ops::AddAssign<&'static str>` for `::Output` help: consider restricting type parameter `T` | LL | impl> UncheckedCopy for T {} @@ -78,9 +99,16 @@ LL | impl> UncheckedCopy for T {} error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/defaults-unsound-62211-1.rs:41:9 | +LL | trait UncheckedCopy: Sized { + | ------------- +... +LL | type Output: Copy + | ---- required by this bound in `UncheckedCopy` +... LL | impl UncheckedCopy for T {} | ^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` | + = note: required because of the requirements on the impl of `std::marker::Copy` for `::Output` help: consider restricting type parameter `T` | LL | impl UncheckedCopy for T {} diff --git a/src/test/ui/associated-types/defaults-unsound-62211-2.stderr b/src/test/ui/associated-types/defaults-unsound-62211-2.stderr index 1dcfbf538e4c7..c311a9f456e79 100644 --- a/src/test/ui/associated-types/defaults-unsound-62211-2.stderr +++ b/src/test/ui/associated-types/defaults-unsound-62211-2.stderr @@ -42,11 +42,18 @@ LL | + Display = Self; error[E0277]: `T` doesn't implement `std::fmt::Display` --> $DIR/defaults-unsound-62211-2.rs:41:9 | +LL | trait UncheckedCopy: Sized { + | ------------- +... +LL | + Display = Self; + | ------- required by this bound in `UncheckedCopy` +... LL | impl UncheckedCopy for T {} | ^^^^^^^^^^^^^ `T` cannot be formatted with the default formatter | = help: the trait `std::fmt::Display` is not implemented for `T` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead + = note: required because of the requirements on the impl of `std::fmt::Display` for `::Output` help: consider restricting type parameter `T` | LL | impl UncheckedCopy for T {} @@ -55,9 +62,16 @@ LL | impl UncheckedCopy for T {} error[E0277]: the trait bound `T: std::ops::Deref` is not satisfied --> $DIR/defaults-unsound-62211-2.rs:41:9 | +LL | trait UncheckedCopy: Sized { + | ------------- +... +LL | + Deref + | ------------------- required by this bound in `UncheckedCopy` +... LL | impl UncheckedCopy for T {} | ^^^^^^^^^^^^^ the trait `std::ops::Deref` is not implemented for `T` | + = note: required because of the requirements on the impl of `std::ops::Deref` for `::Output` help: consider restricting type parameter `T` | LL | impl UncheckedCopy for T {} @@ -66,10 +80,17 @@ LL | impl UncheckedCopy for T {} error[E0277]: cannot add-assign `&'static str` to `T` --> $DIR/defaults-unsound-62211-2.rs:41:9 | +LL | trait UncheckedCopy: Sized { + | ------------- +... +LL | + AddAssign<&'static str> + | ----------------------- required by this bound in `UncheckedCopy` +... LL | impl UncheckedCopy for T {} | ^^^^^^^^^^^^^ no implementation for `T += &'static str` | = help: the trait `std::ops::AddAssign<&'static str>` is not implemented for `T` + = note: required because of the requirements on the impl of `std::ops::AddAssign<&'static str>` for `::Output` help: consider restricting type parameter `T` | LL | impl> UncheckedCopy for T {} @@ -78,9 +99,16 @@ LL | impl> UncheckedCopy for T {} error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/defaults-unsound-62211-2.rs:41:9 | +LL | trait UncheckedCopy: Sized { + | ------------- +... +LL | type Output: Copy + | ---- required by this bound in `UncheckedCopy` +... LL | impl UncheckedCopy for T {} | ^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` | + = note: required because of the requirements on the impl of `std::marker::Copy` for `::Output` help: consider restricting type parameter `T` | LL | impl UncheckedCopy for T {} diff --git a/src/test/ui/associated-types/issue-43924.stderr b/src/test/ui/associated-types/issue-43924.stderr index 75a5b3f3551cb..38dd8b66a6ed5 100644 --- a/src/test/ui/associated-types/issue-43924.stderr +++ b/src/test/ui/associated-types/issue-43924.stderr @@ -9,14 +9,28 @@ LL | type Out: Default + ToString + ?Sized = dyn ToString; error[E0277]: the trait bound `(dyn std::string::ToString + 'static): std::default::Default` is not satisfied --> $DIR/issue-43924.rs:10:6 | +LL | trait Foo { + | --- +LL | type Out: Default + ToString + ?Sized = dyn ToString; + | ------- required by this bound in `Foo` +... LL | impl Foo for () {} | ^^^^^^^^ the trait `std::default::Default` is not implemented for `(dyn std::string::ToString + 'static)` + | + = note: required because of the requirements on the impl of `std::default::Default` for `<() as Foo>::Out` error[E0277]: the trait bound `(dyn std::string::ToString + 'static): std::default::Default` is not satisfied --> $DIR/issue-43924.rs:11:6 | +LL | trait Foo { + | --- +LL | type Out: Default + ToString + ?Sized = dyn ToString; + | ------- required by this bound in `Foo` +... LL | impl Foo for () {} | ^^^^^^^^ the trait `std::default::Default` is not implemented for `(dyn std::string::ToString + 'static)` + | + = note: required because of the requirements on the impl of `std::default::Default` for `<() as Foo>::Out` error: aborting due to 3 previous errors diff --git a/src/test/ui/associated-types/issue-65774-1.stderr b/src/test/ui/associated-types/issue-65774-1.stderr index 559136be705e2..ae3ebe811e2ab 100644 --- a/src/test/ui/associated-types/issue-65774-1.stderr +++ b/src/test/ui/associated-types/issue-65774-1.stderr @@ -9,8 +9,15 @@ LL | type MpuConfig: MyDisplay = T; error[E0277]: the trait bound `T: MyDisplay` is not satisfied --> $DIR/issue-65774-1.rs:16:6 | +LL | trait MPU { + | --- +LL | type MpuConfig: MyDisplay = T; + | --------- required by this bound in `MPU` +... LL | impl MPU for S { } | ^^^ the trait `MyDisplay` is not implemented for `T` + | + = note: required because of the requirements on the impl of `MyDisplay` for `::MpuConfig` error: aborting due to 2 previous errors diff --git a/src/test/ui/associated-types/issue-65774-2.stderr b/src/test/ui/associated-types/issue-65774-2.stderr index cb515964226a5..dadf229bd5d16 100644 --- a/src/test/ui/associated-types/issue-65774-2.stderr +++ b/src/test/ui/associated-types/issue-65774-2.stderr @@ -9,8 +9,15 @@ LL | type MpuConfig: MyDisplay = T; error[E0277]: the trait bound `T: MyDisplay` is not satisfied --> $DIR/issue-65774-2.rs:16:6 | +LL | trait MPU { + | --- +LL | type MpuConfig: MyDisplay = T; + | --------- required by this bound in `MPU` +... LL | impl MPU for S { } | ^^^ the trait `MyDisplay` is not implemented for `T` + | + = note: required because of the requirements on the impl of `MyDisplay` for `::MpuConfig` error: aborting due to 2 previous errors diff --git a/src/test/ui/builtin-superkinds/builtin-superkinds-double-superkind.stderr b/src/test/ui/builtin-superkinds/builtin-superkinds-double-superkind.stderr index ea5215e458d65..b1437a3669279 100644 --- a/src/test/ui/builtin-superkinds/builtin-superkinds-double-superkind.stderr +++ b/src/test/ui/builtin-superkinds/builtin-superkinds-double-superkind.stderr @@ -1,11 +1,15 @@ error[E0277]: `T` cannot be sent between threads safely --> $DIR/builtin-superkinds-double-superkind.rs:6:24 | +LL | trait Foo : Send+Sync { } + | ---- required by this bound in `Foo` +LL | LL | impl Foo for (T,) { } | ^^^ `T` cannot be sent between threads safely | = help: within `(T,)`, the trait `std::marker::Send` is not implemented for `T` = note: required because it appears within the type `(T,)` + = note: required because of the requirements on the impl of `std::marker::Send` for `(T,)` help: consider further restricting this bound | LL | impl Foo for (T,) { } @@ -14,11 +18,15 @@ LL | impl Foo for (T,) { } error[E0277]: `T` cannot be shared between threads safely --> $DIR/builtin-superkinds-double-superkind.rs:9:16 | +LL | trait Foo : Send+Sync { } + | ---- required by this bound in `Foo` +... LL | impl Foo for (T,T) { } | ^^^ `T` cannot be shared between threads safely | = help: within `(T, T)`, the trait `std::marker::Sync` is not implemented for `T` = note: required because it appears within the type `(T, T)` + = note: required because of the requirements on the impl of `std::marker::Sync` for `(T, T)` help: consider further restricting this bound | LL | impl Foo for (T,T) { } diff --git a/src/test/ui/builtin-superkinds/builtin-superkinds-in-metadata.stderr b/src/test/ui/builtin-superkinds/builtin-superkinds-in-metadata.stderr index ba6595f68d5cc..8555c843a9342 100644 --- a/src/test/ui/builtin-superkinds/builtin-superkinds-in-metadata.stderr +++ b/src/test/ui/builtin-superkinds/builtin-superkinds-in-metadata.stderr @@ -3,9 +3,15 @@ error[E0277]: `T` cannot be sent between threads safely | LL | impl RequiresRequiresShareAndSend for X { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `T` cannot be sent between threads safely + | + ::: $DIR/auxiliary/trait_superkinds_in_metadata.rs:7:58 + | +LL | pub trait RequiresRequiresShareAndSend : RequiresShare + Send { } + | ---- required by this bound in `trait_superkinds_in_metadata::RequiresRequiresShareAndSend` | = help: within `X`, the trait `std::marker::Send` is not implemented for `T` = note: required because it appears within the type `X` + = note: required because of the requirements on the impl of `std::marker::Send` for `X` help: consider further restricting this bound | LL | impl RequiresRequiresShareAndSend for X { } diff --git a/src/test/ui/builtin-superkinds/builtin-superkinds-simple.stderr b/src/test/ui/builtin-superkinds/builtin-superkinds-simple.stderr index a0ff64077c4b3..b4f22f2d68fc9 100644 --- a/src/test/ui/builtin-superkinds/builtin-superkinds-simple.stderr +++ b/src/test/ui/builtin-superkinds/builtin-superkinds-simple.stderr @@ -1,10 +1,14 @@ error[E0277]: `std::rc::Rc` cannot be sent between threads safely --> $DIR/builtin-superkinds-simple.rs:6:6 | +LL | trait Foo : Send { } + | ---- required by this bound in `Foo` +LL | LL | impl Foo for std::rc::Rc { } | ^^^ `std::rc::Rc` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `std::rc::Rc` + = note: required because of the requirements on the impl of `std::marker::Send` for `std::rc::Rc` error: aborting due to previous error diff --git a/src/test/ui/builtin-superkinds/builtin-superkinds-typaram-not-send.stderr b/src/test/ui/builtin-superkinds/builtin-superkinds-typaram-not-send.stderr index bef33d1fd05d3..1334997c3d93b 100644 --- a/src/test/ui/builtin-superkinds/builtin-superkinds-typaram-not-send.stderr +++ b/src/test/ui/builtin-superkinds/builtin-superkinds-typaram-not-send.stderr @@ -1,10 +1,14 @@ error[E0277]: `T` cannot be sent between threads safely --> $DIR/builtin-superkinds-typaram-not-send.rs:5:24 | +LL | trait Foo : Send { } + | ---- required by this bound in `Foo` +LL | LL | impl Foo for T { } | ^^^ `T` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `T` + = note: required because of the requirements on the impl of `std::marker::Send` for `T` help: consider further restricting this bound | LL | impl Foo for T { } diff --git a/src/test/ui/dst/dst-sized-trait-param.stderr b/src/test/ui/dst/dst-sized-trait-param.stderr index 40dc9978f367b..14c7d02c2586b 100644 --- a/src/test/ui/dst/dst-sized-trait-param.stderr +++ b/src/test/ui/dst/dst-sized-trait-param.stderr @@ -1,20 +1,28 @@ error[E0277]: the size for values of type `[isize]` cannot be known at compilation time --> $DIR/dst-sized-trait-param.rs:7:6 | +LL | trait Foo : Sized { fn take(self, x: &T) { } } // Note: T is sized + | - required by this bound in `Foo` +LL | LL | impl Foo<[isize]> for usize { } | ^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[isize]` = note: to learn more, visit + = note: required because of the requirements on the impl of `std::marker::Sized` for `[isize]` error[E0277]: the size for values of type `[usize]` cannot be known at compilation time --> $DIR/dst-sized-trait-param.rs:10:6 | +LL | trait Foo : Sized { fn take(self, x: &T) { } } // Note: T is sized + | ----- required by this bound in `Foo` +... LL | impl Foo for [usize] { } | ^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[usize]` = note: to learn more, visit + = note: required because of the requirements on the impl of `std::marker::Sized` for `[usize]` error: aborting due to 2 previous errors diff --git a/src/test/ui/generic-associated-types/construct_with_other_type.stderr b/src/test/ui/generic-associated-types/construct_with_other_type.stderr index bad746f7ef121..f27bc4d68d441 100644 --- a/src/test/ui/generic-associated-types/construct_with_other_type.stderr +++ b/src/test/ui/generic-associated-types/construct_with_other_type.stderr @@ -1,12 +1,19 @@ error[E0271]: type mismatch resolving `for<'a> <::Baa<'a> as std::ops::Deref>::Target == <::Quux<'a> as Foo>::Bar<'a, 'static>` --> $DIR/construct_with_other_type.rs:19:9 | +LL | trait Baz { + | --- +... +LL | type Baa<'a>: Deref as Foo>::Bar<'a, 'static>> where Self: 'a; + | -------------------------------------------------- required by this bound in `Baz` +... LL | impl Baz for T where T: Foo { | ^^^ expected type parameter `T`, found associated type | = note: expected associated type `::Bar<'_, 'static>` found associated type `<::Quux<'_> as Foo>::Bar<'_, 'static>` = note: you might be missing a type parameter or trait bound + = note: required because of the requirements on the impl of `Baz` for `T` error: aborting due to previous error diff --git a/src/test/ui/generics/issue-61631-default-type-param-can-reference-self-in-trait.stderr b/src/test/ui/generics/issue-61631-default-type-param-can-reference-self-in-trait.stderr index ea0664c48d4d8..3f06dfdccd868 100644 --- a/src/test/ui/generics/issue-61631-default-type-param-can-reference-self-in-trait.stderr +++ b/src/test/ui/generics/issue-61631-default-type-param-can-reference-self-in-trait.stderr @@ -1,11 +1,15 @@ error[E0277]: the size for values of type `[()]` cannot be known at compilation time --> $DIR/issue-61631-default-type-param-can-reference-self-in-trait.rs:19:6 | +LL | trait Tsized {} + | - required by this bound in `Tsized` +LL | LL | impl Tsized for () {} | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[()]` = note: to learn more, visit + = note: required because of the requirements on the impl of `std::marker::Sized` for `[()]` error: aborting due to previous error diff --git a/src/test/ui/impl-bounds-checking.stderr b/src/test/ui/impl-bounds-checking.stderr index b52f3d6b839d4..6453508410ead 100644 --- a/src/test/ui/impl-bounds-checking.stderr +++ b/src/test/ui/impl-bounds-checking.stderr @@ -1,8 +1,13 @@ error[E0277]: the trait bound `isize: Clone2` is not satisfied --> $DIR/impl-bounds-checking.rs:10:6 | +LL | trait Getter { + | ------ required by this bound in `Getter` +... LL | impl Getter for isize { | ^^^^^^^^^^^^^ the trait `Clone2` is not implemented for `isize` + | + = note: required because of the requirements on the impl of `Clone2` for `isize` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-10412.stderr b/src/test/ui/issues/issue-10412.stderr index 0793dd99b4d12..9c50b4af9a993 100644 --- a/src/test/ui/issues/issue-10412.stderr +++ b/src/test/ui/issues/issue-10412.stderr @@ -49,11 +49,15 @@ LL | impl<'self> Serializable for &'self str { error[E0277]: the size for values of type `str` cannot be known at compilation time --> $DIR/issue-10412.rs:6:13 | +LL | trait Serializable<'self, T> { + | - required by this bound in `Serializable` +... LL | impl<'self> Serializable for &'self str { | ^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` = note: to learn more, visit + = note: required because of the requirements on the impl of `std::marker::Sized` for `str` error: aborting due to 9 previous errors diff --git a/src/test/ui/issues/issue-43784-supertrait.stderr b/src/test/ui/issues/issue-43784-supertrait.stderr index 2fb0583ee7d59..86c0f8f597bef 100644 --- a/src/test/ui/issues/issue-43784-supertrait.stderr +++ b/src/test/ui/issues/issue-43784-supertrait.stderr @@ -4,6 +4,7 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied LL | impl Complete for T {} | ^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` | + = note: required because of the requirements on the impl of `std::marker::Copy` for `T` help: consider restricting type parameter `T` | LL | impl Complete for T {} diff --git a/src/test/ui/malformed/malformed-derive-entry.stderr b/src/test/ui/malformed/malformed-derive-entry.stderr index ddc75c905ac20..74606b71bf12e 100644 --- a/src/test/ui/malformed/malformed-derive-entry.stderr +++ b/src/test/ui/malformed/malformed-derive-entry.stderr @@ -21,7 +21,13 @@ error[E0277]: the trait bound `Test1: std::clone::Clone` is not satisfied | LL | #[derive(Copy(Bad))] | ^^^^ the trait `std::clone::Clone` is not implemented for `Test1` + | + ::: $SRC_DIR/libcore/marker.rs:LL:COL | +LL | pub trait Copy: Clone { + | ----- required by this bound in `std::marker::Copy` + | + = note: required because of the requirements on the impl of `std::clone::Clone` for `Test1` = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Test2: std::clone::Clone` is not satisfied @@ -29,7 +35,13 @@ error[E0277]: the trait bound `Test2: std::clone::Clone` is not satisfied | LL | #[derive(Copy="bad")] | ^^^^ the trait `std::clone::Clone` is not implemented for `Test2` + | + ::: $SRC_DIR/libcore/marker.rs:LL:COL + | +LL | pub trait Copy: Clone { + | ----- required by this bound in `std::marker::Copy` | + = note: required because of the requirements on the impl of `std::clone::Clone` for `Test2` = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 5 previous errors diff --git a/src/test/ui/specialization/defaultimpl/specialization-wfcheck.stderr b/src/test/ui/specialization/defaultimpl/specialization-wfcheck.stderr index 4e4cad624754e..91e45df8d3ef9 100644 --- a/src/test/ui/specialization/defaultimpl/specialization-wfcheck.stderr +++ b/src/test/ui/specialization/defaultimpl/specialization-wfcheck.stderr @@ -1,9 +1,13 @@ error[E0277]: the trait bound `U: std::cmp::Eq` is not satisfied --> $DIR/specialization-wfcheck.rs:7:17 | +LL | trait Foo<'a, T: Eq + 'a> { } + | -- required by this bound in `Foo` +LL | LL | default impl Foo<'static, U> for () {} | ^^^^^^^^^^^^^^^ the trait `std::cmp::Eq` is not implemented for `U` | + = note: required because of the requirements on the impl of `std::cmp::Eq` for `U` help: consider restricting type parameter `U` | LL | default impl Foo<'static, U> for () {} diff --git a/src/test/ui/traits/traits-assoc-type-in-supertrait-bad.stderr b/src/test/ui/traits/traits-assoc-type-in-supertrait-bad.stderr index 5d0fb6b44cb29..441fa9f27929d 100644 --- a/src/test/ui/traits/traits-assoc-type-in-supertrait-bad.stderr +++ b/src/test/ui/traits/traits-assoc-type-in-supertrait-bad.stderr @@ -1,8 +1,13 @@ error[E0271]: type mismatch resolving ` as std::iter::Iterator>::Item == u32` --> $DIR/traits-assoc-type-in-supertrait-bad.rs:11:6 | +LL | pub trait Foo: Iterator::Key> { + | ----------------------- required by this bound in `Foo` +... LL | impl Foo for IntoIter { | ^^^ expected `i32`, found `u32` + | + = note: required because of the requirements on the impl of `Foo` for `std::vec::IntoIter` error: aborting due to previous error diff --git a/src/test/ui/unsized/unsized-trait-impl-trait-arg.stderr b/src/test/ui/unsized/unsized-trait-impl-trait-arg.stderr index b37d9f9d5369e..502dd20105869 100644 --- a/src/test/ui/unsized/unsized-trait-impl-trait-arg.stderr +++ b/src/test/ui/unsized/unsized-trait-impl-trait-arg.stderr @@ -1,6 +1,9 @@ error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized-trait-impl-trait-arg.rs:8:17 | +LL | trait T2 { + | - required by this bound in `T2` +... LL | impl T2 for S4 { | - ^^^^^ doesn't have a size known at compile-time | | @@ -8,6 +11,7 @@ LL | impl T2 for S4 { | = help: the trait `std::marker::Sized` is not implemented for `X` = note: to learn more, visit + = note: required because of the requirements on the impl of `std::marker::Sized` for `X` error: aborting due to previous error diff --git a/src/test/ui/unsized7.stderr b/src/test/ui/unsized7.stderr index 0f71c5f6f8fe6..cd30c98f55d0d 100644 --- a/src/test/ui/unsized7.stderr +++ b/src/test/ui/unsized7.stderr @@ -1,6 +1,9 @@ error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized7.rs:12:21 | +LL | trait T1 { + | - required by this bound in `T1` +... LL | impl T1 for S3 { | - ^^^^^ doesn't have a size known at compile-time | | @@ -8,6 +11,7 @@ LL | impl T1 for S3 { | = help: the trait `std::marker::Sized` is not implemented for `X` = note: to learn more, visit + = note: required because of the requirements on the impl of `std::marker::Sized` for `X` error: aborting due to previous error From 6bc55c701f50ccdc8605b37cdf62d02ec596b108 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Thu, 9 Apr 2020 13:07:22 -0700 Subject: [PATCH 2/4] Remove `AssocTypeBound` and propagate bound `Span`s --- src/librustc_middle/traits/mod.rs | 9 - .../traits/structural_impls.rs | 1 - .../traits/error_reporting/suggestions.rs | 9 - src/librustc_trait_selection/traits/wf.rs | 229 ++++-------------- src/librustc_typeck/astconv.rs | 2 +- ...rojection-from-multiple-supertraits.stderr | 4 +- ...int-at-type-on-obligation-failure-2.stderr | 36 ++- ...point-at-type-on-obligation-failure.stderr | 9 +- .../construct_with_other_type.stderr | 7 - .../generic-associated-types/iterable.stderr | 22 +- .../issues/issue-43784-associated-type.stderr | 10 +- src/test/ui/issues/issue-65673.stderr | 11 +- ...issing-assoc-type-bound-restriction.stderr | 14 +- .../ui/traits/cycle-cache-err-60010.stderr | 11 +- .../traits-assoc-type-in-supertrait-bad.rs | 4 +- ...traits-assoc-type-in-supertrait-bad.stderr | 11 +- .../unboxed-closure-sugar-wrong-trait.stderr | 4 +- 17 files changed, 106 insertions(+), 287 deletions(-) diff --git a/src/librustc_middle/traits/mod.rs b/src/librustc_middle/traits/mod.rs index c129b574fd38a..47c8aa023f043 100644 --- a/src/librustc_middle/traits/mod.rs +++ b/src/librustc_middle/traits/mod.rs @@ -257,8 +257,6 @@ pub enum ObligationCauseCode<'tcx> { /// #[feature(trivial_bounds)] is not enabled TrivialBound, - - AssocTypeBound(Box), } impl ObligationCauseCode<'_> { @@ -272,13 +270,6 @@ impl ObligationCauseCode<'_> { } } -#[derive(Clone, Debug, PartialEq, Eq, Hash)] -pub struct AssocTypeBoundData { - pub impl_span: Option, - pub original: Span, - pub bounds: Vec, -} - // `ObligationCauseCode` is used a lot. Make sure it doesn't unintentionally get bigger. #[cfg(target_arch = "x86_64")] static_assert_size!(ObligationCauseCode<'_>, 32); diff --git a/src/librustc_middle/traits/structural_impls.rs b/src/librustc_middle/traits/structural_impls.rs index b1fb02a67b3ff..b7d0f6666bd38 100644 --- a/src/librustc_middle/traits/structural_impls.rs +++ b/src/librustc_middle/traits/structural_impls.rs @@ -501,7 +501,6 @@ impl<'a, 'tcx> Lift<'tcx> for traits::ObligationCauseCode<'a> { super::MethodReceiver => Some(super::MethodReceiver), super::BlockTailExpression(id) => Some(super::BlockTailExpression(id)), super::TrivialBound => Some(super::TrivialBound), - super::AssocTypeBound(ref data) => Some(super::AssocTypeBound(data.clone())), } } } diff --git a/src/librustc_trait_selection/traits/error_reporting/suggestions.rs b/src/librustc_trait_selection/traits/error_reporting/suggestions.rs index 254db6cb869b1..52bf2e6ad490c 100644 --- a/src/librustc_trait_selection/traits/error_reporting/suggestions.rs +++ b/src/librustc_trait_selection/traits/error_reporting/suggestions.rs @@ -1684,15 +1684,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { err.help("add `#![feature(trivial_bounds)]` to the crate attributes to enable"); } } - ObligationCauseCode::AssocTypeBound(ref data) => { - err.span_label(data.original, "associated type defined here"); - if let Some(sp) = data.impl_span { - err.span_label(sp, "in this `impl` item"); - } - for sp in &data.bounds { - err.span_label(*sp, "restricted in this bound"); - } - } } } diff --git a/src/librustc_trait_selection/traits/wf.rs b/src/librustc_trait_selection/traits/wf.rs index d341909ef7f8b..0cda92b7dc8b4 100644 --- a/src/librustc_trait_selection/traits/wf.rs +++ b/src/librustc_trait_selection/traits/wf.rs @@ -1,12 +1,11 @@ use crate::infer::InferCtxt; use crate::opaque_types::required_region_bounds; -use crate::traits::{self, AssocTypeBoundData}; +use crate::traits; use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_hir::lang_items; use rustc_middle::ty::subst::{GenericArgKind, SubstsRef}; use rustc_middle::ty::{self, ToPredicate, Ty, TyCtxt, TypeFoldable, WithConstness}; -use rustc_span::symbol::{kw, Ident}; use rustc_span::Span; use std::rc::Rc; @@ -143,137 +142,57 @@ fn extend_cause_with_original_assoc_item_obligation<'tcx>( pred: &ty::Predicate<'_>, mut trait_assoc_items: impl Iterator, ) { - let trait_item = - tcx.hir().as_local_hir_id(trait_ref.def_id).and_then(|trait_id| tcx.hir().find(trait_id)); - let (trait_name, trait_generics) = match trait_item { - Some(hir::Node::Item(hir::Item { - ident, - kind: hir::ItemKind::Trait(.., generics, _, _), - .. - })) - | Some(hir::Node::Item(hir::Item { - ident, - kind: hir::ItemKind::TraitAlias(generics, _), - .. - })) => (Some(ident), Some(generics)), - _ => (None, None), + debug!( + "extended_cause_with_original_assoc_item_obligation {:?} {:?} {:?} {:?}", + trait_ref, item, cause, pred + ); + let items = match item { + Some(hir::Item { kind: hir::ItemKind::Impl { items, .. }, .. }) => items, + _ => return, }; - - let item_span = item.map(|i| tcx.sess.source_map().guess_head_span(i.span)); + let fix_span = + |impl_item_ref: &hir::ImplItemRef<'_>| match tcx.hir().impl_item(impl_item_ref.id).kind { + hir::ImplItemKind::Const(ty, _) | hir::ImplItemKind::TyAlias(ty) => ty.span, + _ => impl_item_ref.span, + }; match pred { ty::Predicate::Projection(proj) => { // The obligation comes not from the current `impl` nor the `trait` being // implemented, but rather from a "second order" obligation, like in - // `src/test/ui/associated-types/point-at-type-on-obligation-failure.rs`: - // - // error[E0271]: type mismatch resolving `::Ok == ()` - // --> $DIR/point-at-type-on-obligation-failure.rs:13:5 - // | - // LL | type Ok; - // | -- associated type defined here - // ... - // LL | impl Bar for Foo { - // | ---------------- in this `impl` item - // LL | type Ok = (); - // | ^^^^^^^^^^^^^ expected `u32`, found `()` - // | - // = note: expected type `u32` - // found type `()` - // - // FIXME: we would want to point a span to all places that contributed to this - // obligation. In the case above, it should be closer to: - // - // error[E0271]: type mismatch resolving `::Ok == ()` - // --> $DIR/point-at-type-on-obligation-failure.rs:13:5 - // | - // LL | type Ok; - // | -- associated type defined here - // LL | type Sibling: Bar2; - // | -------------------------------- obligation set here - // ... - // LL | impl Bar for Foo { - // | ---------------- in this `impl` item - // LL | type Ok = (); - // | ^^^^^^^^^^^^^ expected `u32`, found `()` - // ... - // LL | impl Bar2 for Foo2 { - // | ---------------- in this `impl` item - // LL | type Ok = u32; - // | -------------- obligation set here - // | - // = note: expected type `u32` - // found type `()` - if let Some(hir::ItemKind::Impl { items, .. }) = item.map(|i| &i.kind) { - let trait_assoc_item = tcx.associated_item(proj.projection_def_id()); - if let Some(impl_item) = - items.iter().find(|item| item.ident == trait_assoc_item.ident) - { - cause.span = impl_item.span; - cause.code = traits::AssocTypeBound(Box::new(AssocTypeBoundData { - impl_span: item_span, - original: trait_assoc_item.ident.span, - bounds: vec![], - })); + // `src/test/ui/associated-types/point-at-type-on-obligation-failure.rs`. + let trait_assoc_item = tcx.associated_item(proj.projection_def_id()); + if let Some(impl_item_span) = + items.iter().find(|item| item.ident == trait_assoc_item.ident).map(fix_span) + { + cause.span = impl_item_span; + } else { + let kind = &proj.ty().skip_binder().kind; + if let ty::Projection(projection_ty) = kind { + // This happens when an associated type has a projection coming from another + // associated type. See `traits-assoc-type-in-supertrait-bad.rs`. + let trait_assoc_item = tcx.associated_item(projection_ty.item_def_id); + if let Some(impl_item_span) = + items.iter().find(|item| item.ident == trait_assoc_item.ident).map(fix_span) + { + cause.span = impl_item_span; + } } } } - ty::Predicate::Trait(proj, _) => { - // An associated item obligation born out of the `trait` failed to be met. - // Point at the `impl` that failed the obligation, the associated item that - // needed to meet the obligation, and the definition of that associated item, - // which should hold the obligation in most cases. An example can be seen in - // `src/test/ui/associated-types/point-at-type-on-obligation-failure-2.rs`: - // - // error[E0277]: the trait bound `bool: Bar` is not satisfied - // --> $DIR/point-at-type-on-obligation-failure-2.rs:8:5 - // | - // LL | type Assoc: Bar; - // | ----- associated type defined here - // ... - // LL | impl Foo for () { - // | --------------- in this `impl` item - // LL | type Assoc = bool; - // | ^^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `bool` - // - // If the obligation comes from the where clause in the `trait`, we point at it: - // - // error[E0277]: the trait bound `bool: Bar` is not satisfied - // --> $DIR/point-at-type-on-obligation-failure-2.rs:8:5 - // | - // | trait Foo where >::Assoc: Bar { - // | -------------------------- restricted in this bound - // LL | type Assoc; - // | ----- associated type defined here - // ... - // LL | impl Foo for () { - // | --------------- in this `impl` item - // LL | type Assoc = bool; - // | ^^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `bool` - if let ( - ty::Projection(ty::ProjectionTy { item_def_id, .. }), - Some(hir::ItemKind::Impl { items, .. }), - ) = (&proj.skip_binder().self_ty().kind, item.map(|i| &i.kind)) + ty::Predicate::Trait(pred, _) => { + // An associated item obligation born out of the `trait` failed to be met. An example + // can be seen in `ui/associated-types/point-at-type-on-obligation-failure-2.rs`. + debug!("extended_cause_with_original_assoc_item_obligation trait proj {:?}", pred); + if let ty::Projection(ty::ProjectionTy { item_def_id, .. }) = + &pred.skip_binder().self_ty().kind { - if let Some((impl_item, trait_assoc_item)) = trait_assoc_items + if let Some(impl_item_span) = trait_assoc_items .find(|i| i.def_id == *item_def_id) .and_then(|trait_assoc_item| { - items - .iter() - .find(|i| i.ident == trait_assoc_item.ident) - .map(|impl_item| (impl_item, trait_assoc_item)) + items.iter().find(|i| i.ident == trait_assoc_item.ident).map(fix_span) }) { - let bounds = trait_generics - .map(|generics| { - get_generic_bound_spans(&generics, trait_name, trait_assoc_item.ident) - }) - .unwrap_or_else(Vec::new); - cause.span = impl_item.span; - cause.code = traits::AssocTypeBound(Box::new(AssocTypeBoundData { - impl_span: item_span, - original: trait_assoc_item.ident.span, - bounds, - })); + cause.span = impl_item_span; } } } @@ -307,6 +226,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { let tcx = self.infcx.tcx; let obligations = self.nominal_obligations(trait_ref.def_id, trait_ref.substs); + debug!("compute_trait_ref obligations {:?}", obligations); let cause = self.cause(traits::MiscObligation); let param_env = self.param_env; @@ -315,16 +235,16 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { if let Elaborate::All = elaborate { let implied_obligations = traits::util::elaborate_obligations(tcx, obligations.clone()); let implied_obligations = implied_obligations.map(|obligation| { + debug!("compute_trait_ref implied_obligation {:?}", obligation); + debug!("compute_trait_ref implied_obligation cause {:?}", obligation.cause); let mut cause = cause.clone(); - let parent_trait_ref = obligation - .predicate - .to_opt_poly_trait_ref() - .unwrap_or_else(|| ty::Binder::dummy(*trait_ref)); - let derived_cause = traits::DerivedObligationCause { - parent_trait_ref, - parent_code: Rc::new(obligation.cause.code.clone()), - }; - cause.code = traits::ObligationCauseCode::ImplDerivedObligation(derived_cause); + if let Some(parent_trait_ref) = obligation.predicate.to_opt_poly_trait_ref() { + let derived_cause = traits::DerivedObligationCause { + parent_trait_ref, + parent_code: Rc::new(obligation.cause.code.clone()), + }; + cause.code = traits::ObligationCauseCode::ImplDerivedObligation(derived_cause); + } extend_cause_with_original_assoc_item_obligation( tcx, trait_ref, @@ -333,6 +253,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { &obligation.predicate, tcx.associated_items(trait_ref.def_id).in_definition_order().copied(), ); + debug!("compute_trait_ref new cause {:?}", cause); traits::Obligation::new(cause, param_env, obligation.predicate) }); self.out.extend(implied_obligations); @@ -719,53 +640,3 @@ pub fn object_region_bounds<'tcx>( required_region_bounds(tcx, open_ty, predicates) } - -/// Find the span of a generic bound affecting an associated type. -fn get_generic_bound_spans( - generics: &hir::Generics<'_>, - trait_name: Option<&Ident>, - assoc_item_name: Ident, -) -> Vec { - let mut bounds = vec![]; - for clause in generics.where_clause.predicates.iter() { - if let hir::WherePredicate::BoundPredicate(pred) = clause { - match &pred.bounded_ty.kind { - hir::TyKind::Path(hir::QPath::Resolved(Some(ty), path)) => { - let mut s = path.segments.iter(); - if let (a, Some(b), None) = (s.next(), s.next(), s.next()) { - if a.map(|s| &s.ident) == trait_name - && b.ident == assoc_item_name - && is_self_path(&ty.kind) - { - // `::Bar` - bounds.push(pred.span); - } - } - } - hir::TyKind::Path(hir::QPath::TypeRelative(ty, segment)) => { - if segment.ident == assoc_item_name { - if is_self_path(&ty.kind) { - // `Self::Bar` - bounds.push(pred.span); - } - } - } - _ => {} - } - } - } - bounds -} - -fn is_self_path(kind: &hir::TyKind<'_>) -> bool { - if let hir::TyKind::Path(hir::QPath::Resolved(None, path)) = kind { - let mut s = path.segments.iter(); - if let (Some(segment), None) = (s.next(), s.next()) { - if segment.ident.name == kw::SelfUpper { - // `type(Self)` - return true; - } - } - } - false -} diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 4a8cd9e91e278..3aaa84da75261 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -1045,7 +1045,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { bounds, speculative, &mut dup_bindings, - span, + binding.span, ); // Okay to ignore `Err` because of `ErrorReported` (see above). } diff --git a/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.stderr b/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.stderr index 8d0cd57fad442..b6a88179c1f63 100644 --- a/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.stderr +++ b/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.stderr @@ -28,7 +28,7 @@ LL | fn dent(c: C, color: ::Color) { | ^^^^^^^^^^^^^^^^^^^^^ error[E0222]: ambiguous associated type `Color` in bounds of `BoxCar` - --> $DIR/associated-type-projection-from-multiple-supertraits.rs:23:30 + --> $DIR/associated-type-projection-from-multiple-supertraits.rs:23:37 | LL | type Color; | ----------- ambiguous `Color` from `Vehicle` @@ -37,7 +37,7 @@ LL | type Color; | ----------- ambiguous `Color` from `Box` ... LL | fn dent_object(c: dyn BoxCar) { - | ^^^^^^^^^^^^^^^^^^^ ambiguous associated type `Color` + | ^^^^^^^^^^^ ambiguous associated type `Color` | = help: consider introducing a new type parameter `T` and adding `where` constraints: where diff --git a/src/test/ui/associated-types/point-at-type-on-obligation-failure-2.stderr b/src/test/ui/associated-types/point-at-type-on-obligation-failure-2.stderr index 072e9dad062e0..cdc9559cd95e9 100644 --- a/src/test/ui/associated-types/point-at-type-on-obligation-failure-2.stderr +++ b/src/test/ui/associated-types/point-at-type-on-obligation-failure-2.stderr @@ -1,39 +1,37 @@ error[E0277]: the trait bound `bool: Bar` is not satisfied - --> $DIR/point-at-type-on-obligation-failure-2.rs:8:5 + --> $DIR/point-at-type-on-obligation-failure-2.rs:8:18 | +LL | trait Foo { + | --- LL | type Assoc: Bar; - | ----- associated type defined here + | --- required by this bound in `Foo` ... -LL | impl Foo for () { - | --------------- in this `impl` item LL | type Assoc = bool; - | ^^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `bool` + | ^^^^ the trait `Bar` is not implemented for `bool` + | + = note: required because of the requirements on the impl of `Bar` for `<() as Foo>::Assoc` error[E0277]: the trait bound `bool: Bar` is not satisfied - --> $DIR/point-at-type-on-obligation-failure-2.rs:16:5 + --> $DIR/point-at-type-on-obligation-failure-2.rs:16:18 | LL | trait Baz where Self::Assoc: Bar { - | ---------------- restricted in this bound -LL | type Assoc; - | ----- associated type defined here + | --- required by this bound in `Baz` ... -LL | impl Baz for () { - | --------------- in this `impl` item LL | type Assoc = bool; - | ^^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `bool` + | ^^^^ the trait `Bar` is not implemented for `bool` + | + = note: required because of the requirements on the impl of `Bar` for `<() as Baz>::Assoc` error[E0277]: the trait bound `bool: Bar` is not satisfied - --> $DIR/point-at-type-on-obligation-failure-2.rs:24:5 + --> $DIR/point-at-type-on-obligation-failure-2.rs:24:18 | LL | trait Bat where ::Assoc: Bar { - | ------------------------- restricted in this bound -LL | type Assoc; - | ----- associated type defined here + | --- required by this bound in `Bat` ... -LL | impl Bat for () { - | --------------- in this `impl` item LL | type Assoc = bool; - | ^^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `bool` + | ^^^^ the trait `Bar` is not implemented for `bool` + | + = note: required because of the requirements on the impl of `Bar` for `<() as Bat>::Assoc` error: aborting due to 3 previous errors diff --git a/src/test/ui/associated-types/point-at-type-on-obligation-failure.stderr b/src/test/ui/associated-types/point-at-type-on-obligation-failure.stderr index e86b460f818b8..818702b7afe2a 100644 --- a/src/test/ui/associated-types/point-at-type-on-obligation-failure.stderr +++ b/src/test/ui/associated-types/point-at-type-on-obligation-failure.stderr @@ -1,13 +1,8 @@ error[E0271]: type mismatch resolving `::Ok == ()` - --> $DIR/point-at-type-on-obligation-failure.rs:13:5 + --> $DIR/point-at-type-on-obligation-failure.rs:13:15 | -LL | type Ok; - | -- associated type defined here -... -LL | impl Bar for Foo { - | ---------------- in this `impl` item LL | type Ok = (); - | ^^^^^^^^^^^^^ expected `u32`, found `()` + | ^^ expected `u32`, found `()` error: aborting due to previous error diff --git a/src/test/ui/generic-associated-types/construct_with_other_type.stderr b/src/test/ui/generic-associated-types/construct_with_other_type.stderr index f27bc4d68d441..bad746f7ef121 100644 --- a/src/test/ui/generic-associated-types/construct_with_other_type.stderr +++ b/src/test/ui/generic-associated-types/construct_with_other_type.stderr @@ -1,19 +1,12 @@ error[E0271]: type mismatch resolving `for<'a> <::Baa<'a> as std::ops::Deref>::Target == <::Quux<'a> as Foo>::Bar<'a, 'static>` --> $DIR/construct_with_other_type.rs:19:9 | -LL | trait Baz { - | --- -... -LL | type Baa<'a>: Deref as Foo>::Bar<'a, 'static>> where Self: 'a; - | -------------------------------------------------- required by this bound in `Baz` -... LL | impl Baz for T where T: Foo { | ^^^ expected type parameter `T`, found associated type | = note: expected associated type `::Bar<'_, 'static>` found associated type `<::Quux<'_> as Foo>::Bar<'_, 'static>` = note: you might be missing a type parameter or trait bound - = note: required because of the requirements on the impl of `Baz` for `T` error: aborting due to previous error diff --git a/src/test/ui/generic-associated-types/iterable.stderr b/src/test/ui/generic-associated-types/iterable.stderr index dc62ee53c0630..6bc5a2319a980 100644 --- a/src/test/ui/generic-associated-types/iterable.stderr +++ b/src/test/ui/generic-associated-types/iterable.stderr @@ -1,15 +1,8 @@ error[E0271]: type mismatch resolving `for<'a> < as Iterable>::Iter<'a> as std::iter::Iterator>::Item == as Iterable>::Item<'a>` - --> $DIR/iterable.rs:15:5 + --> $DIR/iterable.rs:15:33 | -LL | impl Iterable for Vec { - | --------------------------- in this `impl` item LL | type Item<'a> where T: 'a = as Iterator>::Item; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected reference, found associated type - | - ::: $SRC_DIR/libcore/iter/traits/iterator.rs:LL:COL - | -LL | type Item; - | ---- associated type defined here + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected reference, found associated type | = note: expected reference `&T` found associated type ` as Iterable>::Item<'_>` @@ -17,17 +10,10 @@ LL | type Item; = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html error[E0271]: type mismatch resolving `for<'a> <<[T] as Iterable>::Iter<'a> as std::iter::Iterator>::Item == <[T] as Iterable>::Item<'a>` - --> $DIR/iterable.rs:27:5 + --> $DIR/iterable.rs:27:33 | -LL | impl Iterable for [T] { - | ------------------------ in this `impl` item LL | type Item<'a> where T: 'a = as Iterator>::Item; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected reference, found associated type - | - ::: $SRC_DIR/libcore/iter/traits/iterator.rs:LL:COL - | -LL | type Item; - | ---- associated type defined here + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected reference, found associated type | = note: expected reference `&T` found associated type `<[T] as Iterable>::Item<'_>` diff --git a/src/test/ui/issues/issue-43784-associated-type.stderr b/src/test/ui/issues/issue-43784-associated-type.stderr index 21cd39d01fa25..fa835f5543ded 100644 --- a/src/test/ui/issues/issue-43784-associated-type.stderr +++ b/src/test/ui/issues/issue-43784-associated-type.stderr @@ -1,14 +1,10 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied - --> $DIR/issue-43784-associated-type.rs:14:5 + --> $DIR/issue-43784-associated-type.rs:14:18 | -LL | type Assoc: Partial; - | ----- associated type defined here -... -LL | impl Complete for T { - | ---------------------- in this `impl` item LL | type Assoc = T; - | ^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` + | ^ the trait `std::marker::Copy` is not implemented for `T` | + = note: required because of the requirements on the impl of `std::marker::Copy` for `::Assoc` help: consider restricting type parameter `T` | LL | impl Complete for T { diff --git a/src/test/ui/issues/issue-65673.stderr b/src/test/ui/issues/issue-65673.stderr index a556e35b6a944..d1a490eb5657d 100644 --- a/src/test/ui/issues/issue-65673.stderr +++ b/src/test/ui/issues/issue-65673.stderr @@ -1,16 +1,17 @@ error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time - --> $DIR/issue-65673.rs:9:5 + --> $DIR/issue-65673.rs:9:16 | +LL | trait WithType { + | -------- LL | type Ctx; - | --- associated type defined here + | --------- required by this bound in `WithType` ... -LL | impl WithType for T { - | ---------------------- in this `impl` item LL | type Ctx = dyn Alias; - | ^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | ^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn Trait + 'static)` = note: to learn more, visit + = note: required because of the requirements on the impl of `std::marker::Sized` for `::Ctx` error: aborting due to previous error diff --git a/src/test/ui/suggestions/missing-assoc-type-bound-restriction.stderr b/src/test/ui/suggestions/missing-assoc-type-bound-restriction.stderr index 6b985edae9e28..2091e30f11593 100644 --- a/src/test/ui/suggestions/missing-assoc-type-bound-restriction.stderr +++ b/src/test/ui/suggestions/missing-assoc-type-bound-restriction.stderr @@ -13,20 +13,22 @@ LL | impl> Parent for ParentWrapper { | the trait `Child` is not implemented for `::Assoc` error[E0277]: the trait bound `::Assoc: Child` is not satisfied - --> $DIR/missing-assoc-type-bound-restriction.rs:20:5 + --> $DIR/missing-assoc-type-bound-restriction.rs:20:18 | +LL | trait Parent { + | ------ +LL | type Ty; LL | type Assoc: Child; - | ----- associated type defined here + | --------------- required by this bound in `Parent` ... LL | impl> Parent for ParentWrapper { - | ------------------------------------------------------- help: consider further restricting the associated type: `where ::Assoc: Child` - | | - | in this `impl` item + | - help: consider further restricting the associated type: `where ::Assoc: Child` ... LL | type Assoc = ChildWrapper; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Child` is not implemented for `::Assoc` + | ^^^^^^^^^^^^^^^^^^^^^^ the trait `Child` is not implemented for `::Assoc` | = note: required because of the requirements on the impl of `Child` for `ChildWrapper<::Assoc>` + = note: required because of the requirements on the impl of `Child< as Parent>::Ty>` for ` as Parent>::Assoc` error[E0277]: the trait bound `::Assoc: Child` is not satisfied --> $DIR/missing-assoc-type-bound-restriction.rs:20:5 diff --git a/src/test/ui/traits/cycle-cache-err-60010.stderr b/src/test/ui/traits/cycle-cache-err-60010.stderr index 295845b1146ef..9e2e5568ba249 100644 --- a/src/test/ui/traits/cycle-cache-err-60010.stderr +++ b/src/test/ui/traits/cycle-cache-err-60010.stderr @@ -7,20 +7,21 @@ LL | _parse: >::Data, = note: required because of the requirements on the impl of `Query` for `ParseQuery` error[E0275]: overflow evaluating the requirement `Runtime: std::panic::RefUnwindSafe` - --> $DIR/cycle-cache-err-60010.rs:31:5 + --> $DIR/cycle-cache-err-60010.rs:31:20 | +LL | trait Database { + | -------- LL | type Storage; - | ------- associated type defined here + | ------------- required by this bound in `Database` ... -LL | impl Database for RootDatabase { - | ------------------------------ in this `impl` item LL | type Storage = SalsaStorage; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ | = note: required because it appears within the type `RootDatabase` = note: required because of the requirements on the impl of `SourceDatabase` for `RootDatabase` = note: required because of the requirements on the impl of `Query` for `ParseQuery` = note: required because it appears within the type `SalsaStorage` + = note: required because of the requirements on the impl of `std::marker::Sized` for `::Storage` error: aborting due to 2 previous errors diff --git a/src/test/ui/traits/traits-assoc-type-in-supertrait-bad.rs b/src/test/ui/traits/traits-assoc-type-in-supertrait-bad.rs index 47d7075ac3576..579ce7cf70669 100644 --- a/src/test/ui/traits/traits-assoc-type-in-supertrait-bad.rs +++ b/src/test/ui/traits/traits-assoc-type-in-supertrait-bad.rs @@ -8,8 +8,8 @@ pub trait Foo: Iterator::Key> { type Key; } -impl Foo for IntoIter { //~ ERROR type mismatch - type Key = u32; +impl Foo for IntoIter { + type Key = u32; //~ ERROR type mismatch } fn main() { diff --git a/src/test/ui/traits/traits-assoc-type-in-supertrait-bad.stderr b/src/test/ui/traits/traits-assoc-type-in-supertrait-bad.stderr index 441fa9f27929d..604763f8e354e 100644 --- a/src/test/ui/traits/traits-assoc-type-in-supertrait-bad.stderr +++ b/src/test/ui/traits/traits-assoc-type-in-supertrait-bad.stderr @@ -1,13 +1,8 @@ error[E0271]: type mismatch resolving ` as std::iter::Iterator>::Item == u32` - --> $DIR/traits-assoc-type-in-supertrait-bad.rs:11:6 + --> $DIR/traits-assoc-type-in-supertrait-bad.rs:12:16 | -LL | pub trait Foo: Iterator::Key> { - | ----------------------- required by this bound in `Foo` -... -LL | impl Foo for IntoIter { - | ^^^ expected `i32`, found `u32` - | - = note: required because of the requirements on the impl of `Foo` for `std::vec::IntoIter` +LL | type Key = u32; + | ^^^ expected `i32`, found `u32` error: aborting due to previous error diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-trait.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-trait.stderr index ff65fd968c5e7..c81402a3dcc00 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-trait.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-trait.stderr @@ -5,10 +5,10 @@ LL | fn f isize>(x: F) {} | ^^^^^^^^^^^^ unexpected type argument error[E0220]: associated type `Output` not found for `Trait` - --> $DIR/unboxed-closure-sugar-wrong-trait.rs:5:8 + --> $DIR/unboxed-closure-sugar-wrong-trait.rs:5:24 | LL | fn f isize>(x: F) {} - | ^^^^^^^^^^^^^^^^^^^^^ associated type `Output` not found + | ^^^^^ associated type `Output` not found error: aborting due to 2 previous errors From ce936e9336afbd1ff116c64f0fdcc438b4745c54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sat, 11 Apr 2020 14:14:16 -0700 Subject: [PATCH 3/4] Do not emit note for projected derived obligations --- src/librustc_middle/traits/mod.rs | 7 ++++++- src/librustc_middle/traits/structural_impls.rs | 1 + .../traits/error_reporting/on_unimplemented.rs | 3 ++- .../traits/error_reporting/suggestions.rs | 13 ++++++++++++- src/librustc_trait_selection/traits/wf.rs | 2 +- .../bad-bounds-on-assoc-in-trait.stderr | 1 - .../defaults-unsound-62211-1.stderr | 4 ---- .../defaults-unsound-62211-2.stderr | 4 ---- src/test/ui/associated-types/issue-43924.stderr | 4 ---- src/test/ui/associated-types/issue-65774-1.stderr | 2 -- src/test/ui/associated-types/issue-65774-2.stderr | 2 -- .../point-at-type-on-obligation-failure-2.stderr | 6 ------ .../builtin-superkinds-double-superkind.stderr | 2 -- .../builtin-superkinds-in-metadata.stderr | 1 - .../builtin-superkinds-simple.stderr | 1 - .../builtin-superkinds-typaram-not-send.stderr | 1 - src/test/ui/dst/dst-sized-trait-param.stderr | 2 -- ...lt-type-param-can-reference-self-in-trait.stderr | 1 - src/test/ui/impl-bounds-checking.stderr | 2 -- src/test/ui/issues/issue-10412.stderr | 1 - .../ui/issues/issue-43784-associated-type.stderr | 1 - src/test/ui/issues/issue-43784-supertrait.stderr | 1 - src/test/ui/issues/issue-65673.stderr | 1 - src/test/ui/malformed/malformed-derive-entry.stderr | 2 -- .../defaultimpl/specialization-wfcheck.stderr | 1 - .../missing-assoc-type-bound-restriction.stderr | 1 - src/test/ui/traits/cycle-cache-err-60010.stderr | 1 - .../ui/unsized/unsized-trait-impl-trait-arg.stderr | 1 - src/test/ui/unsized7.stderr | 1 - 29 files changed, 22 insertions(+), 48 deletions(-) diff --git a/src/librustc_middle/traits/mod.rs b/src/librustc_middle/traits/mod.rs index 47c8aa023f043..d22a4ac298efe 100644 --- a/src/librustc_middle/traits/mod.rs +++ b/src/librustc_middle/traits/mod.rs @@ -191,6 +191,8 @@ pub enum ObligationCauseCode<'tcx> { ImplDerivedObligation(DerivedObligationCause<'tcx>), + DerivedObligation(DerivedObligationCause<'tcx>), + /// Error derived when matching traits/impls; see ObligationCause for more details CompareImplMethodObligation { item_name: ast::Name, @@ -263,7 +265,10 @@ impl ObligationCauseCode<'_> { // Return the base obligation, ignoring derived obligations. pub fn peel_derives(&self) -> &Self { let mut base_cause = self; - while let BuiltinDerivedObligation(cause) | ImplDerivedObligation(cause) = base_cause { + while let BuiltinDerivedObligation(cause) + | ImplDerivedObligation(cause) + | DerivedObligation(cause) = base_cause + { base_cause = &cause.parent_code; } base_cause diff --git a/src/librustc_middle/traits/structural_impls.rs b/src/librustc_middle/traits/structural_impls.rs index b7d0f6666bd38..5831cb3859f81 100644 --- a/src/librustc_middle/traits/structural_impls.rs +++ b/src/librustc_middle/traits/structural_impls.rs @@ -456,6 +456,7 @@ impl<'a, 'tcx> Lift<'tcx> for traits::ObligationCauseCode<'a> { super::ImplDerivedObligation(ref cause) => { tcx.lift(cause).map(super::ImplDerivedObligation) } + super::DerivedObligation(ref cause) => tcx.lift(cause).map(super::DerivedObligation), super::CompareImplMethodObligation { item_name, impl_item_def_id, diff --git a/src/librustc_trait_selection/traits/error_reporting/on_unimplemented.rs b/src/librustc_trait_selection/traits/error_reporting/on_unimplemented.rs index 1ecc7fdafc442..e9f55c24256c7 100644 --- a/src/librustc_trait_selection/traits/error_reporting/on_unimplemented.rs +++ b/src/librustc_trait_selection/traits/error_reporting/on_unimplemented.rs @@ -134,7 +134,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { match obligation.cause.code { ObligationCauseCode::BuiltinDerivedObligation(..) - | ObligationCauseCode::ImplDerivedObligation(..) => {} + | ObligationCauseCode::ImplDerivedObligation(..) + | ObligationCauseCode::DerivedObligation(..) => {} _ => { // this is a "direct", user-specified, rather than derived, // obligation. diff --git a/src/librustc_trait_selection/traits/error_reporting/suggestions.rs b/src/librustc_trait_selection/traits/error_reporting/suggestions.rs index 52bf2e6ad490c..9a6a6fefa7c71 100644 --- a/src/librustc_trait_selection/traits/error_reporting/suggestions.rs +++ b/src/librustc_trait_selection/traits/error_reporting/suggestions.rs @@ -1135,7 +1135,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { while let Some(code) = next_code { debug!("maybe_note_obligation_cause_for_async_await: code={:?}", code); match code { - ObligationCauseCode::BuiltinDerivedObligation(derived_obligation) + ObligationCauseCode::DerivedObligation(derived_obligation) + | ObligationCauseCode::BuiltinDerivedObligation(derived_obligation) | ObligationCauseCode::ImplDerivedObligation(derived_obligation) => { let ty = derived_obligation.parent_trait_ref.self_ty(); debug!( @@ -1661,6 +1662,16 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { obligated_types, ); } + ObligationCauseCode::DerivedObligation(ref data) => { + let parent_trait_ref = self.resolve_vars_if_possible(&data.parent_trait_ref); + let parent_predicate = parent_trait_ref.without_const().to_predicate(); + self.note_obligation_cause_code( + err, + &parent_predicate, + &data.parent_code, + obligated_types, + ); + } ObligationCauseCode::CompareImplMethodObligation { .. } => { err.note(&format!( "the requirement `{}` appears on the impl method \ diff --git a/src/librustc_trait_selection/traits/wf.rs b/src/librustc_trait_selection/traits/wf.rs index 0cda92b7dc8b4..f6953971ef5bc 100644 --- a/src/librustc_trait_selection/traits/wf.rs +++ b/src/librustc_trait_selection/traits/wf.rs @@ -243,7 +243,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { parent_trait_ref, parent_code: Rc::new(obligation.cause.code.clone()), }; - cause.code = traits::ObligationCauseCode::ImplDerivedObligation(derived_cause); + cause.code = traits::ObligationCauseCode::DerivedObligation(derived_cause); } extend_cause_with_original_assoc_item_obligation( tcx, diff --git a/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr b/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr index dd2f30e6dc040..96e690631894d 100644 --- a/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr +++ b/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr @@ -11,7 +11,6 @@ LL | impl Case1 for S1 { | ^^^^^ `>::App` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` | = help: the trait `for<'a> std::fmt::Debug` is not implemented for `>::App` - = note: required because of the requirements on the impl of `for<'a> std::fmt::Debug` for `<<<::C as std::iter::Iterator>::Item as std::iter::Iterator>::Item as Lam<&'a u8>>::App` error[E0277]: `<::C as std::iter::Iterator>::Item` is not an iterator --> $DIR/bad-bounds-on-assoc-in-trait.rs:36:20 diff --git a/src/test/ui/associated-types/defaults-unsound-62211-1.stderr b/src/test/ui/associated-types/defaults-unsound-62211-1.stderr index c4ab7b6e26e51..7bf75f3839c0e 100644 --- a/src/test/ui/associated-types/defaults-unsound-62211-1.stderr +++ b/src/test/ui/associated-types/defaults-unsound-62211-1.stderr @@ -53,7 +53,6 @@ LL | impl UncheckedCopy for T {} | = help: the trait `std::fmt::Display` is not implemented for `T` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead - = note: required because of the requirements on the impl of `std::fmt::Display` for `::Output` help: consider restricting type parameter `T` | LL | impl UncheckedCopy for T {} @@ -71,7 +70,6 @@ LL | + Deref LL | impl UncheckedCopy for T {} | ^^^^^^^^^^^^^ the trait `std::ops::Deref` is not implemented for `T` | - = note: required because of the requirements on the impl of `std::ops::Deref` for `::Output` help: consider restricting type parameter `T` | LL | impl UncheckedCopy for T {} @@ -90,7 +88,6 @@ LL | impl UncheckedCopy for T {} | ^^^^^^^^^^^^^ no implementation for `T += &'static str` | = help: the trait `std::ops::AddAssign<&'static str>` is not implemented for `T` - = note: required because of the requirements on the impl of `std::ops::AddAssign<&'static str>` for `::Output` help: consider restricting type parameter `T` | LL | impl> UncheckedCopy for T {} @@ -108,7 +105,6 @@ LL | type Output: Copy LL | impl UncheckedCopy for T {} | ^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` | - = note: required because of the requirements on the impl of `std::marker::Copy` for `::Output` help: consider restricting type parameter `T` | LL | impl UncheckedCopy for T {} diff --git a/src/test/ui/associated-types/defaults-unsound-62211-2.stderr b/src/test/ui/associated-types/defaults-unsound-62211-2.stderr index c311a9f456e79..b6d889515b6fb 100644 --- a/src/test/ui/associated-types/defaults-unsound-62211-2.stderr +++ b/src/test/ui/associated-types/defaults-unsound-62211-2.stderr @@ -53,7 +53,6 @@ LL | impl UncheckedCopy for T {} | = help: the trait `std::fmt::Display` is not implemented for `T` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead - = note: required because of the requirements on the impl of `std::fmt::Display` for `::Output` help: consider restricting type parameter `T` | LL | impl UncheckedCopy for T {} @@ -71,7 +70,6 @@ LL | + Deref LL | impl UncheckedCopy for T {} | ^^^^^^^^^^^^^ the trait `std::ops::Deref` is not implemented for `T` | - = note: required because of the requirements on the impl of `std::ops::Deref` for `::Output` help: consider restricting type parameter `T` | LL | impl UncheckedCopy for T {} @@ -90,7 +88,6 @@ LL | impl UncheckedCopy for T {} | ^^^^^^^^^^^^^ no implementation for `T += &'static str` | = help: the trait `std::ops::AddAssign<&'static str>` is not implemented for `T` - = note: required because of the requirements on the impl of `std::ops::AddAssign<&'static str>` for `::Output` help: consider restricting type parameter `T` | LL | impl> UncheckedCopy for T {} @@ -108,7 +105,6 @@ LL | type Output: Copy LL | impl UncheckedCopy for T {} | ^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` | - = note: required because of the requirements on the impl of `std::marker::Copy` for `::Output` help: consider restricting type parameter `T` | LL | impl UncheckedCopy for T {} diff --git a/src/test/ui/associated-types/issue-43924.stderr b/src/test/ui/associated-types/issue-43924.stderr index 38dd8b66a6ed5..58f71b8b14ed2 100644 --- a/src/test/ui/associated-types/issue-43924.stderr +++ b/src/test/ui/associated-types/issue-43924.stderr @@ -16,8 +16,6 @@ LL | type Out: Default + ToString + ?Sized = dyn ToString; ... LL | impl Foo for () {} | ^^^^^^^^ the trait `std::default::Default` is not implemented for `(dyn std::string::ToString + 'static)` - | - = note: required because of the requirements on the impl of `std::default::Default` for `<() as Foo>::Out` error[E0277]: the trait bound `(dyn std::string::ToString + 'static): std::default::Default` is not satisfied --> $DIR/issue-43924.rs:11:6 @@ -29,8 +27,6 @@ LL | type Out: Default + ToString + ?Sized = dyn ToString; ... LL | impl Foo for () {} | ^^^^^^^^ the trait `std::default::Default` is not implemented for `(dyn std::string::ToString + 'static)` - | - = note: required because of the requirements on the impl of `std::default::Default` for `<() as Foo>::Out` error: aborting due to 3 previous errors diff --git a/src/test/ui/associated-types/issue-65774-1.stderr b/src/test/ui/associated-types/issue-65774-1.stderr index ae3ebe811e2ab..2e5a1ebf19afa 100644 --- a/src/test/ui/associated-types/issue-65774-1.stderr +++ b/src/test/ui/associated-types/issue-65774-1.stderr @@ -16,8 +16,6 @@ LL | type MpuConfig: MyDisplay = T; ... LL | impl MPU for S { } | ^^^ the trait `MyDisplay` is not implemented for `T` - | - = note: required because of the requirements on the impl of `MyDisplay` for `::MpuConfig` error: aborting due to 2 previous errors diff --git a/src/test/ui/associated-types/issue-65774-2.stderr b/src/test/ui/associated-types/issue-65774-2.stderr index dadf229bd5d16..5b3986407bc4c 100644 --- a/src/test/ui/associated-types/issue-65774-2.stderr +++ b/src/test/ui/associated-types/issue-65774-2.stderr @@ -16,8 +16,6 @@ LL | type MpuConfig: MyDisplay = T; ... LL | impl MPU for S { } | ^^^ the trait `MyDisplay` is not implemented for `T` - | - = note: required because of the requirements on the impl of `MyDisplay` for `::MpuConfig` error: aborting due to 2 previous errors diff --git a/src/test/ui/associated-types/point-at-type-on-obligation-failure-2.stderr b/src/test/ui/associated-types/point-at-type-on-obligation-failure-2.stderr index cdc9559cd95e9..dac713567b5e2 100644 --- a/src/test/ui/associated-types/point-at-type-on-obligation-failure-2.stderr +++ b/src/test/ui/associated-types/point-at-type-on-obligation-failure-2.stderr @@ -8,8 +8,6 @@ LL | type Assoc: Bar; ... LL | type Assoc = bool; | ^^^^ the trait `Bar` is not implemented for `bool` - | - = note: required because of the requirements on the impl of `Bar` for `<() as Foo>::Assoc` error[E0277]: the trait bound `bool: Bar` is not satisfied --> $DIR/point-at-type-on-obligation-failure-2.rs:16:18 @@ -19,8 +17,6 @@ LL | trait Baz where Self::Assoc: Bar { ... LL | type Assoc = bool; | ^^^^ the trait `Bar` is not implemented for `bool` - | - = note: required because of the requirements on the impl of `Bar` for `<() as Baz>::Assoc` error[E0277]: the trait bound `bool: Bar` is not satisfied --> $DIR/point-at-type-on-obligation-failure-2.rs:24:18 @@ -30,8 +26,6 @@ LL | trait Bat where ::Assoc: Bar { ... LL | type Assoc = bool; | ^^^^ the trait `Bar` is not implemented for `bool` - | - = note: required because of the requirements on the impl of `Bar` for `<() as Bat>::Assoc` error: aborting due to 3 previous errors diff --git a/src/test/ui/builtin-superkinds/builtin-superkinds-double-superkind.stderr b/src/test/ui/builtin-superkinds/builtin-superkinds-double-superkind.stderr index b1437a3669279..4e7b513629d05 100644 --- a/src/test/ui/builtin-superkinds/builtin-superkinds-double-superkind.stderr +++ b/src/test/ui/builtin-superkinds/builtin-superkinds-double-superkind.stderr @@ -9,7 +9,6 @@ LL | impl Foo for (T,) { } | = help: within `(T,)`, the trait `std::marker::Send` is not implemented for `T` = note: required because it appears within the type `(T,)` - = note: required because of the requirements on the impl of `std::marker::Send` for `(T,)` help: consider further restricting this bound | LL | impl Foo for (T,) { } @@ -26,7 +25,6 @@ LL | impl Foo for (T,T) { } | = help: within `(T, T)`, the trait `std::marker::Sync` is not implemented for `T` = note: required because it appears within the type `(T, T)` - = note: required because of the requirements on the impl of `std::marker::Sync` for `(T, T)` help: consider further restricting this bound | LL | impl Foo for (T,T) { } diff --git a/src/test/ui/builtin-superkinds/builtin-superkinds-in-metadata.stderr b/src/test/ui/builtin-superkinds/builtin-superkinds-in-metadata.stderr index 8555c843a9342..3fb1af3a67cc2 100644 --- a/src/test/ui/builtin-superkinds/builtin-superkinds-in-metadata.stderr +++ b/src/test/ui/builtin-superkinds/builtin-superkinds-in-metadata.stderr @@ -11,7 +11,6 @@ LL | pub trait RequiresRequiresShareAndSend : RequiresShare + Send { } | = help: within `X`, the trait `std::marker::Send` is not implemented for `T` = note: required because it appears within the type `X` - = note: required because of the requirements on the impl of `std::marker::Send` for `X` help: consider further restricting this bound | LL | impl RequiresRequiresShareAndSend for X { } diff --git a/src/test/ui/builtin-superkinds/builtin-superkinds-simple.stderr b/src/test/ui/builtin-superkinds/builtin-superkinds-simple.stderr index b4f22f2d68fc9..592cc3b1c4ec1 100644 --- a/src/test/ui/builtin-superkinds/builtin-superkinds-simple.stderr +++ b/src/test/ui/builtin-superkinds/builtin-superkinds-simple.stderr @@ -8,7 +8,6 @@ LL | impl Foo for std::rc::Rc { } | ^^^ `std::rc::Rc` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `std::rc::Rc` - = note: required because of the requirements on the impl of `std::marker::Send` for `std::rc::Rc` error: aborting due to previous error diff --git a/src/test/ui/builtin-superkinds/builtin-superkinds-typaram-not-send.stderr b/src/test/ui/builtin-superkinds/builtin-superkinds-typaram-not-send.stderr index 1334997c3d93b..9c5073a1e49d7 100644 --- a/src/test/ui/builtin-superkinds/builtin-superkinds-typaram-not-send.stderr +++ b/src/test/ui/builtin-superkinds/builtin-superkinds-typaram-not-send.stderr @@ -8,7 +8,6 @@ LL | impl Foo for T { } | ^^^ `T` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `T` - = note: required because of the requirements on the impl of `std::marker::Send` for `T` help: consider further restricting this bound | LL | impl Foo for T { } diff --git a/src/test/ui/dst/dst-sized-trait-param.stderr b/src/test/ui/dst/dst-sized-trait-param.stderr index 14c7d02c2586b..749d569b9aedc 100644 --- a/src/test/ui/dst/dst-sized-trait-param.stderr +++ b/src/test/ui/dst/dst-sized-trait-param.stderr @@ -9,7 +9,6 @@ LL | impl Foo<[isize]> for usize { } | = help: the trait `std::marker::Sized` is not implemented for `[isize]` = note: to learn more, visit - = note: required because of the requirements on the impl of `std::marker::Sized` for `[isize]` error[E0277]: the size for values of type `[usize]` cannot be known at compilation time --> $DIR/dst-sized-trait-param.rs:10:6 @@ -22,7 +21,6 @@ LL | impl Foo for [usize] { } | = help: the trait `std::marker::Sized` is not implemented for `[usize]` = note: to learn more, visit - = note: required because of the requirements on the impl of `std::marker::Sized` for `[usize]` error: aborting due to 2 previous errors diff --git a/src/test/ui/generics/issue-61631-default-type-param-can-reference-self-in-trait.stderr b/src/test/ui/generics/issue-61631-default-type-param-can-reference-self-in-trait.stderr index 3f06dfdccd868..95f4aa9e6dbaa 100644 --- a/src/test/ui/generics/issue-61631-default-type-param-can-reference-self-in-trait.stderr +++ b/src/test/ui/generics/issue-61631-default-type-param-can-reference-self-in-trait.stderr @@ -9,7 +9,6 @@ LL | impl Tsized for () {} | = help: the trait `std::marker::Sized` is not implemented for `[()]` = note: to learn more, visit - = note: required because of the requirements on the impl of `std::marker::Sized` for `[()]` error: aborting due to previous error diff --git a/src/test/ui/impl-bounds-checking.stderr b/src/test/ui/impl-bounds-checking.stderr index 6453508410ead..8698ed6e875f3 100644 --- a/src/test/ui/impl-bounds-checking.stderr +++ b/src/test/ui/impl-bounds-checking.stderr @@ -6,8 +6,6 @@ LL | trait Getter { ... LL | impl Getter for isize { | ^^^^^^^^^^^^^ the trait `Clone2` is not implemented for `isize` - | - = note: required because of the requirements on the impl of `Clone2` for `isize` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-10412.stderr b/src/test/ui/issues/issue-10412.stderr index 9c50b4af9a993..888576c43365f 100644 --- a/src/test/ui/issues/issue-10412.stderr +++ b/src/test/ui/issues/issue-10412.stderr @@ -57,7 +57,6 @@ LL | impl<'self> Serializable for &'self str { | = help: the trait `std::marker::Sized` is not implemented for `str` = note: to learn more, visit - = note: required because of the requirements on the impl of `std::marker::Sized` for `str` error: aborting due to 9 previous errors diff --git a/src/test/ui/issues/issue-43784-associated-type.stderr b/src/test/ui/issues/issue-43784-associated-type.stderr index fa835f5543ded..d8e9110fbbd1d 100644 --- a/src/test/ui/issues/issue-43784-associated-type.stderr +++ b/src/test/ui/issues/issue-43784-associated-type.stderr @@ -4,7 +4,6 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied LL | type Assoc = T; | ^ the trait `std::marker::Copy` is not implemented for `T` | - = note: required because of the requirements on the impl of `std::marker::Copy` for `::Assoc` help: consider restricting type parameter `T` | LL | impl Complete for T { diff --git a/src/test/ui/issues/issue-43784-supertrait.stderr b/src/test/ui/issues/issue-43784-supertrait.stderr index 86c0f8f597bef..2fb0583ee7d59 100644 --- a/src/test/ui/issues/issue-43784-supertrait.stderr +++ b/src/test/ui/issues/issue-43784-supertrait.stderr @@ -4,7 +4,6 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied LL | impl Complete for T {} | ^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` | - = note: required because of the requirements on the impl of `std::marker::Copy` for `T` help: consider restricting type parameter `T` | LL | impl Complete for T {} diff --git a/src/test/ui/issues/issue-65673.stderr b/src/test/ui/issues/issue-65673.stderr index d1a490eb5657d..6778ab8bfe4f2 100644 --- a/src/test/ui/issues/issue-65673.stderr +++ b/src/test/ui/issues/issue-65673.stderr @@ -11,7 +11,6 @@ LL | type Ctx = dyn Alias; | = help: the trait `std::marker::Sized` is not implemented for `(dyn Trait + 'static)` = note: to learn more, visit - = note: required because of the requirements on the impl of `std::marker::Sized` for `::Ctx` error: aborting due to previous error diff --git a/src/test/ui/malformed/malformed-derive-entry.stderr b/src/test/ui/malformed/malformed-derive-entry.stderr index 74606b71bf12e..2c45a498240ef 100644 --- a/src/test/ui/malformed/malformed-derive-entry.stderr +++ b/src/test/ui/malformed/malformed-derive-entry.stderr @@ -27,7 +27,6 @@ LL | #[derive(Copy(Bad))] LL | pub trait Copy: Clone { | ----- required by this bound in `std::marker::Copy` | - = note: required because of the requirements on the impl of `std::clone::Clone` for `Test1` = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Test2: std::clone::Clone` is not satisfied @@ -41,7 +40,6 @@ LL | #[derive(Copy="bad")] LL | pub trait Copy: Clone { | ----- required by this bound in `std::marker::Copy` | - = note: required because of the requirements on the impl of `std::clone::Clone` for `Test2` = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 5 previous errors diff --git a/src/test/ui/specialization/defaultimpl/specialization-wfcheck.stderr b/src/test/ui/specialization/defaultimpl/specialization-wfcheck.stderr index 91e45df8d3ef9..f499c1f569859 100644 --- a/src/test/ui/specialization/defaultimpl/specialization-wfcheck.stderr +++ b/src/test/ui/specialization/defaultimpl/specialization-wfcheck.stderr @@ -7,7 +7,6 @@ LL | LL | default impl Foo<'static, U> for () {} | ^^^^^^^^^^^^^^^ the trait `std::cmp::Eq` is not implemented for `U` | - = note: required because of the requirements on the impl of `std::cmp::Eq` for `U` help: consider restricting type parameter `U` | LL | default impl Foo<'static, U> for () {} diff --git a/src/test/ui/suggestions/missing-assoc-type-bound-restriction.stderr b/src/test/ui/suggestions/missing-assoc-type-bound-restriction.stderr index 2091e30f11593..c5510bfa3f2fe 100644 --- a/src/test/ui/suggestions/missing-assoc-type-bound-restriction.stderr +++ b/src/test/ui/suggestions/missing-assoc-type-bound-restriction.stderr @@ -28,7 +28,6 @@ LL | type Assoc = ChildWrapper; | ^^^^^^^^^^^^^^^^^^^^^^ the trait `Child` is not implemented for `::Assoc` | = note: required because of the requirements on the impl of `Child` for `ChildWrapper<::Assoc>` - = note: required because of the requirements on the impl of `Child< as Parent>::Ty>` for ` as Parent>::Assoc` error[E0277]: the trait bound `::Assoc: Child` is not satisfied --> $DIR/missing-assoc-type-bound-restriction.rs:20:5 diff --git a/src/test/ui/traits/cycle-cache-err-60010.stderr b/src/test/ui/traits/cycle-cache-err-60010.stderr index 9e2e5568ba249..356b90d064623 100644 --- a/src/test/ui/traits/cycle-cache-err-60010.stderr +++ b/src/test/ui/traits/cycle-cache-err-60010.stderr @@ -21,7 +21,6 @@ LL | type Storage = SalsaStorage; = note: required because of the requirements on the impl of `SourceDatabase` for `RootDatabase` = note: required because of the requirements on the impl of `Query` for `ParseQuery` = note: required because it appears within the type `SalsaStorage` - = note: required because of the requirements on the impl of `std::marker::Sized` for `::Storage` error: aborting due to 2 previous errors diff --git a/src/test/ui/unsized/unsized-trait-impl-trait-arg.stderr b/src/test/ui/unsized/unsized-trait-impl-trait-arg.stderr index 502dd20105869..4cf054d177f66 100644 --- a/src/test/ui/unsized/unsized-trait-impl-trait-arg.stderr +++ b/src/test/ui/unsized/unsized-trait-impl-trait-arg.stderr @@ -11,7 +11,6 @@ LL | impl T2 for S4 { | = help: the trait `std::marker::Sized` is not implemented for `X` = note: to learn more, visit - = note: required because of the requirements on the impl of `std::marker::Sized` for `X` error: aborting due to previous error diff --git a/src/test/ui/unsized7.stderr b/src/test/ui/unsized7.stderr index cd30c98f55d0d..d18644f005a88 100644 --- a/src/test/ui/unsized7.stderr +++ b/src/test/ui/unsized7.stderr @@ -11,7 +11,6 @@ LL | impl T1 for S3 { | = help: the trait `std::marker::Sized` is not implemented for `X` = note: to learn more, visit - = note: required because of the requirements on the impl of `std::marker::Sized` for `X` error: aborting due to previous error From d9a5419ef4f0af07cbf62a5a4a6b002b9d6bcabd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sat, 18 Apr 2020 16:36:46 -0700 Subject: [PATCH 4/4] Add label to item source of bound obligation --- .../traits/error_reporting/suggestions.rs | 4 ++-- .../bad-bounds-on-assoc-in-trait.stderr | 8 ++++---- .../associated-types/associated-types-eq-hr.stderr | 14 +++++++------- .../defaults-unsound-62211-1.stderr | 8 ++++---- .../defaults-unsound-62211-2.stderr | 8 ++++---- .../higher-ranked-projection.bad.stderr | 2 +- src/test/ui/associated-types/issue-43924.stderr | 4 ++-- src/test/ui/associated-types/issue-65774-1.stderr | 2 +- src/test/ui/associated-types/issue-65774-2.stderr | 2 +- .../point-at-type-on-obligation-failure-2.stderr | 2 +- .../expect-fn-supply-fn.nll.stderr | 6 +++--- .../expect-fn-supply-fn.stderr | 6 +++--- .../expect-infer-var-appearing-twice.stderr | 2 +- .../generator-yielding-or-returning-itself.stderr | 4 ++-- .../issue-62326-parameter-out-of-range.stderr | 2 +- .../ui/generic-associated-types/iterable.stderr | 4 ++-- src/test/ui/hrtb/hrtb-conflate-regions.stderr | 2 +- .../hrtb-exists-forall-trait-contravariant.stderr | 2 +- .../hrtb/hrtb-exists-forall-trait-covariant.stderr | 2 +- .../hrtb/hrtb-exists-forall-trait-invariant.stderr | 2 +- ...rtb-higher-ranker-supertraits-transitive.stderr | 2 +- .../ui/hrtb/hrtb-higher-ranker-supertraits.stderr | 4 ++-- src/test/ui/hrtb/hrtb-just-for-static.stderr | 4 ++-- src/test/ui/issues/issue-24204.stderr | 2 +- src/test/ui/issues/issue-43623.stderr | 4 ++-- src/test/ui/issues/issue-47706.stderr | 2 +- src/test/ui/issues/issue-60218.stderr | 2 +- src/test/ui/issues/issue-60283.stderr | 4 ++-- src/test/ui/issues/issue-65673.stderr | 2 +- .../missing-assoc-type-bound-restriction.stderr | 6 +++--- src/test/ui/traits/cycle-cache-err-60010.stderr | 2 +- src/test/ui/where-clauses/where-for-self-2.stderr | 2 +- 32 files changed, 61 insertions(+), 61 deletions(-) diff --git a/src/librustc_trait_selection/traits/error_reporting/suggestions.rs b/src/librustc_trait_selection/traits/error_reporting/suggestions.rs index 9a6a6fefa7c71..aaa5174420fa0 100644 --- a/src/librustc_trait_selection/traits/error_reporting/suggestions.rs +++ b/src/librustc_trait_selection/traits/error_reporting/suggestions.rs @@ -1532,14 +1532,14 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { let item_name = tcx.def_path_str(item_def_id); let msg = format!("required by this bound in `{}`", item_name); if let Some(ident) = tcx.opt_item_name(item_def_id) { - let sm = self.tcx.sess.source_map(); + let sm = tcx.sess.source_map(); let same_line = match (sm.lookup_line(ident.span.hi()), sm.lookup_line(span.lo())) { (Ok(l), Ok(r)) => l.line == r.line, _ => true, }; if !ident.span.overlaps(span) && !same_line { - err.span_label(ident.span, ""); + err.span_label(ident.span, "required by a bound in this"); } } if span != DUMMY_SP { diff --git a/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr b/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr index 96e690631894d..f65ae32c01c99 100644 --- a/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr +++ b/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr @@ -2,7 +2,7 @@ error[E0277]: `>::App` doesn't implement `std::fmt::Debug` --> $DIR/bad-bounds-on-assoc-in-trait.rs:31:6 | LL | trait Case1 { - | ----- + | ----- required by a bound in this ... LL | Debug | ----- required by this bound in `Case1` @@ -26,7 +26,7 @@ error[E0277]: `<::C as std::iter::Iterator>::Item` cannot be sent be --> $DIR/bad-bounds-on-assoc-in-trait.rs:36:20 | LL | trait Case1 { - | ----- + | ----- required by a bound in this LL | type C: Clone + Iterator::C as std::iter::Iterator>::Item` cannot be shared --> $DIR/bad-bounds-on-assoc-in-trait.rs:36:20 | LL | trait Case1 { - | ----- + | ----- required by a bound in this ... LL | > + Sync>; | ---- required by this bound in `Case1` @@ -58,7 +58,7 @@ error[E0277]: `<_ as Lam<&'a u8>>::App` doesn't implement `std::fmt::Debug` --> $DIR/bad-bounds-on-assoc-in-trait.rs:36:20 | LL | trait Case1 { - | ----- + | ----- required by a bound in this ... LL | Debug | ----- required by this bound in `Case1` diff --git a/src/test/ui/associated-types/associated-types-eq-hr.stderr b/src/test/ui/associated-types/associated-types-eq-hr.stderr index fd7d89d193381..58d72746e76aa 100644 --- a/src/test/ui/associated-types/associated-types-eq-hr.stderr +++ b/src/test/ui/associated-types/associated-types-eq-hr.stderr @@ -2,7 +2,7 @@ error[E0271]: type mismatch resolving `for<'x> $DIR/associated-types-eq-hr.rs:82:5 | LL | fn foo() - | --- + | --- required by a bound in this LL | where T : for<'x> TheTrait<&'x isize, A = &'x isize> | ------------- required by this bound in `foo` ... @@ -16,7 +16,7 @@ error[E0271]: type mismatch resolving `for<'x> --> $DIR/associated-types-eq-hr.rs:86:5 | LL | fn bar() - | --- + | --- required by a bound in this LL | where T : for<'x> TheTrait<&'x isize, A = &'x usize> | ------------- required by this bound in `bar` ... @@ -30,7 +30,7 @@ error[E0277]: the trait bound `for<'x, 'y> Tuple: TheTrait<(&'x isize, &'y isize --> $DIR/associated-types-eq-hr.rs:91:17 | LL | fn tuple_one() - | --------- + | --------- required by a bound in this LL | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'x isize> | ---------------------------------------------------------- required by this bound in `tuple_one` ... @@ -44,7 +44,7 @@ error[E0271]: type mismatch resolving `for<'x, 'y> $DIR/associated-types-eq-hr.rs:91:5 | LL | fn tuple_one() - | --------- + | --------- required by a bound in this LL | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'x isize> | ------------- required by this bound in `tuple_one` ... @@ -55,7 +55,7 @@ error[E0277]: the trait bound `for<'x, 'y> Tuple: TheTrait<(&'x isize, &'y isize --> $DIR/associated-types-eq-hr.rs:97:17 | LL | fn tuple_two() - | --------- + | --------- required by a bound in this LL | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'y isize> | ---------------------------------------------------------- required by this bound in `tuple_two` ... @@ -69,7 +69,7 @@ error[E0271]: type mismatch resolving `for<'x, 'y> $DIR/associated-types-eq-hr.rs:97:5 | LL | fn tuple_two() - | --------- + | --------- required by a bound in this LL | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'y isize> | ------------- required by this bound in `tuple_two` ... @@ -80,7 +80,7 @@ error[E0277]: the trait bound `for<'x, 'y> Tuple: TheTrait<(&'x isize, &'y isize --> $DIR/associated-types-eq-hr.rs:107:18 | LL | fn tuple_four() - | ---------- + | ---------- required by a bound in this LL | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize)> | ------------------------------------------- required by this bound in `tuple_four` ... diff --git a/src/test/ui/associated-types/defaults-unsound-62211-1.stderr b/src/test/ui/associated-types/defaults-unsound-62211-1.stderr index 7bf75f3839c0e..856d513d60bd3 100644 --- a/src/test/ui/associated-types/defaults-unsound-62211-1.stderr +++ b/src/test/ui/associated-types/defaults-unsound-62211-1.stderr @@ -43,7 +43,7 @@ error[E0277]: `T` doesn't implement `std::fmt::Display` --> $DIR/defaults-unsound-62211-1.rs:41:9 | LL | trait UncheckedCopy: Sized { - | ------------- + | ------------- required by a bound in this ... LL | + Display = Self; | ------- required by this bound in `UncheckedCopy` @@ -62,7 +62,7 @@ error[E0277]: the trait bound `T: std::ops::Deref` is not satisfied --> $DIR/defaults-unsound-62211-1.rs:41:9 | LL | trait UncheckedCopy: Sized { - | ------------- + | ------------- required by a bound in this ... LL | + Deref | ------------------- required by this bound in `UncheckedCopy` @@ -79,7 +79,7 @@ error[E0277]: cannot add-assign `&'static str` to `T` --> $DIR/defaults-unsound-62211-1.rs:41:9 | LL | trait UncheckedCopy: Sized { - | ------------- + | ------------- required by a bound in this ... LL | + AddAssign<&'static str> | ----------------------- required by this bound in `UncheckedCopy` @@ -97,7 +97,7 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/defaults-unsound-62211-1.rs:41:9 | LL | trait UncheckedCopy: Sized { - | ------------- + | ------------- required by a bound in this ... LL | type Output: Copy | ---- required by this bound in `UncheckedCopy` diff --git a/src/test/ui/associated-types/defaults-unsound-62211-2.stderr b/src/test/ui/associated-types/defaults-unsound-62211-2.stderr index b6d889515b6fb..1060c82fec22a 100644 --- a/src/test/ui/associated-types/defaults-unsound-62211-2.stderr +++ b/src/test/ui/associated-types/defaults-unsound-62211-2.stderr @@ -43,7 +43,7 @@ error[E0277]: `T` doesn't implement `std::fmt::Display` --> $DIR/defaults-unsound-62211-2.rs:41:9 | LL | trait UncheckedCopy: Sized { - | ------------- + | ------------- required by a bound in this ... LL | + Display = Self; | ------- required by this bound in `UncheckedCopy` @@ -62,7 +62,7 @@ error[E0277]: the trait bound `T: std::ops::Deref` is not satisfied --> $DIR/defaults-unsound-62211-2.rs:41:9 | LL | trait UncheckedCopy: Sized { - | ------------- + | ------------- required by a bound in this ... LL | + Deref | ------------------- required by this bound in `UncheckedCopy` @@ -79,7 +79,7 @@ error[E0277]: cannot add-assign `&'static str` to `T` --> $DIR/defaults-unsound-62211-2.rs:41:9 | LL | trait UncheckedCopy: Sized { - | ------------- + | ------------- required by a bound in this ... LL | + AddAssign<&'static str> | ----------------------- required by this bound in `UncheckedCopy` @@ -97,7 +97,7 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/defaults-unsound-62211-2.rs:41:9 | LL | trait UncheckedCopy: Sized { - | ------------- + | ------------- required by a bound in this ... LL | type Output: Copy | ---- required by this bound in `UncheckedCopy` diff --git a/src/test/ui/associated-types/higher-ranked-projection.bad.stderr b/src/test/ui/associated-types/higher-ranked-projection.bad.stderr index 74c9ad2c39e67..3b3e4c3ea117a 100644 --- a/src/test/ui/associated-types/higher-ranked-projection.bad.stderr +++ b/src/test/ui/associated-types/higher-ranked-projection.bad.stderr @@ -2,7 +2,7 @@ error[E0271]: type mismatch resolving `for<'a> <&'a _ as Mirror>::Image == _` --> $DIR/higher-ranked-projection.rs:25:5 | LL | fn foo(_t: T) - | --- + | --- required by a bound in this LL | where for<'a> &'a T: Mirror | ------- required by this bound in `foo` ... diff --git a/src/test/ui/associated-types/issue-43924.stderr b/src/test/ui/associated-types/issue-43924.stderr index 58f71b8b14ed2..f21846fd82c43 100644 --- a/src/test/ui/associated-types/issue-43924.stderr +++ b/src/test/ui/associated-types/issue-43924.stderr @@ -10,7 +10,7 @@ error[E0277]: the trait bound `(dyn std::string::ToString + 'static): std::defau --> $DIR/issue-43924.rs:10:6 | LL | trait Foo { - | --- + | --- required by a bound in this LL | type Out: Default + ToString + ?Sized = dyn ToString; | ------- required by this bound in `Foo` ... @@ -21,7 +21,7 @@ error[E0277]: the trait bound `(dyn std::string::ToString + 'static): std::defau --> $DIR/issue-43924.rs:11:6 | LL | trait Foo { - | --- + | --- required by a bound in this LL | type Out: Default + ToString + ?Sized = dyn ToString; | ------- required by this bound in `Foo` ... diff --git a/src/test/ui/associated-types/issue-65774-1.stderr b/src/test/ui/associated-types/issue-65774-1.stderr index 2e5a1ebf19afa..72f47df5d80e7 100644 --- a/src/test/ui/associated-types/issue-65774-1.stderr +++ b/src/test/ui/associated-types/issue-65774-1.stderr @@ -10,7 +10,7 @@ error[E0277]: the trait bound `T: MyDisplay` is not satisfied --> $DIR/issue-65774-1.rs:16:6 | LL | trait MPU { - | --- + | --- required by a bound in this LL | type MpuConfig: MyDisplay = T; | --------- required by this bound in `MPU` ... diff --git a/src/test/ui/associated-types/issue-65774-2.stderr b/src/test/ui/associated-types/issue-65774-2.stderr index 5b3986407bc4c..aef70885af369 100644 --- a/src/test/ui/associated-types/issue-65774-2.stderr +++ b/src/test/ui/associated-types/issue-65774-2.stderr @@ -10,7 +10,7 @@ error[E0277]: the trait bound `T: MyDisplay` is not satisfied --> $DIR/issue-65774-2.rs:16:6 | LL | trait MPU { - | --- + | --- required by a bound in this LL | type MpuConfig: MyDisplay = T; | --------- required by this bound in `MPU` ... diff --git a/src/test/ui/associated-types/point-at-type-on-obligation-failure-2.stderr b/src/test/ui/associated-types/point-at-type-on-obligation-failure-2.stderr index dac713567b5e2..3118a9c5352c3 100644 --- a/src/test/ui/associated-types/point-at-type-on-obligation-failure-2.stderr +++ b/src/test/ui/associated-types/point-at-type-on-obligation-failure-2.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `bool: Bar` is not satisfied --> $DIR/point-at-type-on-obligation-failure-2.rs:8:18 | LL | trait Foo { - | --- + | --- required by a bound in this LL | type Assoc: Bar; | --- required by this bound in `Foo` ... diff --git a/src/test/ui/closure-expected-type/expect-fn-supply-fn.nll.stderr b/src/test/ui/closure-expected-type/expect-fn-supply-fn.nll.stderr index 7141c047d7f53..97fdb76dd11c7 100644 --- a/src/test/ui/closure-expected-type/expect-fn-supply-fn.nll.stderr +++ b/src/test/ui/closure-expected-type/expect-fn-supply-fn.nll.stderr @@ -2,7 +2,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/expect-fn-supply-fn.rs:30:5 | LL | fn with_closure_expecting_fn_with_free_region(_: F) - | ------------------------------------------ + | ------------------------------------------ required by a bound in this LL | where F: for<'a> FnOnce(fn(&'a u32), &i32) | ------------------------- required by this bound in `with_closure_expecting_fn_with_free_region` ... @@ -15,7 +15,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/expect-fn-supply-fn.rs:37:5 | LL | fn with_closure_expecting_fn_with_bound_region(_: F) - | ------------------------------------------- + | ------------------------------------------- required by a bound in this LL | where F: FnOnce(fn(&u32), &i32) | ---------------------- required by this bound in `with_closure_expecting_fn_with_bound_region` ... @@ -28,7 +28,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/expect-fn-supply-fn.rs:46:5 | LL | fn with_closure_expecting_fn_with_bound_region(_: F) - | ------------------------------------------- + | ------------------------------------------- required by a bound in this LL | where F: FnOnce(fn(&u32), &i32) | ---------------------- required by this bound in `with_closure_expecting_fn_with_bound_region` ... diff --git a/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr b/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr index 0033395846815..fae41c4114abc 100644 --- a/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr +++ b/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr @@ -40,7 +40,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/expect-fn-supply-fn.rs:30:5 | LL | fn with_closure_expecting_fn_with_free_region(_: F) - | ------------------------------------------ + | ------------------------------------------ required by a bound in this LL | where F: for<'a> FnOnce(fn(&'a u32), &i32) | ------------------------- required by this bound in `with_closure_expecting_fn_with_free_region` ... @@ -53,7 +53,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/expect-fn-supply-fn.rs:37:5 | LL | fn with_closure_expecting_fn_with_bound_region(_: F) - | ------------------------------------------- + | ------------------------------------------- required by a bound in this LL | where F: FnOnce(fn(&u32), &i32) | ---------------------- required by this bound in `with_closure_expecting_fn_with_bound_region` ... @@ -66,7 +66,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/expect-fn-supply-fn.rs:46:5 | LL | fn with_closure_expecting_fn_with_bound_region(_: F) - | ------------------------------------------- + | ------------------------------------------- required by a bound in this LL | where F: FnOnce(fn(&u32), &i32) | ---------------------- required by this bound in `with_closure_expecting_fn_with_bound_region` ... diff --git a/src/test/ui/closure-expected-type/expect-infer-var-appearing-twice.stderr b/src/test/ui/closure-expected-type/expect-infer-var-appearing-twice.stderr index 1c6564ee426e5..93b42a5a305f2 100644 --- a/src/test/ui/closure-expected-type/expect-infer-var-appearing-twice.stderr +++ b/src/test/ui/closure-expected-type/expect-infer-var-appearing-twice.stderr @@ -2,7 +2,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/expect-infer-var-appearing-twice.rs:14:5 | LL | fn with_closure(_: F) - | ------------ + | ------------ required by a bound in this LL | where F: FnOnce(A, A) | ------------ required by this bound in `with_closure` ... diff --git a/src/test/ui/generator/generator-yielding-or-returning-itself.stderr b/src/test/ui/generator/generator-yielding-or-returning-itself.stderr index fc8064d8225bf..9699abd5661a2 100644 --- a/src/test/ui/generator/generator-yielding-or-returning-itself.stderr +++ b/src/test/ui/generator/generator-yielding-or-returning-itself.stderr @@ -2,7 +2,7 @@ error[E0271]: type mismatch resolving `<[generator@$DIR/generator-yielding-or-re --> $DIR/generator-yielding-or-returning-itself.rs:15:5 | LL | pub fn want_cyclic_generator_return(_: T) - | ---------------------------- + | ---------------------------- required by a bound in this LL | where T: Generator | ---------- required by this bound in `want_cyclic_generator_return` ... @@ -18,7 +18,7 @@ error[E0271]: type mismatch resolving `<[generator@$DIR/generator-yielding-or-re --> $DIR/generator-yielding-or-returning-itself.rs:28:5 | LL | pub fn want_cyclic_generator_yield(_: T) - | --------------------------- + | --------------------------- required by a bound in this LL | where T: Generator | --------- required by this bound in `want_cyclic_generator_yield` ... diff --git a/src/test/ui/generic-associated-types/issue-62326-parameter-out-of-range.stderr b/src/test/ui/generic-associated-types/issue-62326-parameter-out-of-range.stderr index 88b5c6a0a013c..4b06baa09ffbf 100644 --- a/src/test/ui/generic-associated-types/issue-62326-parameter-out-of-range.stderr +++ b/src/test/ui/generic-associated-types/issue-62326-parameter-out-of-range.stderr @@ -2,7 +2,7 @@ error[E0280]: the requirement `for<'a> ::Item<'a>: 'a` is not --> $DIR/issue-62326-parameter-out-of-range.rs:7:20 | LL | trait Iterator { - | -------- + | -------- required by a bound in this LL | type Item<'a>: 'a; | ^^ required by this bound in `Iterator` diff --git a/src/test/ui/generic-associated-types/iterable.stderr b/src/test/ui/generic-associated-types/iterable.stderr index 6bc5a2319a980..b1298163aabf0 100644 --- a/src/test/ui/generic-associated-types/iterable.stderr +++ b/src/test/ui/generic-associated-types/iterable.stderr @@ -24,7 +24,7 @@ error[E0271]: type mismatch resolving `for<'a> < as Iterable>:: --> $DIR/iterable.rs:19:30 | LL | trait Iterable { - | -------- + | -------- required by a bound in this LL | type Item<'a> where Self: 'a; LL | type Iter<'a>: Iterator> where Self: 'a; | --------------------- required by this bound in `Iterable` @@ -41,7 +41,7 @@ error[E0271]: type mismatch resolving `for<'a> <<[T] as Iterable>::Iter<'a> as s --> $DIR/iterable.rs:31:30 | LL | trait Iterable { - | -------- + | -------- required by a bound in this LL | type Item<'a> where Self: 'a; LL | type Iter<'a>: Iterator> where Self: 'a; | --------------------- required by this bound in `Iterable` diff --git a/src/test/ui/hrtb/hrtb-conflate-regions.stderr b/src/test/ui/hrtb/hrtb-conflate-regions.stderr index 9822b48f4f48f..7250935ea296b 100644 --- a/src/test/ui/hrtb/hrtb-conflate-regions.stderr +++ b/src/test/ui/hrtb/hrtb-conflate-regions.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `for<'a, 'b> SomeStruct: Foo<(&'a isize, &'b isize --> $DIR/hrtb-conflate-regions.rs:27:22 | LL | fn want_foo2() - | --------- + | --------- required by a bound in this LL | where T : for<'a,'b> Foo<(&'a isize, &'b isize)> | -------------------------------------- required by this bound in `want_foo2` ... diff --git a/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.stderr b/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.stderr index 969d9eda73519..7a7285d3d76e0 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.stderr +++ b/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `(): Trait fn(&'b u32)>` is not satisfied --> $DIR/hrtb-exists-forall-trait-contravariant.rs:34:11 | LL | fn foo() - | --- + | --- required by a bound in this LL | where LL | T: Trait fn(&'b u32)>, | -------------------------- required by this bound in `foo` diff --git a/src/test/ui/hrtb/hrtb-exists-forall-trait-covariant.stderr b/src/test/ui/hrtb/hrtb-exists-forall-trait-covariant.stderr index dddc2bcce49e5..1e335f9ee9610 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-trait-covariant.stderr +++ b/src/test/ui/hrtb/hrtb-exists-forall-trait-covariant.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `(): Trait fn(fn(&'b u32))>` is not satisf --> $DIR/hrtb-exists-forall-trait-covariant.rs:36:11 | LL | fn foo() - | --- + | --- required by a bound in this LL | where LL | T: Trait fn(fn(&'b u32))>, | ------------------------------ required by this bound in `foo` diff --git a/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.stderr b/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.stderr index 23ef75944d317..9174ea4d8419d 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.stderr +++ b/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `(): Trait fn(std::cell::Cell<&'b u32>)>` --> $DIR/hrtb-exists-forall-trait-invariant.rs:28:11 | LL | fn foo() - | --- + | --- required by a bound in this LL | where LL | T: Trait fn(Cell<&'b u32>)>, | -------------------------------- required by this bound in `foo` diff --git a/src/test/ui/hrtb/hrtb-higher-ranker-supertraits-transitive.stderr b/src/test/ui/hrtb/hrtb-higher-ranker-supertraits-transitive.stderr index 268ff057421fe..87a13889298df 100644 --- a/src/test/ui/hrtb/hrtb-higher-ranker-supertraits-transitive.stderr +++ b/src/test/ui/hrtb/hrtb-higher-ranker-supertraits-transitive.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `for<'ccx> B: Bar<'ccx>` is not satisfied --> $DIR/hrtb-higher-ranker-supertraits-transitive.rs:47:26 | LL | fn want_bar_for_any_ccx(b: &B) - | -------------------- + | -------------------- required by a bound in this LL | where B : for<'ccx> Bar<'ccx> | ------------------- required by this bound in `want_bar_for_any_ccx` ... diff --git a/src/test/ui/hrtb/hrtb-higher-ranker-supertraits.stderr b/src/test/ui/hrtb/hrtb-higher-ranker-supertraits.stderr index 2e20d2fe6dda3..0123faa36dbcd 100644 --- a/src/test/ui/hrtb/hrtb-higher-ranker-supertraits.stderr +++ b/src/test/ui/hrtb/hrtb-higher-ranker-supertraits.stderr @@ -5,7 +5,7 @@ LL | want_foo_for_any_tcx(f); | ^ the trait `for<'tcx> Foo<'tcx>` is not implemented for `F` ... LL | fn want_foo_for_any_tcx(f: &F) - | -------------------- + | -------------------- required by a bound in this LL | where F : for<'tcx> Foo<'tcx> | ------------------- required by this bound in `want_foo_for_any_tcx` | @@ -21,7 +21,7 @@ LL | want_bar_for_any_ccx(b); | ^ the trait `for<'ccx> Bar<'ccx>` is not implemented for `B` ... LL | fn want_bar_for_any_ccx(b: &B) - | -------------------- + | -------------------- required by a bound in this LL | where B : for<'ccx> Bar<'ccx> | ------------------- required by this bound in `want_bar_for_any_ccx` | diff --git a/src/test/ui/hrtb/hrtb-just-for-static.stderr b/src/test/ui/hrtb/hrtb-just-for-static.stderr index 6ec0beefd60e3..4fa404624775b 100644 --- a/src/test/ui/hrtb/hrtb-just-for-static.stderr +++ b/src/test/ui/hrtb/hrtb-just-for-static.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `for<'a> StaticInt: Foo<&'a isize>` is not satisfi --> $DIR/hrtb-just-for-static.rs:24:17 | LL | fn want_hrtb() - | --------- + | --------- required by a bound in this LL | where T : for<'a> Foo<&'a isize> | ---------------------- required by this bound in `want_hrtb` ... @@ -16,7 +16,7 @@ error[E0277]: the trait bound `for<'a> &'a u32: Foo<&'a isize>` is not satisfied --> $DIR/hrtb-just-for-static.rs:30:17 | LL | fn want_hrtb() - | --------- + | --------- required by a bound in this LL | where T : for<'a> Foo<&'a isize> | ---------------------- required by this bound in `want_hrtb` ... diff --git a/src/test/ui/issues/issue-24204.stderr b/src/test/ui/issues/issue-24204.stderr index 64d1b68cbed7f..d69efc860059b 100644 --- a/src/test/ui/issues/issue-24204.stderr +++ b/src/test/ui/issues/issue-24204.stderr @@ -2,7 +2,7 @@ error[E0271]: type mismatch resolving `<::A as MultiDispatch>:: --> $DIR/issue-24204.rs:14:12 | LL | trait Trait: Sized { - | ----- + | ----- required by a bound in this LL | type A: MultiDispatch; | -------- required by this bound in `Trait` ... diff --git a/src/test/ui/issues/issue-43623.stderr b/src/test/ui/issues/issue-43623.stderr index d90eb53f9006f..99fb2a1f5d030 100644 --- a/src/test/ui/issues/issue-43623.stderr +++ b/src/test/ui/issues/issue-43623.stderr @@ -2,7 +2,7 @@ error[E0631]: type mismatch in function arguments --> $DIR/issue-43623.rs:14:5 | LL | pub fn break_me(f: F) - | -------- + | -------- required by a bound in this LL | where T: for<'b> Trait<'b>, LL | F: for<'b> FnMut(>::Assoc) { | -------------------------------------- required by this bound in `break_me` @@ -16,7 +16,7 @@ error[E0271]: type mismatch resolving `for<'b> $DIR/issue-43623.rs:14:5 | LL | pub fn break_me(f: F) - | -------- + | -------- required by a bound in this LL | where T: for<'b> Trait<'b>, LL | F: for<'b> FnMut(>::Assoc) { | ------------------------------ required by this bound in `break_me` diff --git a/src/test/ui/issues/issue-47706.stderr b/src/test/ui/issues/issue-47706.stderr index 6cde93734667f..c84d8ecb4c9e6 100644 --- a/src/test/ui/issues/issue-47706.stderr +++ b/src/test/ui/issues/issue-47706.stderr @@ -14,7 +14,7 @@ LL | Bar(i32), | -------- takes 1 argument ... LL | fn foo(f: F) - | --- + | --- required by a bound in this LL | where LL | F: Fn(), | ---- required by this bound in `foo` diff --git a/src/test/ui/issues/issue-60218.stderr b/src/test/ui/issues/issue-60218.stderr index a9970cc109699..77b9d9c4aaa3a 100644 --- a/src/test/ui/issues/issue-60218.stderr +++ b/src/test/ui/issues/issue-60218.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `for<'t> $DIR/issue-60218.rs:18:5 | LL | pub fn trigger_error(iterable: I, functor: F) - | ------------- + | ------------- required by a bound in this ... LL | for<'t> ::IntoIter, F> as Iterator>::Item: Foo, | --- required by this bound in `trigger_error` diff --git a/src/test/ui/issues/issue-60283.stderr b/src/test/ui/issues/issue-60283.stderr index d13dcd54a479a..e74a34e247a67 100644 --- a/src/test/ui/issues/issue-60283.stderr +++ b/src/test/ui/issues/issue-60283.stderr @@ -2,7 +2,7 @@ error[E0631]: type mismatch in function arguments --> $DIR/issue-60283.rs:14:13 | LL | pub fn foo(_: T, _: F) - | --- + | --- required by a bound in this LL | where T: for<'a> Trait<'a>, LL | F: for<'a> FnMut(>::Item) {} | ------------------------------------- required by this bound in `foo` @@ -17,7 +17,7 @@ error[E0271]: type mismatch resolving `for<'a> } as s --> $DIR/issue-60283.rs:14:5 | LL | pub fn foo(_: T, _: F) - | --- + | --- required by a bound in this LL | where T: for<'a> Trait<'a>, LL | F: for<'a> FnMut(>::Item) {} | ----------------------------- required by this bound in `foo` diff --git a/src/test/ui/issues/issue-65673.stderr b/src/test/ui/issues/issue-65673.stderr index 6778ab8bfe4f2..114f2d62e561a 100644 --- a/src/test/ui/issues/issue-65673.stderr +++ b/src/test/ui/issues/issue-65673.stderr @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be know --> $DIR/issue-65673.rs:9:16 | LL | trait WithType { - | -------- + | -------- required by a bound in this LL | type Ctx; | --------- required by this bound in `WithType` ... diff --git a/src/test/ui/suggestions/missing-assoc-type-bound-restriction.stderr b/src/test/ui/suggestions/missing-assoc-type-bound-restriction.stderr index c5510bfa3f2fe..ef484e94729e8 100644 --- a/src/test/ui/suggestions/missing-assoc-type-bound-restriction.stderr +++ b/src/test/ui/suggestions/missing-assoc-type-bound-restriction.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `::Assoc: Child` is not satisfied --> $DIR/missing-assoc-type-bound-restriction.rs:17:19 | LL | trait Parent { - | ------ + | ------ required by a bound in this LL | type Ty; LL | type Assoc: Child; | --------------- required by this bound in `Parent` @@ -16,7 +16,7 @@ error[E0277]: the trait bound `::Assoc: Child` is not satisfied --> $DIR/missing-assoc-type-bound-restriction.rs:20:18 | LL | trait Parent { - | ------ + | ------ required by a bound in this LL | type Ty; LL | type Assoc: Child; | --------------- required by this bound in `Parent` @@ -33,7 +33,7 @@ error[E0277]: the trait bound `::Assoc: Child` is not satisfied --> $DIR/missing-assoc-type-bound-restriction.rs:20:5 | LL | trait Parent { - | ------ + | ------ required by a bound in this LL | type Ty; LL | type Assoc: Child; | --------------- required by this bound in `Parent` diff --git a/src/test/ui/traits/cycle-cache-err-60010.stderr b/src/test/ui/traits/cycle-cache-err-60010.stderr index 356b90d064623..3188ee83e7d39 100644 --- a/src/test/ui/traits/cycle-cache-err-60010.stderr +++ b/src/test/ui/traits/cycle-cache-err-60010.stderr @@ -10,7 +10,7 @@ error[E0275]: overflow evaluating the requirement `Runtime: std::p --> $DIR/cycle-cache-err-60010.rs:31:20 | LL | trait Database { - | -------- + | -------- required by a bound in this LL | type Storage; | ------------- required by this bound in `Database` ... diff --git a/src/test/ui/where-clauses/where-for-self-2.stderr b/src/test/ui/where-clauses/where-for-self-2.stderr index b18b36d029d70..9976243b200dc 100644 --- a/src/test/ui/where-clauses/where-for-self-2.stderr +++ b/src/test/ui/where-clauses/where-for-self-2.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `for<'a> &'a _: Bar` is not satisfied --> $DIR/where-for-self-2.rs:21:5 | LL | fn foo(x: &T) - | --- + | --- required by a bound in this LL | where for<'a> &'a T: Bar | --- required by this bound in `foo` ...