-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Use .name_str() to format primitive types in error messages #85187
Conversation
r? @jackh726 (rust-highfive has picked a reviewer for you, use r? to override) |
ty::IntVarValue::IntType(ty) => ty.name_str(), | ||
ty::IntVarValue::UintType(ty) => ty.name_str(), | ||
}; | ||
write!(f, "expected `{}`, found `{}`", expected, found) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the Display
output not just call write u32
/i32
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If not, that's fine. That's what I would expect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no Display
implementation for IntType
, UintType
etc., only a derived Debug
implementation that causes the wrong formatting observed in #84976 (U32
instead of u32
etc.).
@@ -0,0 +1,21 @@ | |||
fn foo(length: &u32) -> i32 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Maybe add a short comment here on what this test is for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@bors r+ rollup |
📌 Commit 69a4ae2 has been approved by |
Rollup of 8 pull requests Successful merges: - rust-lang#83501 (rustdoc: Add unstable CLI option to show basic type layout information) - rust-lang#85018 (shrinking the deprecated method span) - rust-lang#85124 (rustdoc: remove explicit boolean comparisons.) - rust-lang#85136 (Change param name (k to key and v to value) in std::env module) - rust-lang#85162 (Fix typo in variable name) - rust-lang#85187 (Use .name_str() to format primitive types in error messages) - rust-lang#85191 (Improve rustdoc gui tester) - rust-lang#85196 (Revert "Auto merge of rust-lang#84797 - richkadel:cover-unreachable-statements…) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This pull request fixes #84976. The problem described there is caused by this code
rust/compiler/rustc_middle/src/ty/error.rs
Lines 161 to 166 in 506e75c
using
Debug
formatting ({:?}
), while the proper solution is to callname_str()
ofty::IntTy
,ty::UintTy
andty::FloatTy
, respectively.