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

Comment in trait visibility position causes token duplication #6160

Open
miraclx opened this issue May 6, 2024 · 2 comments
Open

Comment in trait visibility position causes token duplication #6160

miraclx opened this issue May 6, 2024 · 2 comments
Labels
a-comments bug Panic, non-idempotency, invalid code, etc.

Comments

@miraclx
Copy link

miraclx commented May 6, 2024

Just noticed some weird behaviour, not sure if it's been reported already, I tried searching but I'm not sure how to classify it

this:

pub/* (crate) */ trait MyTrait {}

gets reformatted as:

pub trait MyTrait /* (crate) */ trait MyTrait {}

Test:

$ rustfmt <<< 'pub/* (crate) */ trait MyTrait {}'
pub trait MyTrait /* (crate) */ trait MyTrait {}

Worth noting, I didn't observe this behavior with structs, enums, unions and expanding the comment's scope to include the pub, it behaves correctly with this:

/* pub (crate) */ trait MyTrait {}

getting reformatted to:

/* pub (crate) */
trait MyTrait {}
@miraclx miraclx changed the title Comment in trait visibility position duplicates the entire trait Comment in trait visibility position causes token duplication May 6, 2024
@miraclx
Copy link
Author

miraclx commented May 6, 2024

Ah, this is similar enough to - #5841

@ytmimi
Copy link
Contributor

ytmimi commented May 6, 2024

@miraclx thanks for looking into this and finding #5841

@ytmimi ytmimi added bug Panic, non-idempotency, invalid code, etc. a-comments labels May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-comments bug Panic, non-idempotency, invalid code, etc.
Projects
None yet
Development

No branches or pull requests

2 participants