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

Projections of nested tuple structs turn into syntax errors #1063

Closed
sorear opened this issue Jun 12, 2016 · 4 comments
Closed

Projections of nested tuple structs turn into syntax errors #1063

sorear opened this issue Jun 12, 2016 · 4 comments
Labels
bug Panic, non-idempotency, invalid code, etc.

Comments

@sorear
Copy link

sorear commented Jun 12, 2016

Start with this valid code (playpen: https://is.gd/rPUytX):

fn main() {
    let x = ((1u8, 2), 3);
    println!("{}", x.0 .0);
}

Click "format"; rustfmt will delete the space in .0 .0, but .0.0 is a syntax error because the lexer interprets 0.0 as a float literal.

@marcusklaas marcusklaas added the bug Panic, non-idempotency, invalid code, etc. label Jun 13, 2016
@marcusklaas
Copy link
Contributor

Hmmm.. not sure how we should format this. Perhaps the best solution is just to force a multi-line format when two consecutive tuple accesses are detected.

@sorear
Copy link
Author

sorear commented Jun 13, 2016

My preference would be to inject a single space as in the example above, although I have no idea how difficult that'd be. Requiring a newline seems weird, given that it'd make extremely short lines.

@srinivasreddy
Copy link
Contributor

I would prefer this way though,

fn main() {
    let x = ((1u8, 2), 3);
    println!("{}", (x.0).0);
}

@sorear
Copy link
Author

sorear commented Jun 15, 2016

@srinivasreddy That's what I wound up doing to make the present rustfmt accept my code, and I'd be 100% OK with rustfmt generating that if it's as easy or easier than my proposal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Panic, non-idempotency, invalid code, etc.
Projects
None yet
Development

No branches or pull requests

3 participants