Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust_2021_incompatible_closure_captures lint produces bad formatting #87952

Closed
m-ou-se opened this issue Aug 12, 2021 · 1 comment · Fixed by #87953
Closed

rust_2021_incompatible_closure_captures lint produces bad formatting #87952

m-ou-se opened this issue Aug 12, 2021 · 1 comment · Fixed by #87953
Assignees
Labels
A-closures Area: Closures (`|…| { … }`) A-edition-2021 Area: The 2021 edition D-edition Diagnostics: An error or lint that should account for edition differences. D-papercut Diagnostics: An error or lint that needs small tweaks.

Comments

@m-ou-se
Copy link
Member

m-ou-se commented Aug 12, 2021

#![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);
    };
@m-ou-se m-ou-se added A-closures Area: Closures (`|…| { … }`) D-papercut Diagnostics: An error or lint that needs small tweaks. D-edition Diagnostics: An error or lint that should account for edition differences. A-edition-2021 Area: The 2021 edition labels Aug 12, 2021
@m-ou-se m-ou-se self-assigned this Aug 12, 2021
@m-ou-se
Copy link
Member Author

m-ou-se commented Aug 12, 2021

Working on a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-closures Area: Closures (`|…| { … }`) A-edition-2021 Area: The 2021 edition D-edition Diagnostics: An error or lint that should account for edition differences. D-papercut Diagnostics: An error or lint that needs small tweaks.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant