-
Notifications
You must be signed in to change notification settings - Fork 889
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
Feature: upper- or lowercase hexadecimal literals #4903
Conversation
Apologies for the delay but still haven't had a chance to go through this in detail. It seems like a reasonable feature to support so I suspect we'll be able to move ahead, could just potentially have a bit of bikeshedding to do on implementation specifics. |
Thanks! Some bikeshedding is fine, I'm sure some things could be better/more idiomatic. |
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.
This is in great shape, thanks so much! It does sound like a small feature at first, but very much looking forward to being able to get it released.
Will need a couple minor changes (largely renaming the variants and updating all the refs to them) but should be good to merge afterwards.
Configurations.md
Outdated
Change the case of the letters in hexadecimal literal values | ||
|
||
- **Default value**: `Ignore` | ||
- **Possible values**: `ToUpper`, `ToLower` | ||
- **Stable**: No |
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.
Couple minor things I'd like to tweak here. Let's adjust the text to reflect the fact that it can set vs. implying it will change.
Instead of Ignore
, we should use Preserve
to be consistent with variants in our other configuration options, and then let's drop the To
prefix on the other variants.
Change the case of the letters in hexadecimal literal values | |
- **Default value**: `Ignore` | |
- **Possible values**: `ToUpper`, `ToLower` | |
- **Stable**: No | |
Control the case of the letters in hexadecimal literal values | |
- **Default value**: `Preserve` | |
- **Possible values**: `Upper`, `Lower` | |
- **Stable**: No |
src/expr.rs
Outdated
if let Some(hex_lit) = hex_lit { | ||
return Some(format!( | ||
"0x{}{}", | ||
hex_lit, | ||
lit.token.suffix.map_or(String::new(), |s| s.to_string()) | ||
)); | ||
} | ||
} | ||
|
||
Some(context.snippet(span).to_owned()) |
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.
Could you make sure the values will continue to be passed through wrap_str
as they are currently? If we drop that then we're potentially introducing some breaking formatting changes around some edge cases approaching width limits
553fa0a
to
8e3b215
Compare
Thanks for making these updates, though please note there's still at least one more that needs to be resolved before this can proceed |
8e3b215
to
d176b76
Compare
Awesome thank you! Going to go ahead and merge this which will put it on track to be included the next time we update rustfmt. No ETA as of yet, but there will be couple PRs to move across branches and ultimately update the submodule in the main compiler repo. GH should notify you on those given the authorship of the commits so you'll know once this hits nightly |
A small feature to consistently case hexadecimal literals in your Rust code.