Skip to content

rust_2021_incompatible_closure_captures lint produces bad formatting #87952

Closed
@m-ou-se

Description

@m-ou-se
#![warn(rust_2021_incompatible_closure_captures)]

fn main() {
    let a = ("hey".to_string(), "123".to_string());
    let _ = || {
        dbg!(a.0);
    };
}

suggests:

    let _ = || { let _ = &a; 
        dbg!(a.0);
    };

It adds let _ = &a; on the same line as the {. There's also an extra space after the ; there.

Instead, it'd be nice if it produced:

    let _ = || {
        let _ = &a;
        dbg!(a.0);
    };

Metadata

Metadata

Assignees

Labels

A-closuresArea: Closures (`|…| { … }`)A-edition-2021Area: The 2021 editionD-editionDiagnostics: An error or lint that should account for edition differences.D-papercutDiagnostics: An error or lint that needs small tweaks.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions