diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2024-10-24 22:16:43 +0000 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2024-11-02 03:08:04 +0000 |
| commit | b7fc1a743122e3c45f105a5d1169a042a2c6e8bf (patch) | |
| tree | 1e26a4fee38823f1ba577c5aae2109643c955136 /tests/ui/try-trait | |
| parent | 7c7bb7dc017545db732f5cffec684bbaeae0a9a0 (diff) | |
| download | rust-b7fc1a743122e3c45f105a5d1169a042a2c6e8bf.tar.gz rust-b7fc1a743122e3c45f105a5d1169a042a2c6e8bf.zip | |
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.
Diffstat (limited to 'tests/ui/try-trait')
| -rw-r--r-- | tests/ui/try-trait/bad-interconversion.stderr | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/tests/ui/try-trait/bad-interconversion.stderr b/tests/ui/try-trait/bad-interconversion.stderr index fe28912ba00..20fe2d721bc 100644 --- a/tests/ui/try-trait/bad-interconversion.stderr +++ b/tests/ui/try-trait/bad-interconversion.stderr @@ -67,7 +67,8 @@ LL | ControlFlow::Continue(Err("hello")?) | ^ this `?` produces `Result<Infallible, &str>`, which is incompatible with `ControlFlow<String>` | = help: the trait `FromResidual<Result<Infallible, &str>>` is not implemented for `ControlFlow<String>` - = help: the trait `FromResidual<ControlFlow<String, Infallible>>` is implemented for `ControlFlow<String>` + = help: the trait `FromResidual<Result<Infallible, &str>>` is not implemented for `ControlFlow<String>` + but trait `FromResidual<ControlFlow<String, Infallible>>` is implemented for it = help: for that trait implementation, expected `ControlFlow<String, Infallible>`, found `Result<Infallible, &str>` error[E0277]: the `?` operator can only be used on `ControlFlow`s in a function that returns `ControlFlow` @@ -79,7 +80,8 @@ LL | Some(3)?; | ^ this `?` produces `Option<Infallible>`, which is incompatible with `ControlFlow<u64>` | = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `ControlFlow<u64>` - = help: the trait `FromResidual<ControlFlow<u64, Infallible>>` is implemented for `ControlFlow<u64>` + = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `ControlFlow<u64>` + but trait `FromResidual<ControlFlow<u64, Infallible>>` is implemented for it = help: for that trait implementation, expected `ControlFlow<u64, Infallible>`, found `Option<Infallible>` error[E0277]: the `?` operator in a function that returns `ControlFlow<B, _>` can only be used on other `ControlFlow<B, _>`s (with the same Break type) @@ -92,7 +94,8 @@ LL | ControlFlow::Break(4_u8)?; | = help: the trait `FromResidual<ControlFlow<u8, Infallible>>` is not implemented for `ControlFlow<i64>` = note: unlike `Result`, there's no `From`-conversion performed for `ControlFlow` - = help: the trait `FromResidual<ControlFlow<i64, Infallible>>` is implemented for `ControlFlow<i64>` + = help: the trait `FromResidual<ControlFlow<u8, _>>` is not implemented for `ControlFlow<i64>` + but trait `FromResidual<ControlFlow<i64, _>>` is implemented for it = help: for that trait implementation, expected `i64`, found `u8` error: aborting due to 8 previous errors |
