rust/tests/ui/error-emitter/E0308-clarification.rs
Esteban Küber c75e601543 Highlight clarifying information in "expected/found" error
When the expected and found types have the same textual representation, we add clarifying in parentheses. We now visually highlight it in the output.

Detect a corner case where the clarifying information would be the same for both types and skip it, as it doesn't add anything useful.
2025-02-02 02:39:43 +00:00

17 lines
481 B
Rust

//@ compile-flags: -Zunstable-options --error-format=human-unicode --color=always
//@ only-linux
// Ensure that when we have a type error where both types have the same textual representation, the
// diagnostic machinery highlights the clarifying comment that comes after in parentheses.
trait Foo: Copy + ToString {}
impl<T: Copy + ToString> Foo for T {}
fn hide<T: Foo>(x: T) -> impl Foo {
x
}
fn main() {
let mut x = (hide(0_u32), hide(0_i32));
x = (x.1, x.0);
}