-
Notifications
You must be signed in to change notification settings - Fork 891
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 deletes polarity of negative impl #4566
Comments
That's an odd miss considering rustfmt wasn't "officially" released til 1.31.0 🤔 I'm a bit behind on rustfmt PRs and issues but will try to take a look at this after work today |
Ah I see, this only occurs in the absence of a trait_ref (compare with While I'm not sure what the use case is for a negative impl without a Going to mark this as a good-first-issue in case others want to work on it, but please let me know if this is a blocker/higher urgency for you and I'll go ahead and resolve myself. For anyone interested in working on this, you'll want to take a look at the Things are already taken care of when there is a trait ref: rustfmt/src/formatting/items.rs Lines 967 to 976 in fd9e7d3
But in cases where there isn't then rustfmt is silently tossing the polarity string. In order to resolve this, we should probably incorporate a new check that looks for the combination of a negative polarity and the absence of a trait ref, and if true then ensure the polarity string ( Be sure to include the extra character in the budget computations to prevent any off-by-one issues with edgier cases that run up around the max_width limit, and then incorporate the check both for the case where the type string can fit on one line: rustfmt/src/formatting/items.rs Lines 991 to 1004 in fd9e7d3
and the case where it has to be multilined rustfmt/src/formatting/items.rs Lines 1006 to 1019 in fd9e7d3
|
As of current master branch (fd9e7d3):
Expected:
impl !Trait {}
Actual:
impl Trait {}
This syntax is accepted syntactically by rustc since 1.25.0. Playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=a0af137c2df7c45fe1571573ec6a8ad3
The text was updated successfully, but these errors were encountered: