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

Multiline closure body parenthesization can cause incorrect precedence #99

Closed
dtolnay opened this issue Jan 12, 2025 · 0 comments · Fixed by #100
Closed

Multiline closure body parenthesization can cause incorrect precedence #99

dtolnay opened this issue Jan 12, 2025 · 0 comments · Fixed by #100

Comments

@dtolnay
Copy link
Owner

dtolnay commented Jan 12, 2025

fn main() {
    let input: syn::File = syn::parse_quote! {
        const _: _ = || { a; } .. b .. c;
    };
    println!("syn: {}", quote::ToTokens::to_token_stream(&input));
    print!("prettyplease: {}", prettyplease::unparse(&input));
}
syn: const _ : _ = | | { a ; } .. b .. c ;
prettyplease: const _: _ = || (
    {
        a;
    }..b
)..c;

Due to ridiculous bailout rules, the ..c in the input is outside the closure body. In the output printed by prettyplease, the ..c winds up inside the closure body.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant