Use .name_str() to format primitive types in error messages#85187
Merged
bors merged 2 commits intorust-lang:masterfrom May 12, 2021
Merged
Use .name_str() to format primitive types in error messages#85187bors merged 2 commits intorust-lang:masterfrom
bors merged 2 commits intorust-lang:masterfrom
Conversation
Contributor
|
r? @jackh726 (rust-highfive has picked a reviewer for you, use r? to override) |
jackh726
approved these changes
May 11, 2021
| ty::IntVarValue::IntType(ty) => ty.name_str(), | ||
| ty::IntVarValue::UintType(ty) => ty.name_str(), | ||
| }; | ||
| write!(f, "expected `{}`, found `{}`", expected, found) |
Member
There was a problem hiding this comment.
Does the Display output not just call write u32/i32?
Member
There was a problem hiding this comment.
If not, that's fine. That's what I would expect.
Contributor
Author
There was a problem hiding this comment.
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 { | |||
Member
There was a problem hiding this comment.
Nit: Maybe add a short comment here on what this test is for?
Member
|
@bors r+ rollup |
Collaborator
|
📌 Commit 69a4ae2 has been approved by |
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
May 11, 2021
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 file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Debugformatting ({:?}), while the proper solution is to callname_str()ofty::IntTy,ty::UintTyandty::FloatTy, respectively.