Skip to content

unused allow annotation #10801

@laralove143

Description

@laralove143

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions