Skip to content

Add a lint for unnecessary trailing return #9426

Closed
@huonw

Description

@huonw
fn foo() -> int {
    return 1; // warning: unnecessary `return`.
}

It would be extremely neat if it could handle

fn foo() -> int {
    if bar() {
        return 1;
    } else {
        return 2;
    }
}

(This is purely stylistic: how many style lints do we want/need?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions