Do not emit note for projected derived obligations

This commit is contained in:
Esteban Küber 2020-04-11 14:14:16 -07:00
parent 6bc55c701f
commit ce936e9336
29 changed files with 22 additions and 48 deletions

View File

@ -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

View File

@ -456,6 +456,7 @@ fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
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,

View File

@ -134,7 +134,8 @@ fn on_unimplemented_note(
match obligation.cause.code {
ObligationCauseCode::BuiltinDerivedObligation(..)
| ObligationCauseCode::ImplDerivedObligation(..) => {}
| ObligationCauseCode::ImplDerivedObligation(..)
| ObligationCauseCode::DerivedObligation(..) => {}
_ => {
// this is a "direct", user-specified, rather than derived,
// obligation.

View File

@ -1135,7 +1135,8 @@ fn maybe_note_obligation_cause_for_async_await(
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 @@ fn note_obligation_cause_code<T>(
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 \

View File

@ -243,7 +243,7 @@ fn compute_trait_ref(&mut self, trait_ref: &ty::TraitRef<'tcx>, elaborate: Elabo
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,

View File

@ -11,7 +11,6 @@ LL | impl Case1 for S1 {
| ^^^^^ `<L1 as Lam<&'a u8>>::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 `<L1 as Lam<&'a u8>>::App`
= note: required because of the requirements on the impl of `for<'a> std::fmt::Debug` for `<<<<S1 as Case1>::C as std::iter::Iterator>::Item as std::iter::Iterator>::Item as Lam<&'a u8>>::App`
error[E0277]: `<<T as Case1>::C as std::iter::Iterator>::Item` is not an iterator
--> $DIR/bad-bounds-on-assoc-in-trait.rs:36:20

View File

@ -53,7 +53,6 @@ LL | impl<T> 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 `<T as UncheckedCopy>::Output`
help: consider restricting type parameter `T`
|
LL | impl<T: std::fmt::Display> UncheckedCopy for T {}
@ -71,7 +70,6 @@ LL | + Deref<Target = str>
LL | impl<T> 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 `<T as UncheckedCopy>::Output`
help: consider restricting type parameter `T`
|
LL | impl<T: std::ops::Deref> UncheckedCopy for T {}
@ -90,7 +88,6 @@ LL | impl<T> 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 `<T as UncheckedCopy>::Output`
help: consider restricting type parameter `T`
|
LL | impl<T: std::ops::AddAssign<&'static str>> UncheckedCopy for T {}
@ -108,7 +105,6 @@ LL | type Output: Copy
LL | impl<T> 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 `<T as UncheckedCopy>::Output`
help: consider restricting type parameter `T`
|
LL | impl<T: std::marker::Copy> UncheckedCopy for T {}

View File

@ -53,7 +53,6 @@ LL | impl<T> 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 `<T as UncheckedCopy>::Output`
help: consider restricting type parameter `T`
|
LL | impl<T: std::fmt::Display> UncheckedCopy for T {}
@ -71,7 +70,6 @@ LL | + Deref<Target = str>
LL | impl<T> 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 `<T as UncheckedCopy>::Output`
help: consider restricting type parameter `T`
|
LL | impl<T: std::ops::Deref> UncheckedCopy for T {}
@ -90,7 +88,6 @@ LL | impl<T> 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 `<T as UncheckedCopy>::Output`
help: consider restricting type parameter `T`
|
LL | impl<T: std::ops::AddAssign<&'static str>> UncheckedCopy for T {}
@ -108,7 +105,6 @@ LL | type Output: Copy
LL | impl<T> 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 `<T as UncheckedCopy>::Output`
help: consider restricting type parameter `T`
|
LL | impl<T: std::marker::Copy> UncheckedCopy for T {}

View File

@ -16,8 +16,6 @@ LL | type Out: Default + ToString + ?Sized = dyn ToString;
...
LL | impl Foo<u32> 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<u32>>::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<u64> 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<u64>>::Out`
error: aborting due to 3 previous errors

View File

@ -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 `<S as MPU>::MpuConfig`
error: aborting due to 2 previous errors

View File

@ -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 `<S as MPU>::MpuConfig`
error: aborting due to 2 previous errors

View File

@ -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 <Self as Bat>::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

View File

@ -9,7 +9,6 @@ LL | impl <T: Sync+'static> 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 <T: Sync+'static + std::marker::Send> Foo for (T,) { }
@ -26,7 +25,6 @@ LL | impl <T: Send> 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 <T: Send + std::marker::Sync> Foo for (T,T) { }

View File

@ -11,7 +11,6 @@ LL | pub trait RequiresRequiresShareAndSend : RequiresShare + Send { }
|
= help: within `X<T>`, the trait `std::marker::Send` is not implemented for `T`
= note: required because it appears within the type `X<T>`
= note: required because of the requirements on the impl of `std::marker::Send` for `X<T>`
help: consider further restricting this bound
|
LL | impl <T:Sync+'static + std::marker::Send> RequiresRequiresShareAndSend for X<T> { }

View File

@ -8,7 +8,6 @@ LL | impl Foo for std::rc::Rc<i8> { }
| ^^^ `std::rc::Rc<i8>` cannot be sent between threads safely
|
= help: the trait `std::marker::Send` is not implemented for `std::rc::Rc<i8>`
= note: required because of the requirements on the impl of `std::marker::Send` for `std::rc::Rc<i8>`
error: aborting due to previous error

View File

@ -8,7 +8,6 @@ LL | impl <T: Sync+'static> 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 <T: Sync+'static + std::marker::Send> Foo for T { }

View File

@ -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 <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= 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<isize> for [usize] { }
|
= help: the trait `std::marker::Sized` is not implemented for `[usize]`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: required because of the requirements on the impl of `std::marker::Sized` for `[usize]`
error: aborting due to 2 previous errors

View File

@ -9,7 +9,6 @@ LL | impl Tsized for () {}
|
= help: the trait `std::marker::Sized` is not implemented for `[()]`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: required because of the requirements on the impl of `std::marker::Sized` for `[()]`
error: aborting due to previous error

View File

@ -6,8 +6,6 @@ LL | trait Getter<T: Clone2> {
...
LL | impl Getter<isize> 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

View File

@ -57,7 +57,6 @@ LL | impl<'self> Serializable<str> for &'self str {
|
= help: the trait `std::marker::Sized` is not implemented for `str`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: required because of the requirements on the impl of `std::marker::Sized` for `str`
error: aborting due to 9 previous errors

View File

@ -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 `<T as Complete>::Assoc`
help: consider restricting type parameter `T`
|
LL | impl<T: std::marker::Copy> Complete for T {

View File

@ -4,7 +4,6 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied
LL | impl<T> 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<T: std::marker::Copy> Complete for T {}

View File

@ -11,7 +11,6 @@ LL | type Ctx = dyn Alias<T>;
|
= help: the trait `std::marker::Sized` is not implemented for `(dyn Trait + 'static)`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: required because of the requirements on the impl of `std::marker::Sized` for `<T as WithType>::Ctx`
error: aborting due to previous error

View File

@ -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

View File

@ -7,7 +7,6 @@ LL |
LL | default impl<U> 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<U: std::cmp::Eq> Foo<'static, U> for () {}

View File

@ -28,7 +28,6 @@ LL | type Assoc = ChildWrapper<T::Assoc>;
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `Child<A>` is not implemented for `<T as Parent>::Assoc`
|
= note: required because of the requirements on the impl of `Child<A>` for `ChildWrapper<<T as Parent>::Assoc>`
= note: required because of the requirements on the impl of `Child<<ParentWrapper<T> as Parent>::Ty>` for `<ParentWrapper<T> as Parent>::Assoc`
error[E0277]: the trait bound `<T as Parent>::Assoc: Child<A>` is not satisfied
--> $DIR/missing-assoc-type-bound-restriction.rs:20:5

View File

@ -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<RootDatabase>` 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 `<RootDatabase as Database>::Storage`
error: aborting due to 2 previous errors

View File

@ -11,7 +11,6 @@ LL | impl<X: ?Sized> T2<X> for S4<X> {
|
= help: the trait `std::marker::Sized` is not implemented for `X`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: required because of the requirements on the impl of `std::marker::Sized` for `X`
error: aborting due to previous error

View File

@ -11,7 +11,6 @@ LL | impl<X: ?Sized + T> T1<X> for S3<X> {
|
= help: the trait `std::marker::Sized` is not implemented for `X`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: required because of the requirements on the impl of `std::marker::Sized` for `X`
error: aborting due to previous error