Skip to content

'unneeded return' fires when return is needed due to attribute #9361

Closed
@RalfJung

Description

@RalfJung

Description

Consider code like this:

        #[allow(clippy::integer_arithmetic)] // cannot overflow
        return discriminant << data_size | data;

The return is needed here because attributes can only be applied to statements, not expressions. But nevertheless clippy says I should remove the return...

Version

rustc 1.65.0-nightly (4b695f7c4 2022-08-21)
binary: rustc
commit-hash: 4b695f7c4e1a02d160fe7e159abd0f87027c0fcf
commit-date: 2022-08-21
host: x86_64-unknown-linux-gnu
release: 1.65.0-nightly
LLVM version: 15.0.0

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions