Point to the value instead of the TAIT declaration for obligation failures

This commit is contained in:
Oli Scherer 2021-07-30 14:51:40 +00:00
parent b2c1919a3d
commit 092e9ccd8a
15 changed files with 49 additions and 50 deletions

View file

@ -28,9 +28,9 @@ impl Bar for AssocNoCopy {
impl Thing for AssocNoCopy {
type Out = Box<dyn Bar<Assoc: Copy>>;
//~^ ERROR the trait bound `String: Copy` is not satisfied
fn func() -> Self::Out {
//~^ ERROR the trait bound `String: Copy` is not satisfied
Box::new(AssocNoCopy)
}
}

View file

@ -1,8 +1,8 @@
error[E0277]: the trait bound `String: Copy` is not satisfied
--> $DIR/assoc-type-eq-with-dyn-atb-fail.rs:30:28
--> $DIR/assoc-type-eq-with-dyn-atb-fail.rs:32:18
|
LL | type Out = Box<dyn Bar<Assoc: Copy>>;
| ^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
LL | fn func() -> Self::Out {
| ^^^^^^^^^ the trait `Copy` is not implemented for `String`
error: aborting due to previous error

View file

@ -8,12 +8,12 @@ pub trait Bar {
impl<S: Default> Bar for S {
type E = impl Copy;
//~^ ERROR the trait bound `S: Copy` is not satisfied in `(S, T)` [E0277]
//~^^ ERROR the trait bound `T: Copy` is not satisfied in `(S, T)` [E0277]
fn foo<T: Default>() -> Self::E {
//~^ ERROR type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias
//~| ERROR impl has stricter requirements than trait
//~| ERROR the trait bound `S: Copy` is not satisfied in `(S, T)` [E0277]
//~| ERROR the trait bound `T: Copy` is not satisfied in `(S, T)` [E0277]
(S::default(), T::default())
}
}

View file

@ -1,5 +1,5 @@
error[E0276]: impl has stricter requirements than trait
--> $DIR/issue-55872-1.rs:14:5
--> $DIR/issue-55872-1.rs:12:5
|
LL | fn foo<T>() -> Self::E;
| ----------------------- definition of `foo` from trait
@ -8,10 +8,10 @@ LL | fn foo<T: Default>() -> Self::E {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: Default`
error[E0277]: the trait bound `S: Copy` is not satisfied in `(S, T)`
--> $DIR/issue-55872-1.rs:10:14
--> $DIR/issue-55872-1.rs:12:29
|
LL | type E = impl Copy;
| ^^^^^^^^^ within `(S, T)`, the trait `Copy` is not implemented for `S`
LL | fn foo<T: Default>() -> Self::E {
| ^^^^^^^ within `(S, T)`, the trait `Copy` is not implemented for `S`
|
= note: required because it appears within the type `(S, T)`
help: consider further restricting this bound
@ -20,10 +20,10 @@ LL | impl<S: Default + std::marker::Copy> Bar for S {
| ^^^^^^^^^^^^^^^^^^^
error[E0277]: the trait bound `T: Copy` is not satisfied in `(S, T)`
--> $DIR/issue-55872-1.rs:10:14
--> $DIR/issue-55872-1.rs:12:29
|
LL | type E = impl Copy;
| ^^^^^^^^^ within `(S, T)`, the trait `Copy` is not implemented for `T`
LL | fn foo<T: Default>() -> Self::E {
| ^^^^^^^ within `(S, T)`, the trait `Copy` is not implemented for `T`
|
= note: required because it appears within the type `(S, T)`
help: consider further restricting this bound
@ -32,12 +32,14 @@ LL | fn foo<T: Default + std::marker::Copy>() -> Self::E {
| ^^^^^^^^^^^^^^^^^^^
error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias
--> $DIR/issue-55872-1.rs:14:37
--> $DIR/issue-55872-1.rs:12:37
|
LL | fn foo<T: Default>() -> Self::E {
| _____________________________________^
LL | |
LL | |
LL | |
LL | |
LL | | (S::default(), T::default())
LL | | }
| |_____^

View file

@ -11,9 +11,9 @@ pub trait Bar {
impl<S> Bar for S {
type E = impl std::marker::Copy;
//~^ ERROR the trait bound `impl Future: Copy` is not satisfied [E0277]
fn foo<T>() -> Self::E {
//~^ ERROR type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias
//~| ERROR the trait bound `impl Future: Copy` is not satisfied [E0277]
async {}
}
}

View file

@ -1,15 +1,16 @@
error[E0277]: the trait bound `impl Future: Copy` is not satisfied
--> $DIR/issue-55872-2.rs:13:14
--> $DIR/issue-55872-2.rs:14:20
|
LL | type E = impl std::marker::Copy;
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `impl Future`
LL | fn foo<T>() -> Self::E {
| ^^^^^^^ the trait `Copy` is not implemented for `impl Future`
error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias
--> $DIR/issue-55872-2.rs:15:28
--> $DIR/issue-55872-2.rs:14:28
|
LL | fn foo<T>() -> Self::E {
| ____________________________^
LL | |
LL | |
LL | | async {}
LL | | }
| |_____^

View file

@ -7,9 +7,9 @@ fn main() {
}
type WrongGeneric<T> = impl 'static;
//~^ ERROR the parameter type `T` may not live long enough
//~| ERROR: at least one trait must be specified
//~^ ERROR: at least one trait must be specified
fn wrong_generic<T>(t: T) -> WrongGeneric<T> {
//~^ ERROR the parameter type `T` may not live long enough
t
}

View file

@ -19,13 +19,12 @@ LL | type WrongGeneric<T> = impl 'static;
found opaque type `impl Sized`
error[E0310]: the parameter type `T` may not live long enough
--> $DIR/generic_type_does_not_live_long_enough.rs:9:24
--> $DIR/generic_type_does_not_live_long_enough.rs:12:30
|
LL | type WrongGeneric<T> = impl 'static;
| ^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
...
LL | fn wrong_generic<T>(t: T) -> WrongGeneric<T> {
| - help: consider adding an explicit lifetime bound...: `T: 'static`
| - ^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
| |
| help: consider adding an explicit lifetime bound...: `T: 'static`
error: aborting due to 3 previous errors

View file

@ -15,9 +15,9 @@ struct X;
impl Foo for X {
type Bar = impl Baz<Self, Self>;
//~^ ERROR implementation of `FnOnce` is not general enough
fn bar(&self) -> Self::Bar {
//~^ ERROR implementation of `FnOnce` is not general enough
|x| x
}
}

View file

@ -1,8 +1,8 @@
error: implementation of `FnOnce` is not general enough
--> $DIR/issue-57611-trait-alias.rs:17:16
--> $DIR/issue-57611-trait-alias.rs:19:22
|
LL | type Bar = impl Baz<Self, Self>;
| ^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough
LL | fn bar(&self) -> Self::Bar {
| ^^^^^^^^^ implementation of `FnOnce` is not general enough
|
= note: closure with signature `fn(&'2 X) -> &X` must implement `FnOnce<(&'1 X,)>`, for any lifetime `'1`...
= note: ...but it actually implements `FnOnce<(&'2 X,)>`, for some specific lifetime `'2`

View file

@ -8,9 +8,9 @@ trait Bug {
impl Bug for &() {
type Item = impl Bug; //~ ERROR `impl Trait` in type aliases is unstable
//~^ ERROR the trait bound `(): Bug` is not satisfied
const FUN: fn() -> Self::Item = || ();
//~^ ERROR the trait bound `(): Bug` is not satisfied
}
fn main() {}

View file

@ -8,10 +8,10 @@ LL | type Item = impl Bug;
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
error[E0277]: the trait bound `(): Bug` is not satisfied
--> $DIR/issue-60371.rs:10:17
--> $DIR/issue-60371.rs:12:40
|
LL | type Item = impl Bug;
| ^^^^^^^^ the trait `Bug` is not implemented for `()`
LL | const FUN: fn() -> Self::Item = || ();
| ^ the trait `Bug` is not implemented for `()`
|
= help: the following implementations were found:
<&() as Bug>

View file

@ -5,9 +5,9 @@
#![feature(type_alias_impl_trait)]
type X<A, B> = impl Into<&'static A>;
//~^ ERROR the trait bound `&'static B: From<&A>` is not satisfied
fn f<A, B: 'static>(a: &'static A, b: B) -> (X<A, B>, X<B, A>) {
//~^ ERROR the trait bound `&'static B: From<&A>` is not satisfied
(a, a)
}

View file

@ -1,8 +1,8 @@
error[E0277]: the trait bound `&'static B: From<&A>` is not satisfied
--> $DIR/multiple-def-uses-in-one-fn.rs:7:16
--> $DIR/multiple-def-uses-in-one-fn.rs:9:45
|
LL | type X<A, B> = impl Into<&'static A>;
| ^^^^^^^^^^^^^^^^^^^^^ the trait `From<&A>` is not implemented for `&'static B`
LL | fn f<A, B: 'static>(a: &'static A, b: B) -> (X<A, B>, X<B, A>) {
| ^^^^^^^^^^^^^^^^^^ the trait `From<&A>` is not implemented for `&'static B`
|
= note: required because of the requirements on the impl of `Into<&'static B>` for `&A`
help: consider introducing a `where` bound, but there might be an alternative better way to express this requirement