b7fc1a7431
When a trait is not implemented for a type, but there *is* an `impl` for another type or different trait params, we format the output to use highlighting in the same way that E0308 does for types. The logic accounts for 3 cases: - When both the type and trait in the expected predicate and the candidate are different - When only the types are different - When only the trait generic params are different For each case, we use slightly different formatting and wording.
84 lines
3.4 KiB
Plaintext
84 lines
3.4 KiB
Plaintext
error[E0599]: the function or associated item `foo` exists for struct `SafeImpl<_, RawImpl<_>>`, but its trait bounds were not satisfied
|
|
--> $DIR/issue-62742.rs:4:16
|
|
|
|
|
LL | WrongImpl::foo(0i32);
|
|
| ^^^ function or associated item cannot be called on `SafeImpl<_, RawImpl<_>>` due to unsatisfied trait bounds
|
|
...
|
|
LL | pub struct RawImpl<T>(PhantomData<T>);
|
|
| --------------------- doesn't satisfy `RawImpl<_>: Raw<_>`
|
|
...
|
|
LL | pub struct SafeImpl<T: ?Sized, A: Raw<T>>(PhantomData<(A, T)>);
|
|
| ----------------------------------------- function or associated item `foo` not found for this struct
|
|
|
|
|
note: trait bound `RawImpl<_>: Raw<_>` was not satisfied
|
|
--> $DIR/issue-62742.rs:35:20
|
|
|
|
|
LL | impl<T: ?Sized, A: Raw<T>> SafeImpl<T, A> {
|
|
| ^^^^^^ --------------
|
|
| |
|
|
| unsatisfied trait bound introduced here
|
|
note: the trait `Raw` must be implemented
|
|
--> $DIR/issue-62742.rs:19:1
|
|
|
|
|
LL | pub trait Raw<T: ?Sized> {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error[E0277]: the trait bound `RawImpl<_>: Raw<_>` is not satisfied
|
|
--> $DIR/issue-62742.rs:4:5
|
|
|
|
|
LL | WrongImpl::foo(0i32);
|
|
| ^^^^^^^^^ the trait `Raw<_>` is not implemented for `RawImpl<_>`
|
|
|
|
|
= help: the trait `Raw<_>` is not implemented for `RawImpl<_>`
|
|
but trait `Raw<[_]>` is implemented for it
|
|
note: required by a bound in `SafeImpl`
|
|
--> $DIR/issue-62742.rs:33:35
|
|
|
|
|
LL | pub struct SafeImpl<T: ?Sized, A: Raw<T>>(PhantomData<(A, T)>);
|
|
| ^^^^^^ required by this bound in `SafeImpl`
|
|
|
|
error[E0599]: the function or associated item `foo` exists for struct `SafeImpl<(), RawImpl<()>>`, but its trait bounds were not satisfied
|
|
--> $DIR/issue-62742.rs:10:22
|
|
|
|
|
LL | WrongImpl::<()>::foo(0i32);
|
|
| ^^^ function or associated item cannot be called on `SafeImpl<(), RawImpl<()>>` due to unsatisfied trait bounds
|
|
...
|
|
LL | pub struct RawImpl<T>(PhantomData<T>);
|
|
| --------------------- doesn't satisfy `RawImpl<()>: Raw<()>`
|
|
...
|
|
LL | pub struct SafeImpl<T: ?Sized, A: Raw<T>>(PhantomData<(A, T)>);
|
|
| ----------------------------------------- function or associated item `foo` not found for this struct
|
|
|
|
|
note: trait bound `RawImpl<()>: Raw<()>` was not satisfied
|
|
--> $DIR/issue-62742.rs:35:20
|
|
|
|
|
LL | impl<T: ?Sized, A: Raw<T>> SafeImpl<T, A> {
|
|
| ^^^^^^ --------------
|
|
| |
|
|
| unsatisfied trait bound introduced here
|
|
note: the trait `Raw` must be implemented
|
|
--> $DIR/issue-62742.rs:19:1
|
|
|
|
|
LL | pub trait Raw<T: ?Sized> {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error[E0277]: the trait bound `RawImpl<()>: Raw<()>` is not satisfied
|
|
--> $DIR/issue-62742.rs:10:5
|
|
|
|
|
LL | WrongImpl::<()>::foo(0i32);
|
|
| ^^^^^^^^^^^^^^^ the trait `Raw<()>` is not implemented for `RawImpl<()>`
|
|
|
|
|
= help: the trait `Raw<()>` is not implemented for `RawImpl<()>`
|
|
but trait `Raw<[()]>` is implemented for it
|
|
= help: for that trait implementation, expected `[()]`, found `()`
|
|
note: required by a bound in `SafeImpl`
|
|
--> $DIR/issue-62742.rs:33:35
|
|
|
|
|
LL | pub struct SafeImpl<T: ?Sized, A: Raw<T>>(PhantomData<(A, T)>);
|
|
| ^^^^^^ required by this bound in `SafeImpl`
|
|
|
|
error: aborting due to 4 previous errors
|
|
|
|
Some errors have detailed explanations: E0277, E0599.
|
|
For more information about an error, try `rustc --explain E0277`.
|