Skip to content

Commit 27571da

Browse files
committed
Remove FieldInfo::attrs.
It's unused. This also removes the need for the lifetime on `FieldInfo`, which is nice.
1 parent d3057b5 commit 27571da

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

compiler/rustc_builtin_macros/src/deriving/clone.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ fn cs_clone(
160160
let ctor_path;
161161
let all_fields;
162162
let fn_path = cx.std_path(&[sym::clone, sym::Clone, sym::clone]);
163-
let subcall = |cx: &mut ExtCtxt<'_>, field: &FieldInfo<'_>| {
163+
let subcall = |cx: &mut ExtCtxt<'_>, field: &FieldInfo| {
164164
let args = vec![cx.expr_addr_of(field.span, field.self_expr.clone())];
165165
cx.expr_call_global(field.span, fn_path.clone(), args)
166166
};

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ pub struct Substructure<'a> {
251251
}
252252

253253
/// Summary of the relevant parts of a struct/enum field.
254-
pub struct FieldInfo<'a> {
254+
pub struct FieldInfo {
255255
pub span: Span,
256256
/// None for tuple structs/normal enum variants, Some for normal
257257
/// structs/struct enum variants.
@@ -262,8 +262,6 @@ pub struct FieldInfo<'a> {
262262
/// The expressions corresponding to references to this field in
263263
/// the other selflike arguments.
264264
pub other_selflike_exprs: Vec<P<Expr>>,
265-
/// The attributes on the field
266-
pub attrs: &'a [ast::Attribute],
267265
}
268266

