rust/tests/source/issue-5270/merge_derives_true.rs
Yacin Tmimi 8984438a6f 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.
2022-03-21 16:56:34 -05:00

63 lines
1.1 KiB
Rust

// 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,
}
}