forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Honor
#[rustfmt::skip::attributes(derive)]
attribute
Fixes 5270 Previously, rustfmt only checked the `merge_derives` configuration value to determine if it should merge_derives. This lead to derives being merged even when annotated with the `rustfmt::skip` attribute. Now, rustfmt also checks if derives are explicitly being skipped in the current context via the `rustfmt::skip` attribute.
- Loading branch information
1 parent
0dba01a
commit 8984438
Showing
4 changed files
with
189 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// rustfmt-merge_derives:true | ||
|
||
#[rustfmt::skip::attributes(derive)] | ||
#[allow(dead_code)] | ||
#[derive(StructField)] | ||
#[derive(Clone)] | ||
struct DoNotMergeDerives { | ||
field: String, | ||
} | ||
|
||
#[allow(dead_code)] | ||
#[derive(StructField)] | ||
#[rustfmt::skip::attributes(derive)] | ||
#[derive(Clone)] | ||
struct DoNotMergeDerivesSkipInMiddle { | ||
field: String, | ||
} | ||
|
||
#[allow(dead_code)] | ||
#[derive(StructField)] | ||
#[derive(Clone)] | ||
#[rustfmt::skip::attributes(derive)] | ||
struct DoNotMergeDerivesSkipAtEnd { | ||
field: String, | ||
} | ||
|
||
#[allow(dead_code)] | ||
#[derive(StructField)] | ||
#[derive(Clone)] | ||
struct MergeDerives { | ||
field: String, | ||
} | ||
|
||
mod inner_attribute_derive_skip { | ||
#![rustfmt::skip::attributes(derive)] | ||
|
||
#[allow(dead_code)] | ||
#[derive(StructField)] | ||
#[derive(Clone)] | ||
struct DoNotMergeDerives { | ||
field: String, | ||
} | ||
} | ||
|
||
#[rustfmt::skip::attributes(derive)] | ||
mod outer_attribute_derive_skip { | ||
#[allow(dead_code)] | ||
#[derive(StructField)] | ||
#[derive(Clone)] | ||
struct DoNotMergeDerives { | ||
field: String, | ||
} | ||
} | ||
|
||
mod no_derive_skip { | ||
#[allow(dead_code)] | ||
#[derive(StructField)] | ||
#[derive(Clone)] | ||
struct MergeDerives { | ||
field: String, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// rustfmt-merge_derives:false | ||
|
||
#[rustfmt::skip::attributes(derive)] | ||
#[allow(dead_code)] | ||
#[derive(StructField)] | ||
#[derive(Clone)] | ||
struct DoNotMergeDerives { | ||
field: String, | ||
} | ||
|
||
#[allow(dead_code)] | ||
#[derive(StructField)] | ||
#[rustfmt::skip::attributes(derive)] | ||
#[derive(Clone)] | ||
struct DoNotMergeDerivesSkipInMiddle { | ||
field: String, | ||
} | ||
|
||
#[allow(dead_code)] | ||
#[derive(StructField)] | ||
#[derive(Clone)] | ||
#[rustfmt::skip::attributes(derive)] | ||
struct DoNotMergeDerivesSkipAtEnd { | ||
field: String, | ||
} | ||
|
||
#[allow(dead_code)] | ||
#[derive(StructField)] | ||
#[derive(Clone)] | ||
struct MergeDerives { | ||
field: String, | ||
} | ||
|
||
mod inner_attribute_derive_skip { | ||
#![rustfmt::skip::attributes(derive)] | ||
|
||
#[allow(dead_code)] | ||
#[derive(StructField)] | ||
#[derive(Clone)] | ||
struct DoNotMergeDerives { | ||
field: String, | ||
} | ||
} | ||
|
||
#[rustfmt::skip::attributes(derive)] | ||
mod outer_attribute_derive_skip { | ||
#[allow(dead_code)] | ||
#[derive(StructField)] | ||
#[derive(Clone)] | ||
struct DoNotMergeDerives { | ||
field: String, | ||
} | ||
} | ||
|
||
mod no_derive_skip { | ||
#[allow(dead_code)] | ||
#[derive(StructField)] | ||
#[derive(Clone)] | ||
struct MergeDerives { | ||
field: String, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// rustfmt-merge_derives:true | ||
|
||
#[rustfmt::skip::attributes(derive)] | ||
#[allow(dead_code)] | ||
#[derive(StructField)] | ||
#[derive(Clone)] | ||
struct DoNotMergeDerives { | ||
field: String, | ||
} | ||
|
||
#[allow(dead_code)] | ||
#[derive(StructField)] | ||
#[rustfmt::skip::attributes(derive)] | ||
#[derive(Clone)] | ||
struct DoNotMergeDerivesSkipInMiddle { | ||
field: String, | ||
} | ||
|
||
#[allow(dead_code)] | ||
#[derive(StructField)] | ||
#[derive(Clone)] | ||
#[rustfmt::skip::attributes(derive)] | ||
struct DoNotMergeDerivesSkipAtEnd { | ||
field: String, | ||
} | ||
|
||
#[allow(dead_code)] | ||
#[derive(StructField, Clone)] | ||
struct MergeDerives { | ||
field: String, | ||
} | ||
|
||
mod inner_attribute_derive_skip { | ||
#![rustfmt::skip::attributes(derive)] | ||
|
||
#[allow(dead_code)] | ||
#[derive(StructField)] | ||
#[derive(Clone)] | ||
struct DoNotMergeDerives { | ||
field: String, | ||
} | ||
} | ||
|
||
#[rustfmt::skip::attributes(derive)] | ||
mod outer_attribute_derive_skip { | ||
#[allow(dead_code)] | ||
#[derive(StructField)] | ||
#[derive(Clone)] | ||
struct DoNotMergeDerives { | ||
field: String, | ||
} | ||
} | ||
|
||
mod no_derive_skip { | ||
#[allow(dead_code)] | ||
#[derive(StructField, Clone)] | ||
struct MergeDerives { | ||
field: String, | ||
} | ||
} |