Skip to content

Commit 7e2e3d4

Browse files
committed
Don't lose an obligation cause
1 parent 312d27d commit 7e2e3d4

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

compiler/rustc_trait_selection/src/traits/wf.rs

-2
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,6 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
309309
}
310310
.into()
311311
});
312-
} else {
313-
cause = traits::ObligationCause::misc(self.span, self.body_id);
314312
}
315313
extend_cause_with_original_assoc_item_obligation(
316314
tcx, trait_ref, item, &mut cause, predicate,

src/test/ui/associated-types/hr-associated-type-projection-1.stderr

+11-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,18 @@ error[E0271]: type mismatch resolving `<T as Deref>::Target == T`
22
--> $DIR/hr-associated-type-projection-1.rs:13:33
33
|
44
LL | impl<T: Copy + std::ops::Deref> UnsafeCopy<'_, T> for T {
5-
| - this type parameter ^^^^^^^^^^^^^^^^^ expected associated type, found type parameter `T`
5+
| - this type parameter ^^^^^^^^^^^^^^^^^ expected type parameter `T`, found associated type
66
|
7-
= note: expected associated type `<T as Deref>::Target`
8-
found type parameter `T`
7+
= note: expected type parameter `T`
8+
found associated type `<T as Deref>::Target`
9+
note: required by a bound in `UnsafeCopy`
10+
--> $DIR/hr-associated-type-projection-1.rs:3:64
11+
|
12+
LL | trait UnsafeCopy<'a, T: Copy>
13+
| ---------- required by a bound in this
14+
LL | where
15+
LL | for<'b> <Self as UnsafeCopy<'b, T>>::Item: std::ops::Deref<Target = T>,
16+
| ^^^^^^^^^^ required by this bound in `UnsafeCopy`
917
help: consider further restricting this bound
1018
|
1119
LL | impl<T: Copy + std::ops::Deref + Deref<Target = T>> UnsafeCopy<'_, T> for T {

src/test/ui/builtin-superkinds/builtin-superkinds-self-type.stderr

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@ error[E0310]: the parameter type `T` may not live long enough
22
--> $DIR/builtin-superkinds-self-type.rs:10:16
33
|
44
LL | impl <T: Sync> Foo for T { }
5-
| ^^^ ...so that the type `T` will meet its required lifetime bounds
5+
| ^^^ ...so that the type `T` will meet its required lifetime bounds...
66
|
7+
note: ...that is required by this bound
8+
--> $DIR/builtin-superkinds-self-type.rs:6:24
9+
|
10+
LL | trait Foo : Sized+Sync+'static {
11+
| ^^^^^^^
712
help: consider adding an explicit lifetime bound...
813
|
914
LL | impl <T: Sync + 'static> Foo for T { }

src/test/ui/traits/assoc-type-in-superbad.stderr

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ error[E0271]: type mismatch resolving `<std::vec::IntoIter<i32> as Iterator>::It
22
--> $DIR/assoc-type-in-superbad.rs:12:16
33
|
44
LL | type Key = u32;
5-
| ^^^ expected `i32`, found `u32`
5+
| ^^^ expected `u32`, found `i32`
6+
|
7+
note: required by a bound in `Foo`
8+
--> $DIR/assoc-type-in-superbad.rs:7:25
9+
|
10+
LL | pub trait Foo: Iterator<Item=<Self as Foo>::Key> {
11+
| ^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Foo`
612

713
error: aborting due to previous error
814

0 commit comments

Comments
 (0)