-
Notifications
You must be signed in to change notification settings - Fork 1k
Prevent duplicating comments and tokens when rewriting trait headers #6834
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
base: main
Are you sure you want to change the base?
Changes from all commits
46a7452
c2cfb41
2a42154
6b3dcf4
0634576
3394929
af27f2c
b46276f
59105d2
e22cd2b
df00702
f0db1f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| pub // should the following be private? | ||
| trait Asso<'ciativity> {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,9 +102,36 @@ trait FooBar = Foo | |
|
|
||
| // #2637 | ||
| auto trait Example {} | ||
|
|
||
| auto /* post auto comment */ trait AutoExampleWithComments {} | ||
|
|
||
| pub auto trait PubExample {} | ||
|
|
||
| pub /* post pub comment */ auto /* post auto comment */ trait PubAutoExampleWithComments {} | ||
|
|
||
| pub unsafe auto trait PubUnsafeExample {} | ||
|
|
||
| pub // post pub comment | ||
| unsafe | ||
| /* post unsafe comment */ | ||
| auto /* post auto comment */ trait PubUnsafeAutoExampleWithComments {} | ||
|
|
||
| pub // post pub comment | ||
| const /* post const comment */ | ||
| unsafe | ||
| /* post unsafe comment */ | ||
| auto /* post auto comment */ trait PubConstUnsafeAutoExampleWithComments {} | ||
|
|
||
| pub /* first */ trait /* second */ MyTrait /* third */ {} | ||
|
|
||
|
Comment on lines
+125
to
+126
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please also add a test for something like this: pub
/* a */
trait
/* b */
Foo
/* c */
{}Just to ensure that we don't accidentally format the comments (aligning them etc?).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done!
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I think after my own testing and looking at the original issue, it looks like trait /* a */ X {}which gets reformatted to trait X /* a */ X {}but in here, it gets re-aligned (thus formatted): trait
/* b */
FooMy recollection of the discussion at #5847 (comment) is that we don't want to introduce comment formatting for now. I'm obviously for us being bold and all, and I disagree with postponing these things because I doubt it will get done in a reasonable time. I also don't think rustfmt breakages should be done using "editions", it should just be through a normal upgrade process (remind me some months later to look into whether rustup can pin rustfmt versions, whether via But I just wanted to let you know in case you wanted to be consistent with the original decision (which applied here would require you to preserve the original comment formatting), and note that Otherwise, feel free to r=me. |
||
| pub | ||
| /* a */ | ||
| trait | ||
| /* b */ | ||
| Foo | ||
| /* c */ | ||
| {} | ||
|
|
||
| // #3006 | ||
| trait Foo<'a> { | ||
| type Bar< 'a >; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| pub // should the following be private? | ||
| trait Asso<'ciativity> | ||
| { | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| pub/* (crate) */ trait MyTrait {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future I might want to make the headers mechanism to also do this part of the job too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was hoping to add the
generics_strcode to theHeaderPartvec as well to simplify things, but becauseformat_headeralways usesshape.infinite_width()generic's weren't getting properly wrapped.Maybe updating
HeaderPartto something like this in the future is something we could consider:Then we could modify
format_headerto dynamically compute anyHeaderPartKind::Computedheader parts with an appropriate shape offset.