Skip to content

Regression (rustc): Formatting UFCS function calls produces invalid code (needstest) #64

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

Closed
pyfisch opened this issue May 3, 2015 · 6 comments
Labels
bug Panic, non-idempotency, invalid code, etc. good first issue Issues up for grabs, also good candidates for new rustfmt contributors

Comments

@pyfisch
Copy link

pyfisch commented May 3, 2015

fn header_name<T: Header>() -> &'static str {
    let name = <T as Header>::header_name();
    name
}

is formatted to

fn header_name<T: Header>() -> &'static str {
    let name = <();
    name
}

which is clearly not intended.

@defyrlt
Copy link
Contributor

defyrlt commented May 3, 2015

I ran this through idempotent tests and got this:

fn header_name<T: Header>() -> &'static str {
    let name = <T as Header>::header_name(();
    name
}

UPD: my rustc was kinda outdated
rustc 1.1.0-nightly (5fb0259ed 2015-04-26) (built 2015-04-27)
so now with
rustc 1.1.0-nightly (c42c1e7a6 2015-05-02) (built 2015-05-02)
I'm getting the same thing

fn header_name<T: Header>() -> &'static str {
    let name = <();
    name
}

@nrc nrc changed the title Formatting produces invalid code Regression (rustc): Formatting UFCS function calls produces invalid code May 4, 2015
@nrc nrc added the bug Panic, non-idempotency, invalid code, etc. label May 4, 2015
@nrc
Copy link
Member

nrc commented May 4, 2015

Given that this is caused by a regression in rustc (by the sounds of it), I'm going to put money on this being due to an incorrect span from the parser.

@marcusklaas
Copy link
Contributor

I've opened an issue for this here: rust-lang/rust#25969.

@marcusklaas
Copy link
Contributor

The underlying issue has been resolved: rust-lang/rust#25994. I can confirm that the test case above is now formatted correctly when using the master branch of rustc.

@nrc nrc added the good first issue Issues up for grabs, also good candidates for new rustfmt contributors label Jun 5, 2015
@nrc
Copy link
Member

nrc commented Jun 5, 2015

This just needs a test now. (thanks for fixing the rustc bug @marcusklaas)

@nrc nrc changed the title Regression (rustc): Formatting UFCS function calls produces invalid code Regression (rustc): Formatting UFCS function calls produces invalid code (needstest) Jun 5, 2015
@nrc
Copy link
Member

nrc commented Jun 8, 2015

Closed by #97

@nrc nrc closed this as completed Jun 8, 2015
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. good first issue Issues up for grabs, also good candidates for new rustfmt contributors
Projects
None yet
Development

No branches or pull requests

4 participants