Skip to content
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

unused allow annotation #10801

Closed
laralove143 opened this issue May 19, 2023 · 2 comments
Closed

unused allow annotation #10801

laralove143 opened this issue May 19, 2023 · 2 comments
Labels
A-lint Area: New lints

Comments

@laralove143
Copy link

What it does

we add #[allow(lint)] to a function to suppress a lint, when that function's body changes and no longer raises that lint, we have the old #[allow(lint)] annotation silently staying there

we might also add #[allow(lint)] to a function because we're sure it will raise that lint, and we turn out to be wrong we dont realize we added that for no reason

Lint Name

unused_allow

Category

style

Advantage

  • keeps code clean
  • doesnt give the idea that the function raises the lint
  • gives no hint to the history of a function

Drawbacks

we might wanna allow a lint to express that we dont care if this happens in the future, in which case we can also allow this lint to express that more explicitly

Example

say we think ignoring an error is fine

#[allow(unused_must_use)]
fn foo() {
  let _: Result<_, _> = fallible();
}

then we realize we do need to handle the error so we rewrite the function to

#[allow(unused_must_use)]
fn foo() {
  fallible().handle();
}

but here #[allow(unused_must_use)] stays even tho it doesnt need to

@laralove143 laralove143 added the A-lint Area: New lints label May 19, 2023
@xFrednet
Copy link
Member

xFrednet commented May 20, 2023

Hey @laralove143, this is a feature which would need to be implemented in the compiler and not Clippy. There was already an RFC to add a feature like this, see: rust-lang/rfcs#2383. If you're interested, you can ready the tracking issue and the linked Zulip conversation. The stabilization is currently held up on a discussion how the new attribute should exactly work. If you have any thoughts on the matter or additional use cases, I'd highly appreciate your input :)

@xFrednet
Copy link
Member

I'm closing this issue, as the discussion moved into the tracking issue. If such a lint would be added, it would need to be implemented in rustc anyways :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints
Projects
None yet
Development

No branches or pull requests

2 participants