forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#121739 - jieyouxu:loooong-typename, r=estebank
Display short types for unimplemented trait Shortens unimplemented trait diagnostics. Now shows: ``` error[E0277]: `Option<Option<Option<...>>>` doesn't implement `std::fmt::Display` --> $DIR/on_unimplemented_long_types.rs:4:17 | LL | pub fn foo() -> impl std::fmt::Display { | ^^^^^^^^^^^^^^^^^^^^^^ `Option<Option<Option<...>>>` cannot be formatted with the default formatter LL | LL | / Some(Some(Some(Some(Some(Some(Some(Some(Some(S... LL | | Some(Some(Some(Some(Some(Some(Some(Some(So... LL | | Some(Some(Some(Some(Some(Some(Some(Som... LL | | Some(Some(Some(Some(Some(Some(Some... ... | LL | | ))))))))))), LL | | ))))))))))) | |_______________- return type was inferred to be `Option<Option<Option<...>>>` here | = help: the trait `std::fmt::Display` is not implemented for `Option<Option<Option<...>>>` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0277`. ``` I'm not 100% sure if this is desirable, or if we should just let the long types remain long. This is also kinda a short-term bandaid solution. The real long term solution is to properly migrate `rustc_trait_selection`'s error reporting to use translatable diagnostics and then properly handle type name printing. Fixes rust-lang#121687.
- Loading branch information
Showing
6 changed files
with
117 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//@ compile-flags: --diagnostic-width=60 -Z write-long-types-to-disk=yes | ||
//@ normalize-stderr-test: "long-type-\d+" -> "long-type-hash" | ||
|
||
pub fn foo() -> impl std::fmt::Display { | ||
//~^ ERROR doesn't implement `std::fmt::Display` | ||
Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some( | ||
Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some( | ||
Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some( | ||
Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some( | ||
Some(Some(Some(Some(Some(Some(Some(Some(())))))))), | ||
))))))))))), | ||
))))))))))), | ||
))))))))))), | ||
))))))))))) | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
error[E0277]: `Option<Option<Option<...>>>` doesn't implement `std::fmt::Display` | ||
--> $DIR/on_unimplemented_long_types.rs:4:17 | ||
| | ||
LL | pub fn foo() -> impl std::fmt::Display { | ||
| ^^^^^^^^^^^^^^^^^^^^^^ `Option<Option<Option<...>>>` cannot be formatted with the default formatter | ||
LL | | ||
LL | / Some(Some(Some(Some(Some(Some(Some(Some(Some(S... | ||
LL | | Some(Some(Some(Some(Some(Some(Some(Some(So... | ||
LL | | Some(Some(Some(Some(Some(Some(Some(Som... | ||
LL | | Some(Some(Some(Some(Some(Some(Some... | ||
... | | ||
LL | | ))))))))))), | ||
LL | | ))))))))))) | ||
| |_______________- return type was inferred to be `Option<Option<Option<...>>>` here | ||
| | ||
= note: the full name for the type has been written to '$TEST_BUILD_DIR/traits/on_unimplemented_long_types/on_unimplemented_long_types.long-type-hash.txt' | ||
= note: consider using `--verbose` to print the full type name to the console | ||
= help: the trait `std::fmt::Display` is not implemented for `Option<Option<Option<...>>>` | ||
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead | ||
= note: the full name for the type has been written to '$TEST_BUILD_DIR/traits/on_unimplemented_long_types/on_unimplemented_long_types.long-type-hash.txt' | ||
= note: consider using `--verbose` to print the full type name to the console | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |