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

--pretty=expanded is too conservative on parens #20937

Closed
nagisa opened this issue Jan 11, 2015 · 2 comments
Closed

--pretty=expanded is too conservative on parens #20937

nagisa opened this issue Jan 11, 2015 · 2 comments
Labels
A-pretty Area: Pretty printing (including `-Z unpretty`)

Comments

@nagisa
Copy link
Member

nagisa commented Jan 11, 2015

It outputs uncompilable code

((y & CONT_MASK) as u32 << 6)

whereas it should output

(((y & CONT_MASK) as u32) << 6)
@steveklabnik
Copy link
Member

So, I'm not sure what the original code was supposed to be here.

fn main() {
    y & CONT_MASK as u32 << 6;
}

itself fails to compile:

$ rustc --pretty=expanded hello.rs -Z unstable-options
hello.rs:2:29: 2:30 error: expected type, found `6`
hello.rs:2     y & CONT_MASK as u32 << 6;
                                       ^

@nagisa
Copy link
Member Author

nagisa commented Jan 4, 2016

@steveklabnik the original code was (((y & CONT_MASK) as u32) << 6) (or perhaps had more parens). It now outputs properly parenthesized code, so this can be closed.

@nagisa nagisa closed this as completed Jan 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-pretty Area: Pretty printing (including `-Z unpretty`)
Projects
None yet
Development

No branches or pull requests

3 participants