1
Fork 0

Remove unused fields in some structures

The dead_code lint was previously eroneously missing those.
Since this lint bug has been fixed, the unused fields need
to be removed.
This commit is contained in:
Arthur Carcano 2024-01-03 17:45:41 +01:00
parent a0fe4138ed
commit ccd99b384e
10 changed files with 16 additions and 34 deletions

View file

@ -52,7 +52,7 @@ fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>
let (ident, vdata, fields) = match substr.fields {
Struct(vdata, fields) => (substr.type_ident, *vdata, fields),
EnumMatching(_, _, v, fields) => (v.ident, &v.data, fields),
EnumMatching(_, v, fields) => (v.ident, &v.data, fields),
AllFieldlessEnum(enum_def) => return show_fieldless_enum(cx, span, enum_def, substr),
EnumTag(..) | StaticStruct(..) | StaticEnum(..) => {
cx.dcx().span_bug(span, "nonsensical .fields in `#[derive(Debug)]`")

View file

@ -226,7 +226,7 @@ fn encodable_substructure(
BlockOrExpr::new_expr(expr)
}
EnumMatching(idx, _, variant, fields) => {
EnumMatching(idx, variant, fields) => {
// We're not generating an AST that the borrow checker is expecting,
// so we need to generate a unique local variable to take the
// mutable loan out on, otherwise we get conflicts which don't

View file

@ -310,10 +310,10 @@ pub enum SubstructureFields<'a> {
/// variants has any fields).
AllFieldlessEnum(&'a ast::EnumDef),
/// Matching variants of the enum: variant index, variant count, ast::Variant,
/// Matching variants of the enum: variant index, ast::Variant,
/// fields: the field name is only non-`None` in the case of a struct
/// variant.
EnumMatching(usize, usize, &'a ast::Variant, Vec<FieldInfo>),
EnumMatching(usize, &'a ast::Variant, Vec<FieldInfo>),
/// The tag of an enum. The first field is a `FieldInfo` for the tags, as
/// if they were fields. The second field is the expression to combine the
@ -1272,7 +1272,7 @@ impl<'a> MethodDef<'a> {
trait_,
type_ident,
nonselflike_args,
&EnumMatching(0, 1, &variants[0], Vec::new()),
&EnumMatching(0, &variants[0], Vec::new()),
);
}
}
@ -1318,7 +1318,7 @@ impl<'a> MethodDef<'a> {
// expressions for referencing every field of every
// Self arg, assuming all are instances of VariantK.
// Build up code associated with such a case.
let substructure = EnumMatching(index, variants.len(), variant, fields);
let substructure = EnumMatching(index, variant, fields);
let arm_expr = self
.call_substructure_method(
cx,
@ -1346,7 +1346,7 @@ impl<'a> MethodDef<'a> {
trait_,
type_ident,
nonselflike_args,
&EnumMatching(0, variants.len(), v, Vec::new()),
&EnumMatching(0, v, Vec::new()),
)
.into_expr(cx, span),
)