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

Left behind trailing whitespace on complicated generics #5125

Closed
Rantanen opened this issue Dec 4, 2021 · 0 comments · Fixed by #5129
Closed

Left behind trailing whitespace on complicated generics #5125

Rantanen opened this issue Dec 4, 2021 · 0 comments · Fixed by #5129
Labels
bug Panic, non-idempotency, invalid code, etc. help wanted

Comments

@Rantanen
Copy link
Contributor

Rantanen commented Dec 4, 2021

The following code yields "error[internal]: left behind trailing whitespace" error on rustfmt:

fn foo(
    a: <u16 as intercom::type_system::ExternType<
        intercom::type_system::AutomationTypeSystem,
    >>::ForeignType,
) {}

(Playground)

As far as I know, this has worked in the past, but has regressed somewhere within this year (unfortunately can't pinpoint the timeframe more accurately than that). Also I believe rustfmt does manage to format that properly, but adds an extra newline before the parameter.

From what I can tell, the output from rustfmt is:

fn foo(
    
    a: <u16 as intercom::type_system::ExternType<
        intercom::type_system::AutomationTypeSystem,
    >>::ForeignType,
) {}

(The second line has indent, but no other content.)

Unfortunately the lines are output from a proc macro and end up as top-level functions in the module. I'm using full mod paths to avoid polluting the caller scope by introducing elements with use statements. Although in my case I'm using rustfmt just to get nicer test output for macro expansion tests so it's not like this is breaking crate usage, just tests.

Meta

  • rustfmt version: rustfmt 1.4.38-nightly (532d2b1 2021-12-03) and whatever playground has.
  • Running with: cargo fmt or playground
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. help wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants