Files
rust/compiler/rustc_errors
Esteban Küber d0cfd66652 When shortened type would look the same, use textual shortening on the highlighted string instead
Introduce a mechanism to textually trim highlighted strings, so that we can print out "expected/found" note with shorter output while still keeping the highlighted inner parts.

```
error[E0308]: mismatched types
  --> $DIR/long-type-E0308.rs:30:5
   |
LL |   ) -> <
   |  ______-
LL | |     <
LL | |         <T::Wrapper<T> as FooBar>::Assoc as FooBar
LL | |     >::Assoc as FooBar
LL | | >::Wrapper<<T::Assoc as FooBar>::Assoc>
   | |_______________________________________- expected `<_ as FooBar>::Wrapper<_>` because of return type
...
LL |       value...oc())
   |       ^^^^^...^^^^^ expected `really_really_really_long_module::FooBar::Wrapper`, found `really_really_really_long_module::FooBar::Assoc`
   |
   = note: expected associated type `<<<<_ as FooBar>::Wrapper<_> as...pper<_>`
              found associated type `<<<<_ as FooBar>::Assoc as Fo...pper<_>`
   = note: an associated type was expected, but a different one was found
   = note: the full name for the type has been written to '$TEST_BUILD_DIR/long-type-E0308.long-type-$LONG_TYPE_HASH.txt'
   = note: consider using `--verbose` to print the full type name to the console
```
2026-07-20 04:51:11 +00:00
..