-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
The useless attribute lint doesn't put the ! in the right place. #1522
Comments
I just had this issue with |
It looks like there is no attribute information for I believe rust-lang/rust#25544 is related somehow |
Unfortunately this seems really difficult to find a proper fix for. Since I managed to get a fix working, but only if the whole Maybe it's easier to remove the suggestion from this lint for now? @oli-obk |
@phansch can you detect the cfg case? if so, just don't emit the suggestion in the cfg case |
Sorry, my previous comment was partly wrong (now updated): As far as I can tell, only #[cfg_attr(feature = "cargo-clippy",
allow(dead_code),
allow(new_without_default))] That would require iterating over each line towards the beginning of the file, making a Span out of each Line, checking if the span contains the beginning of the attribute (a
|
So... we could just not create a suggestion at all in the multi line case? |
That would be the easier solution, yes. If the attribute starts on the same line, we show the correct suggestion, otherwise we don't show a suggestion 👍 |
When the useless_attribute lint is activated, it says that you most likely forgot an exclamation mark (!). While this is true, it also suggests to stick the ! in the middle of the attribute:
The correct response should be to suggest adding it after the #
I'm using the latest clippy on the latest nightly Rust.
The text was updated successfully, but these errors were encountered: