-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
style-guide: Document formatting of as
casts (mostly like a binary operator)
#114394
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
Some changes occurred in src/doc/style-guide cc @rust-lang/style |
I'll take a closer look at the proposed textual changes, but we do already have a dedicated section for casts (however light it may be) and I'd suggest we consolidate under a single one |
@calebcartwright I completely missed that! I'll consolidate them. I don't think this is a change, just documenting existing behavior. |
… operator) `as` casts currently get formatted like a binary operator, except that the second line can stack several `as` casts rather than breaking them each onto their own line. Merge `as` into a subsection of the binary operators section, and then go into detail on the one difference between `as` formatting and binary operator formatting.
46e156c
to
42fa7df
Compare
@ytmimi - on the off chance you have bandwidth this week to double check rustfmt's current behavior matches the more descriptive style guide text could you do so and confirm here? this one's been waiting on me for a while but I've got some other things above it on my todo list and probably won't be able to give it much attention this week. My initial reaction/mental model aligns with Josh that this aligns with current behavior, but with the increased emphasis on formatting stability and avoiding style guide vs. rustfmt discrepancies I want to check some edge cases with deep nesting, comments, and probably embedded within some bin expressions with paren wrapping too, solely out of an abundance of caution |
@calebcartwright This one got lost in my inbox, but I'll put some time aside this week to validate rustfmt's current behavior. I'm almost positive that rustfmt doesn't handle comments in casts very well (at least not until we land rust-lang/rustfmt#5296). I also found this report rust-lang/rustfmt#3528, which suggests rustfmt isn't wrapping casts correctly. I'll report back once I've spent some more time looking into those edge cases. |
Thanks for looking into it @ytmimi! My inclination continues to be that this updated text to the style guide is correct insofar as describing the desired behavior in a non-breaking way, and the existing (potential) issues in rustfmt aren't affected. |
@bors r+ rollup=always |
…iaskrgr Rollup of 4 pull requests Successful merges: - rust-lang#114394 (style-guide: Document formatting of `as` casts (mostly like a binary operator)) - rust-lang#115990 (Allow anyone to set llvm-fixed-upstream) - rust-lang#116008 (Rename BoxMeUp to PanicPayload.) - rust-lang#116011 (Update browser-ui-test version to 0.16.10) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 4 pull requests Successful merges: - rust-lang#114394 (style-guide: Document formatting of `as` casts (mostly like a binary operator)) - rust-lang#115990 (Allow anyone to set llvm-fixed-upstream) - rust-lang#116008 (Rename BoxMeUp to PanicPayload.) - rust-lang#116011 (Update browser-ui-test version to 0.16.10) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#114394 - joshtriplett:style-guide-as, r=calebcartwright style-guide: Document formatting of `as` casts (mostly like a binary operator) `as` casts currently get formatted like a binary operator, except that the second line can stack several `as` casts rather than breaking them each onto their own line. Document this. As far as I can tell (cc `@calebcartwright` for verification), this is not a 2024 edition change, it just documents current behavior.
as
casts currently get formatted like a binary operator, except thatthe second line can stack several
as
casts rather than breaking themeach onto their own line. Document this.
As far as I can tell (cc @calebcartwright for verification), this is not a 2024 edition change, it just documents current behavior.