-
Notifications
You must be signed in to change notification settings - Fork 866
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
rustfmt removes comment between impl
keyword and type name in impl block
#5934
Comments
impl
keyword and type name in impl block
Thanks for the report! This is another instance of a location where rustfmt isn't expecting to find a comment. |
Interesting. Comments can appear anywhere and everywhere. |
@leighmcculloch to explain a little further, comments aren't explicitly represented in the AST rustfmt gets back from the rustc parser, and therefore rustfmt needs to peek back into the original source code in order to recover comments. There's comment recovery code for most, but not all locations a comment could exist. For example, comments between the |
What version are you using?
Rust / Cargo 1.72.0
What did you do?
Wrote this code:
Formatted it with
cargo fmt
.What did you expect to see?
What did you see instead?
Rustfmt removed my code comment.
Discussion
Formatting shouldn't be destructive, but removing comments is destructive.
The text was updated successfully, but these errors were encountered: