Skip to content

move expect from allow_attributes_without_reason to it's own lint #17409

Description

@ratmice

What it does

Currently allow_attributes works only on allow, but doesn't trigger on expect.
The allow_attributes_without_reason works differently, it applies to both allow and expect.

It would be nice if these could be set separately, so that allow_attributes_without_reason only applied to
#[allow()] and expect_attributes_without_reason could apply the same logic to expect.

Advantage

The allow_attributes lint is too much for many cases, such as when you conditionally need an allow in a #[cfg()] where #[expect(...)] is too strong.

We would like to be able to use:

#[allow(...) reason = "...."]
#[expect(something_else)]

but erroring on

#[allow(some_other_thing)]

Moving expect_attributes_without_reason to it's own lint would allow this kind of flexibility.

Drawbacks

People relying on the current behavior of allow_attributes_without_reason need to enable another lint to keep that behavior.

Example

<code>

Could be written as:

<code>

Comparison with existing lints

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lints

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions