Skip to content

unused_unit suggestion includes blank lines #16918

@xtqqczze

Description

@xtqqczze

Summary

Clippy incorrectly formats a function body when removing a redundant unit expression (()), leaving behind an empty line.

Reproducer

Code:

pub fn foo(x: usize) -> () {
    let _ = x;
    ()
}

Current output:

pub fn foo(x: usize) {
    let _ = x;
    
}

Desired output:

pub fn foo(x: usize) {
    let _ = x;
}

Version

clippy 0.1.97 (36ba2c7712 2026-04-23)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingL-suggestionLint: Improving, adding or fixing lint suggestions

    Type

    No type
    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