os-rust/tests/ui/const-generics/defaults/rp_impl_trait_fail.stderr
Esteban Küber b7fc1a7431 Add trait diff highlighting logic and use it in E0277
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.
2024-11-02 03:08:04 +00:00

55 lines
1.9 KiB
Text

error[E0277]: the trait bound `Uwu<10, 12>: Trait` is not satisfied
--> $DIR/rp_impl_trait_fail.rs:6:14
|
LL | fn rawr() -> impl Trait {
| ^^^^^^^^^^ the trait `Trait` is not implemented for `Uwu<10, 12>`
LL |
LL | Uwu::<10, 12>
| ------------- return type was inferred to be `Uwu<10, 12>` here
|
= help: the trait `Trait` is implemented for `Uwu<N>`
error[E0277]: the trait bound `u32: Traitor<N>` is not satisfied
--> $DIR/rp_impl_trait_fail.rs:16:26
|
LL | fn uwu<const N: u8>() -> impl Traitor<N> {
| ^^^^^^^^^^^^^^^ the trait `Traitor<N>` is not implemented for `u32`
LL |
LL | 1_u32
| ----- return type was inferred to be `u32` here
|
= help: the trait `Traitor<N, N>` is not implemented for `u32`
but trait `Traitor<N, 2>` is implemented for it
error[E0277]: the trait bound `u64: Traitor` is not satisfied
--> $DIR/rp_impl_trait_fail.rs:21:13
|
LL | fn owo() -> impl Traitor {
| ^^^^^^^^^^^^ the trait `Traitor` is not implemented for `u64`
LL |
LL | 1_u64
| ----- return type was inferred to be `u64` here
|
= help: the trait `Traitor<1, 1>` is not implemented for `u64`
but trait `Traitor<1, 2>` is implemented for it
error[E0284]: type annotations needed
--> $DIR/rp_impl_trait_fail.rs:28:5
|
LL | uwu();
| ^^^ cannot infer the value of the const parameter `N` declared on the function `uwu`
|
note: required by a const generic parameter in `uwu`
--> $DIR/rp_impl_trait_fail.rs:16:8
|
LL | fn uwu<const N: u8>() -> impl Traitor<N> {
| ^^^^^^^^^^^ required by this const generic parameter in `uwu`
help: consider specifying the generic argument
|
LL | uwu::<N>();
| +++++
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0277, E0284.
For more information about an error, try `rustc --explain E0277`.