269267
/// Fields for a static method
@@ -276,11 +274,11 @@ pub enum StaticFields {
276274

277275
/// A summary of the possible sets of fields.
278276
pub enum SubstructureFields<'a> {
279-
Struct(&'a ast::VariantData, Vec<FieldInfo<'a>>),
277+
Struct(&'a ast::VariantData, Vec<FieldInfo>),
280278
/// Matching variants of the enum: variant index, variant count, ast::Variant,
281279
/// fields: the field name is only non-`None` in the case of a struct
282280
/// variant.
283-
EnumMatching(usize, usize, &'a ast::Variant, Vec<FieldInfo<'a>>),
281+
EnumMatching(usize, usize, &'a ast::Variant, Vec<FieldInfo>),
284282

285283
/// Non-matching variants of the enum, but with all state hidden from the
286284
/// consequent code. The field is a list of `Ident`s bound to the variant
@@ -1082,18 +1080,17 @@ impl<'a> MethodDef<'a> {
10821080
let first_field = raw_fields.next().unwrap();
10831081
let mut nonself_fields: Vec<vec::IntoIter<_>> = raw_fields.collect();
10841082
first_field
1085-
.map(|(span, opt_id, expr, attrs)| FieldInfo {
1083+
.map(|(span, opt_id, expr)| FieldInfo {
10861084
span: span.with_ctxt(trait_.span.ctxt()),
10871085
name: opt_id,
10881086
self_expr: expr,
10891087
other_selflike_exprs: nonself_fields
10901088
.iter_mut()
10911089
.map(|l| {
1092-
let (.., ex, _) = l.next().unwrap();
1090+
let (_, _, ex) = l.next().unwrap();
10931091
ex
10941092
})
10951093
.collect(),
1096-
attrs,
10971094
})
10981095
.collect()
10991096
} else {
@@ -1282,7 +1279,7 @@ impl<'a> MethodDef<'a> {
12821279
.into_iter()
12831280
.enumerate()
12841281
// For each arg field of self, pull out its getter expr ...
1285-
.map(|(field_index, (span, opt_ident, self_getter_expr, attrs))| {
1282+
.map(|(field_index, (span, opt_ident, self_getter_expr))| {
12861283
// ... but FieldInfo also wants getter expr
12871284
// for matching other arguments of Self type;
12881285
// so walk across the *other* selflike_pats_idents
@@ -1292,7 +1289,7 @@ impl<'a> MethodDef<'a> {
12921289
let other_selflike_exprs = selflike_pats_idents
12931290
.iter()
12941291
.map(|fields| {
1295-
let (_, _opt_ident, ref other_getter_expr, _) = fields[field_index];
1292+
let (_, _opt_ident, ref other_getter_expr) = fields[field_index];
12961293

12971294
// All Self args have same variant, so
12981295
// opt_idents are the same. (Assert
@@ -1309,10 +1306,9 @@ impl<'a> MethodDef<'a> {
13091306
name: opt_ident,
13101307
self_expr: self_getter_expr,
13111308
other_selflike_exprs,
1312-
attrs,
13131309
}
13141310
})
1315-
.collect::<Vec<FieldInfo<'_>>>();
1311+
.collect::<Vec<FieldInfo>>();
13161312

13171313
// Now, for some given VariantK, we have built up
13181314
// expressions for referencing every field of every
@@ -1598,7 +1594,7 @@ impl<'a> TraitDef<'a> {
15981594
prefix: &str,
15991595
mutbl: ast::Mutability,
16001596
use_temporaries: bool,
1601-
) -> (P<ast::Pat>, Vec<(Span, Option<Ident>, P<Expr>, &'a [ast::Attribute])>) {
1597+
) -> (P<ast::Pat>, Vec<(Span, Option<Ident>, P<Expr>)>) {
16021598
let mut paths = Vec::new();
16031599
let mut ident_exprs = Vec::new();
16041600
for (i, struct_field) in struct_def.fields().iter().enumerate() {
@@ -1607,7 +1603,7 @@ impl<'a> TraitDef<'a> {
16071603
paths.push(ident.with_span_pos(sp));
16081604
let val = cx.expr_path(cx.path_ident(sp, ident));
16091605
let val = if use_temporaries { val } else { cx.expr_deref(sp, val) };
1610-
ident_exprs.push((sp, struct_field.ident, val, &struct_field.attrs[..]));
1606+
ident_exprs.push((sp, struct_field.ident, val));
16111607
}
16121608

16131609
let subpats = self.create_subpatterns(cx, paths, mutbl, use_temporaries);
@@ -1643,7 +1639,7 @@ impl<'a> TraitDef<'a> {
16431639
cx: &mut ExtCtxt<'_>,
16441640
mut selflike_arg: &P<Expr>,
16451641
struct_def: &'a VariantData,
1646-
) -> Vec<(Span, Option<Ident>, P<Expr>, &'a [ast::Attribute])> {
1642+
) -> Vec<(Span, Option<Ident>, P<Expr>)> {
16471643
let mut ident_exprs = Vec::new();
16481644
for (i, struct_field) in struct_def.fields().iter().enumerate() {
16491645
let sp = struct_field.span.with_ctxt(self.span.ctxt());
@@ -1666,7 +1662,7 @@ impl<'a> TraitDef<'a> {
16661662
}),
16671663
),
16681664
);
1669-
ident_exprs.push((sp, struct_field.ident, val, &struct_field.attrs[..]));
1665+
ident_exprs.push((sp, struct_field.ident, val));
16701666
}
16711667
ident_exprs
16721668
}
@@ -1678,7 +1674,7 @@ impl<'a> TraitDef<'a> {
16781674
variant: &'a ast::Variant,
16791675
prefix: &str,
16801676
mutbl: ast::Mutability,
1681-
) -> (P<ast::Pat>, Vec<(Span, Option<Ident>, P<Expr>, &'a [ast::Attribute])>) {
1677+
) -> (P<ast::Pat>, Vec<(Span, Option<Ident>, P<Expr>)>) {
16821678
let sp = variant.span.with_ctxt(self.span.ctxt());
16831679
let variant_path = cx.path(sp, vec![enum_ident, variant.ident]);
16841680
let use_temporaries = false; // enums can't be repr(packed)

0 commit comments

Comments
 (0)