about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2022-05-10 08:50:32 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2022-05-10 08:50:32 +0000
commit7e2e3d4ebe9ed4cac5dbf92221bd1d3731b60e57 (patch)
tree87e0b48571653fa189eef94dbf82454d0b514724
parent312d27d0a2aa0c47a00b6803c54a9281d2038c68 (diff)
downloadrust-7e2e3d4ebe9ed4cac5dbf92221bd1d3731b60e57.tar.gz
rust-7e2e3d4ebe9ed4cac5dbf92221bd1d3731b60e57.zip
Don't lose an obligation cause
-rw-r--r--compiler/rustc_trait_selection/src/traits/wf.rs2
-rw-r--r--src/test/ui/associated-types/hr-associated-type-projection-1.stderr14
-rw-r--r--src/test/ui/builtin-superkinds/builtin-superkinds-self-type.stderr7
-rw-r--r--src/test/ui/traits/assoc-type-in-superbad.stderr8
4 files changed, 24 insertions, 7 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs
index 1ee5b385f9a..9752e8e73e7 100644
--- a/compiler/rustc_trait_selection/src/traits/wf.rs
+++ b/compiler/rustc_trait_selection/src/traits/wf.rs
@@ -309,8 +309,6 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
                     }
                     .into()
                 });
-            } else {
-                cause = traits::ObligationCause::misc(self.span, self.body_id);
             }
             extend_cause_with_original_assoc_item_obligation(
                 tcx, trait_ref, item, &mut cause, predicate,
diff --git a/src/test/ui/associated-types/hr-associated-type-projection-1.stderr b/src/test/ui/associated-types/hr-associated-type-projection-1.stderr
index 9c29e969de8..a65f84ae58e 100644
--- a/src/test/ui/associated-types/hr-associated-type-projection-1.stderr
+++ b/src/test/ui/associated-types/hr-associated-type-projection-1.stderr
@@ -2,10 +2,18 @@ error[E0271]: type mismatch resolving `<T as Deref>::Target == T`
   --> $DIR/hr-associated-type-projection-1.rs:13:33
    |
 LL | impl<T: Copy + std::ops::Deref> UnsafeCopy<'_, T> for T {
-   |      - this type parameter      ^^^^^^^^^^^^^^^^^ expected associated type, found type parameter `T`
+   |      - this type parameter      ^^^^^^^^^^^^^^^^^ expected type parameter `T`, found associated type
    |
-   = note: expected associated type `<T as Deref>::Target`
-               found type parameter `T`
+   = note: expected type parameter `T`
+             found associated type `<T as Deref>::Target`
+note: required by a bound in `UnsafeCopy`
+  --> $DIR/hr-associated-type-projection-1.rs:3:64
+   |
+LL | trait UnsafeCopy<'a, T: Copy>
+   |       ---------- required by a bound in this
+LL | where
+LL |     for<'b> <Self as UnsafeCopy<'b, T>>::Item: std::ops::Deref<Target = T>,
+   |                                                                ^^^^^^^^^^ required by this bound in `UnsafeCopy`
 help: consider further restricting this bound
    |
 LL | impl<T: Copy + std::ops::Deref + Deref<Target = T>> UnsafeCopy<'_, T> for T {
diff --git a/src/test/ui/builtin-superkinds/builtin-superkinds-self-type.stderr b/src/test/ui/builtin-superkinds/builtin-superkinds-self-type.stderr
index b1e59e9d5de..e2b177b951c 100644
--- a/src/test/ui/builtin-superkinds/builtin-superkinds-self-type.stderr
+++ b/src/test/ui/builtin-superkinds/builtin-superkinds-self-type.stderr
@@ -2,8 +2,13 @@ error[E0310]: the parameter type `T` may not live long enough
   --> $DIR/builtin-superkinds-self-type.rs:10:16
    |
 LL | impl <T: Sync> Foo for T { }
-   |                ^^^ ...so that the type `T` will meet its required lifetime bounds
+   |                ^^^ ...so that the type `T` will meet its required lifetime bounds...
    |
+note: ...that is required by this bound
+  --> $DIR/builtin-superkinds-self-type.rs:6:24
+   |
+LL | trait Foo : Sized+Sync+'static {
+   |                        ^^^^^^^
 help: consider adding an explicit lifetime bound...
    |
 LL | impl <T: Sync + 'static> Foo for T { }
diff --git a/src/test/ui/traits/assoc-type-in-superbad.stderr b/src/test/ui/traits/assoc-type-in-superbad.stderr
index cbdb6b96f46..f3694791417 100644
--- a/src/test/ui/traits/assoc-type-in-superbad.stderr
+++ b/src/test/ui/traits/assoc-type-in-superbad.stderr
@@ -2,7 +2,13 @@ error[E0271]: type mismatch resolving `<std::vec::IntoIter<i32> as Iterator>::It
   --> $DIR/assoc-type-in-superbad.rs:12:16
    |
 LL |     type Key = u32;
-   |                ^^^ expected `i32`, found `u32`
+   |                ^^^ expected `u32`, found `i32`
+   |
+note: required by a bound in `Foo`
+  --> $DIR/assoc-type-in-superbad.rs:7:25
+   |
+LL | pub trait Foo: Iterator<Item=<Self as Foo>::Key> {
+   |                         ^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Foo`
 
 error: aborting due to previous error