Teach structured errors to display short `Ty`
Make it so that every structured error annotated with `#[derive(Diagnostic)]` that has a field of type `Ty<'_>`, the printing of that value into a `String` will look at the thread-local storage `TyCtxt` in order to shorten to a length appropriate with the terminal width. When this happen, the resulting error will have a note with the file where the full type name was written to.
```
error[E0618]: expected function, found `((..., ..., ..., ...), ..., ..., ...)``
--> long.rs:7:5
|
6 | fn foo(x: D) { //~ `x` has type `(...
| - `x` has type `((..., ..., ..., ...), ..., ..., ...)`
7 | x(); //~ ERROR expected function, found `(...
| ^--
| |
| call expression requires function
|
= note: the full name for the type has been written to 'long.long-type-14182675702747116984.txt'
= note: consider using `--verbose` to print the full type name to the console
```
2025-02-18 01:15:59 +00:00
|
|
|
//@ compile-flags: --diagnostic-width=60 -Zwrite-long-types-to-disk=yes
|
2025-02-11 20:38:58 +08:00
|
|
|
|
Teach structured errors to display short `Ty`
Make it so that every structured error annotated with `#[derive(Diagnostic)]` that has a field of type `Ty<'_>`, the printing of that value into a `String` will look at the thread-local storage `TyCtxt` in order to shorten to a length appropriate with the terminal width. When this happen, the resulting error will have a note with the file where the full type name was written to.
```
error[E0618]: expected function, found `((..., ..., ..., ...), ..., ..., ...)``
--> long.rs:7:5
|
6 | fn foo(x: D) { //~ `x` has type `(...
| - `x` has type `((..., ..., ..., ...), ..., ..., ...)`
7 | x(); //~ ERROR expected function, found `(...
| ^--
| |
| call expression requires function
|
= note: the full name for the type has been written to 'long.long-type-14182675702747116984.txt'
= note: consider using `--verbose` to print the full type name to the console
```
2025-02-18 01:15:59 +00:00
|
|
|
type A = (i32, i32, i32, i32);
|
|
|
|
|
type B = (A, A, A, A);
|
|
|
|
|
type C = (B, B, B, B);
|
|
|
|
|
type D = (C, C, C, C);
|
|
|
|
|
|
|
|
|
|
fn foo(x: D) { //~ `x` has type `(...
|
|
|
|
|
x(); //~ ERROR expected function, found `(...
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn main() {}
|