Skip to content

destructive formatting when dealing with const generics #4310

Closed

Description

@lcnr

When formatting

#![feature(const_generics)]

fn foo<
    const N: [u8; {
        struct Inner<'a>(&'a ());
        3
    }],
>() {}

rustfmt changes the empty function argument list from () to (&'a (), which is incorrect.

#![feature(const_generics)]

fn foo<
    const N: [u8; {
        struct Inner<'a>(&'a ());
        3
    }],
>(&'a () {
}

Note that the original code snippet current does not yet compile due to the unfinished nature of const generics,
it should compile in the future though.

Activity

  1. added
    C-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICE
    on Jul 6, 2020
  2. calebcartwright commented on Jul 6, 2020

    @calebcartwright
    Member

    Thanks for the report!

    Note that the original code snippet current does not yet compile due to the unfinished nature of const generics,
    it should compile in the future though.

    This is fairly common with new/unfinished syntax, and takes a little time for rustfmt to incorporate the upstream changes. The next snapshot of the rustc internals that rustfmt consumes will be published tomorrow so we'll take a look afterwards to see if the updated ast and parser mods will allow rustfmt to be able to format this correctly.

  3. added a commit that references this issue on Jul 7, 2020
    decd13a
  4. added a commit that references this issue on Jul 7, 2020
    8e8db1f
  5. added this to the 1.4.33 milestone on Jan 24, 2021
  6. added a commit that references this issue on Jan 27, 2021
    8610454
  7. added a commit that references this issue on Jan 28, 2021
    f8deed3
  8. added a commit that references this issue on Jan 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    1x-backport:completedC-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICE

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions