-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
interpret: go back to regular string interpolation for error messages #153611
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1000,20 +1000,6 @@ pub enum AlignFromBytesError { | |
| TooLarge(u64), | ||
| } | ||
|
|
||
| impl AlignFromBytesError { | ||
| pub fn diag_ident(self) -> &'static str { | ||
| match self { | ||
| Self::NotPowerOfTwo(_) => "not_power_of_two", | ||
| Self::TooLarge(_) => "too_large", | ||
| } | ||
| } | ||
|
|
||
| pub fn align(self) -> u64 { | ||
| let (Self::NotPowerOfTwo(align) | Self::TooLarge(align)) = self; | ||
| align | ||
| } | ||
| } | ||
|
|
||
| impl fmt::Debug for AlignFromBytesError { | ||
| fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
| fmt::Display::fmt(self, f) | ||
|
|
@@ -1023,8 +1009,8 @@ impl fmt::Debug for AlignFromBytesError { | |
| impl fmt::Display for AlignFromBytesError { | ||
| fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
| match self { | ||
| AlignFromBytesError::NotPowerOfTwo(align) => write!(f, "`{align}` is not a power of 2"), | ||
| AlignFromBytesError::TooLarge(align) => write!(f, "`{align}` is too large"), | ||
|
Comment on lines
-1026
to
-1027
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I personally prefer this with the backticks
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are just numbers. We don't usually render them with backticks. And in fact they were not rendered with backticks in const-eval errors before, only in JSON errors. I changed the strings here to avoid changing the const-eval error output. |
||
| AlignFromBytesError::NotPowerOfTwo(align) => write!(f, "{align} is not a power of 2"), | ||
| AlignFromBytesError::TooLarge(align) => write!(f, "{align} is too large"), | ||
| } | ||
| } | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
The
AlignFromBytesErrortype got added #111677. Reverting that PR would mean replacing it byStringagain, but it actually seems reasonable to have a proper error type here so I decided to keep the type, but simplify and deduplicate the logic for turning it into a user-visible message.