-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Teach structured errors to display short Ty<'_>
#137201
base: master
Are you sure you want to change the base?
Conversation
Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri, @rust-lang/wg-const-eval Some changes occurred in compiler/rustc_passes/src/check_attr.rs Some changes occurred in match checking cc @Nadrieril Some changes occurred to the CTFE machinery cc @rust-lang/wg-const-eval Some changes occurred in need_type_info.rs cc @lcnr |
d8758cd
to
56a942b
Compare
56a942b
to
a33d786
Compare
This comment has been minimized.
This comment has been minimized.
b19a017
to
2dcd85f
Compare
@bors r+ |
…, r=oli-obk Teach structured errors to display short `Ty<'_>` Make it so that in 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 ``` Follow up to and response to the comments on rust-lang#136898. r? `@oli-obk`
Needs rebase due to #135726 which added impl IntoDiagArg for RustcVersion {
fn into_diag_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Owned(self.to_string()))
}
} to https://github.com/rust-lang/blobrust/blob/compiler/rustc_errors/src/diagnostic_impls.rs. (CI failed in rollup #137607: #137607 (comment)) @bors r- |
This comment has been minimized.
This comment has been minimized.
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 ```
``` error[E0614]: type `(..., ..., ..., ...)` cannot be dereferenced --> $DIR/long-E0614.rs:10:5 | LL | *x; | ^^ can't be dereferenced | = note: the full name for the type has been written to '$TEST_BUILD_DIR/$FILE.long-type-hash.txt' = note: consider using `--verbose` to print the full type name to the console ```
2dcd85f
to
c550bee
Compare
Make it so that in every structured error annotated with
#[derive(Diagnostic)]
that has a field of typeTy<'_>
, the printing of that value into aString
will look at the thread-local storageTyCtxt
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.Follow up to and response to the comments on #136898.
r? @oli-obk