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

Const generic parameter following a comment gets corrupted #4263

Closed
yvt opened this issue Jun 19, 2020 · 3 comments · Fixed by #4294
Closed

Const generic parameter following a comment gets corrupted #4263

yvt opened this issue Jun 19, 2020 · 3 comments · Fixed by #4294
Labels
1x-backport:completed bug Panic, non-idempotency, invalid code, etc.
Milestone

Comments

@yvt
Copy link

yvt commented Jun 19, 2020

fn func_name<
    // AAAA
    const BBBB: usize,
    /* CCCC */
    const DDDD: usize,
>() {}

Playground Link

Output:

fn func_name<
    // AAAA
    const
    const BBBB: usize,
    /* CCCC */
    const
    const DDDD: usize,
>() {
}

Version: 1.4.15-nightly (2020-05-19 aedff61)

@ayazhafiz
Copy link
Contributor

We will need to update the rust AST to get the span of the const kw so the span of the generic param can be determined correctly.

@topecongiro topecongiro added the blocked Blocked on rustc, an RFC, etc. label Jun 23, 2020
@topecongiro
Copy link
Contributor

Yes, it sounds like a good idea to update the AST.

ayazhafiz added a commit to ayazhafiz/rust that referenced this issue Jun 23, 2020
Context: this is needed to fix rust-lang/rustfmt#4263,
which currently records the span of a const generic param incorrectly
because the location of the `const` kw is not known.

I am not sure how to add tests for this; any guidance in how to do so
would be appreciated 🙂
Manishearth added a commit to Manishearth/rust that referenced this issue Jun 24, 2020
…morse

Record span of `const` kw in GenericParamKind

Context: this is needed for a fix of rust-lang/rustfmt#4263,
which currently records the span of a const generic param incorrectly
because the location of the `const` kw is not known.

I am not sure how to add tests for this; any guidance in how to do so
would be appreciated 🙂
Manishearth added a commit to Manishearth/rust that referenced this issue Jun 26, 2020
…morse

Record span of `const` kw in GenericParamKind

Context: this is needed for a fix of rust-lang/rustfmt#4263,
which currently records the span of a const generic param incorrectly
because the location of the `const` kw is not known.

I am not sure how to add tests for this; any guidance in how to do so
would be appreciated 🙂
Manishearth added a commit to Manishearth/rust that referenced this issue Jun 26, 2020
…morse

Record span of `const` kw in GenericParamKind

Context: this is needed for a fix of rust-lang/rustfmt#4263,
which currently records the span of a const generic param incorrectly
because the location of the `const` kw is not known.

I am not sure how to add tests for this; any guidance in how to do so
would be appreciated 🙂
flip1995 pushed a commit to flip1995/rust-clippy that referenced this issue Jun 28, 2020
Context: this is needed to fix rust-lang/rustfmt#4263,
which currently records the span of a const generic param incorrectly
because the location of the `const` kw is not known.

I am not sure how to add tests for this; any guidance in how to do so
would be appreciated 🙂
flip1995 pushed a commit to flip1995/rust-clippy that referenced this issue Jun 28, 2020
Record span of `const` kw in GenericParamKind

Context: this is needed for a fix of rust-lang/rustfmt#4263,
which currently records the span of a const generic param incorrectly
because the location of the `const` kw is not known.

I am not sure how to add tests for this; any guidance in how to do so
would be appreciated 🙂
@topecongiro topecongiro added this to the 2.0.1 milestone Jun 29, 2020
@topecongiro topecongiro removed the blocked Blocked on rustc, an RFC, etc. label Jun 30, 2020
@topecongiro
Copy link
Contributor

667.0.0, which includes rust-lang/rust#73597, is released.

JohnTitor added a commit to JohnTitor/rust that referenced this issue Jan 30, 2021
…anxiyn

update rustfmt to v1.4.34

Short summary: Various formatting fixes (several const generic related) and introduction of `imports_granularity` config option

Long summary copied from changelog:

#### Changed
- `merge_imports` configuration has been deprecated in favor of the new `imports_granularity` option. Any existing usage of `merge_imports` will be automatically mapped to the corresponding value on `imports_granularity` with a warning message printed to encourage users to update their config files.

#### Added
- New `imports_granularity` option has been added which succeeds `merge_imports`. This new option supports several additional variants which allow users to merge imports at different levels (crate or module), and even flatten imports to have a single use statement per item. ([PR rust-lang/rustfmt#4634](rust-lang/rustfmt#4634), [PR rust-lang/rustfmt#4639](rust-lang/rustfmt#4639))

See the section on the configuration site for more information
https://rust-lang.github.io/rustfmt/?version=v1.4.33&search=#imports_granularity

#### Fixed
- Fix erroneous removal of `const` keyword on const trait impl ([rust-lang/rustfmt#4084](rust-lang/rustfmt#4084))
- Fix incorrect span usage wit const generics in supertraits ([rust-lang/rustfmt#4204](rust-lang/rustfmt#4204))
- Use correct span for const generic params ([rust-lang/rustfmt#4263](rust-lang/rustfmt#4263))
- Correct span on const generics to include type bounds ([rust-lang/rustfmt#4310](rust-lang/rustfmt#4310))
- Idempotence issue on blocks containing only empty statements ([rust-lang/rustfmt#4627](rust-lang/rustfmt#4627) and [rust-lang#3868](rust-lang/rustfmt#3868))
- Fix issue with semicolon placement on required functions that have a trailing comment that ends in a line-style comment before the semicolon ([rust-lang/rustfmt#4646](rust-lang/rustfmt#4646))
- Avoid shared interned cfg_if symbol since rustfmt can re-initialize the rustc_ast globals on multiple inputs ([rust-lang/rustfmt#4656](rust-lang/rustfmt#4656))
- Don't insert trailing comma on (base-less) rest in struct literals within macros ([rust-lang/rustfmt#4675](rust-lang/rustfmt#4675))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1x-backport:completed bug Panic, non-idempotency, invalid code, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants