mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 22:12:15 +00:00
Only point at impl self ty in WF if trait predicate shares self ty
This commit is contained in:
parent
2aabb0fd5d
commit
5924c2511e
@ -1267,14 +1267,21 @@ fn check_impl<'tcx>(
|
||||
},
|
||||
polarity: ty::ImplPolarity::Positive,
|
||||
};
|
||||
let obligations = traits::wf::trait_obligations(
|
||||
let mut obligations = traits::wf::trait_obligations(
|
||||
wfcx.infcx,
|
||||
wfcx.param_env,
|
||||
wfcx.body_id,
|
||||
&trait_pred,
|
||||
ast_self_ty.span,
|
||||
ast_trait_ref.path.span,
|
||||
item,
|
||||
);
|
||||
for obligation in &mut obligations {
|
||||
if let Some(pred) = obligation.predicate.to_opt_poly_trait_pred()
|
||||
&& pred.self_ty().skip_binder() == trait_ref.self_ty()
|
||||
{
|
||||
obligation.cause.span = ast_self_ty.span;
|
||||
}
|
||||
}
|
||||
debug!(?obligations);
|
||||
wfcx.register_obligations(obligations);
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
error[E0277]: the trait bound `for<'b> T: X<'b, T>` is not satisfied
|
||||
--> $DIR/hr-associated-type-bound-param-6.rs:12:25
|
||||
--> $DIR/hr-associated-type-bound-param-6.rs:12:12
|
||||
|
|
||||
LL | impl<S, T> X<'_, T> for (S,) {
|
||||
| ^^^^ the trait `for<'b> X<'b, T>` is not implemented for `T`
|
||||
| ^^^^^^^^ the trait `for<'b> X<'b, T>` is not implemented for `T`
|
||||
|
|
||||
help: consider restricting type parameter `T`
|
||||
|
|
||||
|
@ -1,8 +1,8 @@
|
||||
error[E0271]: type mismatch resolving `<T as Deref>::Target == T`
|
||||
--> $DIR/hr-associated-type-projection-1.rs:13:55
|
||||
--> $DIR/hr-associated-type-projection-1.rs:13:33
|
||||
|
|
||||
LL | impl<T: Copy + std::ops::Deref> UnsafeCopy<'_, T> for T {
|
||||
| - this type parameter ^ expected type parameter `T`, found associated type
|
||||
| - this type parameter ^^^^^^^^^^^^^^^^^ expected type parameter `T`, found associated type
|
||||
|
|
||||
= note: expected type parameter `T`
|
||||
found associated type `<T as Deref>::Target`
|
||||
|
@ -1,8 +1,8 @@
|
||||
error[E0310]: the parameter type `T` may not live long enough
|
||||
--> $DIR/builtin-superkinds-self-type.rs:10:24
|
||||
--> $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
|
||||
|
@ -23,10 +23,10 @@ LL | [<u8 as Baz>::Quaks; 2]: Bar,
|
||||
= help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
|
||||
|
||||
error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied
|
||||
--> $DIR/issue-67185-2.rs:21:14
|
||||
--> $DIR/issue-67185-2.rs:21:6
|
||||
|
|
||||
LL | impl Foo for FooImpl {}
|
||||
| ^^^^^^^ the trait `Bar` is not implemented for `[u16; 3]`
|
||||
| ^^^ the trait `Bar` is not implemented for `[u16; 3]`
|
||||
|
|
||||
= help: the following other types implement trait `Bar`:
|
||||
[[u16; 3]; 3]
|
||||
@ -41,10 +41,10 @@ LL | <u8 as Baz>::Quaks: Bar,
|
||||
| ^^^ required by this bound in `Foo`
|
||||
|
||||
error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied
|
||||
--> $DIR/issue-67185-2.rs:21:14
|
||||
--> $DIR/issue-67185-2.rs:21:6
|
||||
|
|
||||
LL | impl Foo for FooImpl {}
|
||||
| ^^^^^^^ the trait `Bar` is not implemented for `[[u16; 3]; 2]`
|
||||
| ^^^ the trait `Bar` is not implemented for `[[u16; 3]; 2]`
|
||||
|
|
||||
= help: the following other types implement trait `Bar`:
|
||||
[[u16; 3]; 3]
|
||||
|
@ -1,8 +1,8 @@
|
||||
error[E0277]: the size for values of type `[isize]` cannot be known at compilation time
|
||||
--> $DIR/dst-sized-trait-param.rs:7:23
|
||||
--> $DIR/dst-sized-trait-param.rs:7:6
|
||||
|
|
||||
LL | impl Foo<[isize]> for usize { }
|
||||
| ^^^^^ doesn't have a size known at compile-time
|
||||
| ^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
= help: the trait `Sized` is not implemented for `[isize]`
|
||||
note: required by a bound in `Foo`
|
||||
|
@ -1,8 +1,8 @@
|
||||
error[E0309]: the parameter type `T` may not live long enough
|
||||
--> $DIR/implied-bounds-unnorm-associated-type-5.rs:6:27
|
||||
--> $DIR/implied-bounds-unnorm-associated-type-5.rs:6:13
|
||||
|
|
||||
LL | impl<'a, T> Trait<'a> 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/implied-bounds-unnorm-associated-type-5.rs:1:18
|
||||
|
@ -1,8 +1,8 @@
|
||||
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:17
|
||||
--> $DIR/issue-61631-default-type-param-can-reference-self-in-trait.rs:19:6
|
||||
|
|
||||
LL | impl Tsized for () {}
|
||||
| ^^ doesn't have a size known at compile-time
|
||||
| ^^^^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
= help: the trait `Sized` is not implemented for `[()]`
|
||||
note: required by a bound in `Tsized`
|
||||
|
@ -53,10 +53,10 @@ LL | impl<'self> Serializable<'_, str> for &'self str {
|
||||
| +++
|
||||
|
||||
error[E0277]: the size for values of type `str` cannot be known at compilation time
|
||||
--> $DIR/issue-10412.rs:7:35
|
||||
--> $DIR/issue-10412.rs:7:13
|
||||
|
|
||||
LL | impl<'self> Serializable<str> for &'self str {
|
||||
| ^^^^^^^^^^ doesn't have a size known at compile-time
|
||||
| ^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
= help: the trait `Sized` is not implemented for `str`
|
||||
note: required by a bound in `Serializable`
|
||||
|
@ -1,17 +1,17 @@
|
||||
error[E0059]: type parameter to bare `FnMut` trait must be a tuple
|
||||
--> $DIR/overloaded-calls-nontuple.rs:10:23
|
||||
--> $DIR/overloaded-calls-nontuple.rs:10:6
|
||||
|
|
||||
LL | impl FnMut<isize> for S {
|
||||
| ^ the trait `Tuple` is not implemented for `isize`
|
||||
| ^^^^^^^^^^^^ the trait `Tuple` is not implemented for `isize`
|
||||
|
|
||||
note: required by a bound in `FnMut`
|
||||
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
||||
|
||||
error[E0059]: type parameter to bare `FnOnce` trait must be a tuple
|
||||
--> $DIR/overloaded-calls-nontuple.rs:18:24
|
||||
--> $DIR/overloaded-calls-nontuple.rs:18:6
|
||||
|
|
||||
LL | impl FnOnce<isize> for S {
|
||||
| ^ the trait `Tuple` is not implemented for `isize`
|
||||
| ^^^^^^^^^^^^^ the trait `Tuple` is not implemented for `isize`
|
||||
|
|
||||
note: required by a bound in `FnOnce`
|
||||
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
||||
|
@ -9,10 +9,10 @@ LL | #![feature(specialization)]
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
error[E0277]: the trait bound `U: Eq` is not satisfied
|
||||
--> $DIR/specialization-wfcheck.rs:7:37
|
||||
--> $DIR/specialization-wfcheck.rs:7:17
|
||||
|
|
||||
LL | default impl<U> Foo<'static, U> for () {}
|
||||
| ^^ the trait `Eq` is not implemented for `U`
|
||||
| ^^^^^^^^^^^^^^^ the trait `Eq` is not implemented for `U`
|
||||
|
|
||||
note: required by a bound in `Foo`
|
||||
--> $DIR/specialization-wfcheck.rs:5:18
|
||||
|
@ -1,8 +1,8 @@
|
||||
error[E0478]: lifetime bound not satisfied
|
||||
--> $DIR/static-lifetime.rs:3:34
|
||||
--> $DIR/static-lifetime.rs:3:20
|
||||
|
|
||||
LL | impl<'a, A: Clone> Arbitrary for ::std::borrow::Cow<'a, A> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
note: lifetime parameter instantiated with the lifetime `'a` as defined here
|
||||
--> $DIR/static-lifetime.rs:3:6
|
||||
|
@ -223,10 +223,10 @@ LL | trait Trait6<A: ?Sized, B> {}
|
||||
| ++++++++
|
||||
|
||||
error[E0277]: the size for values of type `Y` cannot be known at compilation time
|
||||
--> $DIR/unsized-bound.rs:26:29
|
||||
--> $DIR/unsized-bound.rs:26:12
|
||||
|
|
||||
LL | impl<X, Y> Trait7<X, Y> for X where Y: ?Sized {}
|
||||
| - ^ doesn't have a size known at compile-time
|
||||
| - ^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||
| |
|
||||
| this type parameter needs to be `std::marker::Sized`
|
||||
|
|
||||
@ -246,10 +246,10 @@ LL | trait Trait7<A, B: ?Sized> {}
|
||||
| ++++++++
|
||||
|
||||
error[E0277]: the size for values of type `Y` cannot be known at compilation time
|
||||
--> $DIR/unsized-bound.rs:29:37
|
||||
--> $DIR/unsized-bound.rs:29:20
|
||||
|
|
||||
LL | impl<X, Y: ?Sized> Trait8<X, Y> for X {}
|
||||
| - ^ doesn't have a size known at compile-time
|
||||
| - ^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||
| |
|
||||
| this type parameter needs to be `std::marker::Sized`
|
||||
|
|
||||
|
@ -1,8 +1,8 @@
|
||||
error[E0277]: the trait bound `u16: Trait` is not satisfied
|
||||
--> $DIR/on-structs-and-enums-in-impls.rs:20:30
|
||||
--> $DIR/on-structs-and-enums-in-impls.rs:20:6
|
||||
|
|
||||
LL | impl PolyTrait<Foo<u16>> for Struct {
|
||||
| ^^^^^^ the trait `Trait` is not implemented for `u16`
|
||||
| ^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `u16`
|
||||
|
|
||||
note: required by a bound in `Foo`
|
||||
--> $DIR/on-structs-and-enums-in-impls.rs:3:14
|
||||
|
@ -1,8 +1,8 @@
|
||||
error[E0277]: the size for values of type `X` cannot be known at compilation time
|
||||
--> $DIR/unsized-trait-impl-trait-arg.rs:8:27
|
||||
--> $DIR/unsized-trait-impl-trait-arg.rs:8:17
|
||||
|
|
||||
LL | impl<X: ?Sized> T2<X> for S4<X> {
|
||||
| - ^^^^^ doesn't have a size known at compile-time
|
||||
| - ^^^^^ doesn't have a size known at compile-time
|
||||
| |
|
||||
| this type parameter needs to be `std::marker::Sized`
|
||||
|
|
||||
|
@ -1,8 +1,8 @@
|
||||
error[E0277]: the size for values of type `X` cannot be known at compilation time
|
||||
--> $DIR/unsized7.rs:12:31
|
||||
--> $DIR/unsized7.rs:12:21
|
||||
|
|
||||
LL | impl<X: ?Sized + T> T1<X> for S3<X> {
|
||||
| - ^^^^^ doesn't have a size known at compile-time
|
||||
| - ^^^^^ doesn't have a size known at compile-time
|
||||
| |
|
||||
| this type parameter needs to be `std::marker::Sized`
|
||||
|
|
||||
|
Loading…
Reference in New Issue
Block a user