Skip to content

Commit ee013d8

Browse files
committed
Avoid some unnecessary local attr variables.
1 parent 5b0324f commit ee013d8

File tree

7 files changed

+11
-19
lines changed

7 files changed

+11
-19
lines changed

compiler/rustc_builtin_macros/src/deriving/clone.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ pub fn expand_deriving_clone(
6868
_ => cx.span_bug(span, "`#[derive(Clone)]` on trait item or impl item"),
6969
}
7070

71-
let attrs = thin_vec![cx.attr_word(sym::inline, span)];
7271
let trait_def = TraitDef {
7372
span,
7473
path: path_std!(clone::Clone),
@@ -82,7 +81,7 @@ pub fn expand_deriving_clone(
8281
explicit_self: true,
8382
nonself_args: Vec::new(),
8483
ret_ty: Self_,
85-
attributes: attrs,
84+
attributes: thin_vec![cx.attr_word(sym::inline, span)],
8685
fieldless_variants_strategy: FieldlessVariantsStrategy::Default,
8786
combine_substructure: substructure,
8887
}],

compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ pub fn expand_deriving_eq(
1818
is_const: bool,
1919
) {
2020
let span = cx.with_def_site_ctxt(span);
21-
let attrs = thin_vec![
22-
cx.attr_word(sym::inline, span),
23-
cx.attr_nested_word(sym::doc, sym::hidden, span),
24-
cx.attr_word(sym::no_coverage, span)
25-
];
2621
let trait_def = TraitDef {
2722
span,
2823
path: path_std!(cmp::Eq),
@@ -36,7 +31,11 @@ pub fn expand_deriving_eq(
3631
explicit_self: true,
3732
nonself_args: vec![],
3833
ret_ty: Unit,
39-
attributes: attrs,
34+
attributes: thin_vec![
35+
cx.attr_word(sym::inline, span),
36+
cx.attr_nested_word(sym::doc, sym::hidden, span),
37+
cx.attr_word(sym::no_coverage, span)
38+
],
4039
fieldless_variants_strategy: FieldlessVariantsStrategy::Unify,
4140
combine_substructure: combine_substructure(Box::new(|a, b, c| {
4241
cs_total_eq_assert(a, b, c)

compiler/rustc_builtin_macros/src/deriving/cmp/ord.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ pub fn expand_deriving_ord(
1515
push: &mut dyn FnMut(Annotatable),
1616
is_const: bool,
1717
) {
18-
let attrs = thin_vec![cx.attr_word(sym::inline, span)];
1918
let trait_def = TraitDef {
2019
span,
2120
path: path_std!(cmp::Ord),
@@ -29,7 +28,7 @@ pub fn expand_deriving_ord(
2928
explicit_self: true,
3029
nonself_args: vec![(self_ref(), sym::other)],
3130
ret_ty: Path(path_std!(cmp::Ordering)),
32-
attributes: attrs,
31+
attributes: thin_vec![cx.attr_word(sym::inline, span)],
3332
fieldless_variants_strategy: FieldlessVariantsStrategy::Unify,
3433
combine_substructure: combine_substructure(Box::new(|a, b, c| cs_cmp(a, b, c))),
3534
}],

compiler/rustc_builtin_macros/src/deriving/cmp/partial_eq.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,13 @@ pub fn expand_deriving_partial_eq(
8282

8383
// No need to generate `ne`, the default suffices, and not generating it is
8484
// faster.
85-
let attrs = thin_vec![cx.attr_word(sym::inline, span)];
8685
let methods = vec![MethodDef {
8786
name: sym::eq,
8887
generics: Bounds::empty(),
8988
explicit_self: true,
9089
nonself_args: vec![(self_ref(), sym::other)],
9190
ret_ty: Path(path_local!(bool)),
92-
attributes: attrs,
91+
attributes: thin_vec![cx.attr_word(sym::inline, span)],
9392
fieldless_variants_strategy: FieldlessVariantsStrategy::Unify,
9493
combine_substructure: combine_substructure(Box::new(|a, b, c| cs_eq(a, b, c))),
9594
}];

compiler/rustc_builtin_macros/src/deriving/cmp/partial_ord.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ pub fn expand_deriving_partial_ord(
1919
let ret_ty =
2020
Path(Path::new_(pathvec_std!(option::Option), vec![Box::new(ordering_ty)], PathKind::Std));
2121

22-
let attrs = thin_vec![cx.attr_word(sym::inline, span)];
23-
2422
// Order in which to perform matching
2523
let tag_then_data = if let Annotatable::Item(item) = item
2624
&& let ItemKind::Enum(def, _) = &item.kind {
@@ -48,7 +46,7 @@ pub fn expand_deriving_partial_ord(
4846
explicit_self: true,
4947
nonself_args: vec![(self_ref(), sym::other)],
5048
ret_ty,
51-
attributes: attrs,
49+
attributes: thin_vec![cx.attr_word(sym::inline, span)],
5250
fieldless_variants_strategy: FieldlessVariantsStrategy::Unify,
5351
combine_substructure: combine_substructure(Box::new(|cx, span, substr| {
5452
cs_partial_cmp(cx, span, substr, tag_then_data)

compiler/rustc_builtin_macros/src/deriving/default.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ pub fn expand_deriving_default(
2020
) {
2121
item.visit_with(&mut DetectNonVariantDefaultAttr { cx });
2222

23-
let attrs = thin_vec![cx.attr_word(sym::inline, span)];
2423
let trait_def = TraitDef {
2524
span,
2625
path: Path::new(vec![kw::Default, sym::Default]),
@@ -34,7 +33,7 @@ pub fn expand_deriving_default(
3433
explicit_self: false,
3534
nonself_args: Vec::new(),
3635
ret_ty: Self_,
37-
attributes: attrs,
36+
attributes: thin_vec![cx.attr_word(sym::inline, span)],
3837
fieldless_variants_strategy: FieldlessVariantsStrategy::Default,
3938
combine_substructure: combine_substructure(Box::new(|cx, trait_span, substr| {
4039
match substr.fields {

compiler/rustc_builtin_macros/src/deriving/hash.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ pub fn expand_deriving_hash(
2020
let typaram = sym::__H;
2121

2222
let arg = Path::new_local(typaram);
23-
let attrs = thin_vec![cx.attr_word(sym::inline, span)];
2423
let hash_trait_def = TraitDef {
2524
span,
2625
path,
@@ -34,7 +33,7 @@ pub fn expand_deriving_hash(
3433
explicit_self: true,
3534
nonself_args: vec![(Ref(Box::new(Path(arg)), Mutability::Mut), sym::state)],
3635
ret_ty: Unit,
37-
attributes: attrs,
36+
attributes: thin_vec![cx.attr_word(sym::inline, span)],
3837
fieldless_variants_strategy: FieldlessVariantsStrategy::Unify,
3938
combine_substructure: combine_substructure(Box::new(|a, b, c| {
4039
hash_substructure(a, b, c)

0 commit comments

Comments
 (0)