-
Notifications
You must be signed in to change notification settings - Fork 909
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 incorrectly strips comments when removing empty where clause #4649
Comments
Hi @calebcartwright is this a valid issue? I think I have an idea. |
@ChinYing-Li - yes we should never drop comments. I don't want to take it to the other end of the spectrum just yet though (leaving an empty where clause in the absence of comments), but we can and should certainly handle the case of comments between the empty clause and the start of the block. |
This issue also occurs when the where clause is not empty. pub trait MyTrait
where
Self: Sized,
// some comment
{
} Once this is saved it will have saved: pub trait MyTrait
where
Self: Sized,
{
} |
The original case with empty The other reported case with non-empty |
…iles (per review comment)
Empty where clauses are semantically valid Rust. However rustfmt incorrectly removes them and comments.
Before:
After:
rustfmt 1.4.25-stable (0f29ff6 2020-11-11)
I also tested it on master a97fd77
The text was updated successfully, but these errors were encountered: