Skip to content

Commit b854368

Browse files
committed
simplify ADT walk
1 parent 0a4557d commit b854368

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

c2rust-analyze/src/main.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -306,21 +306,17 @@ fn walk_adts<'tcx, F>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, f: &mut F)
306306
where
307307
F: FnMut(DefId) -> bool,
308308
{
309-
// the first type encountered in the walk is `ty`, and the
310-
// relevant handling for that is below, so we can skip it here
311-
for arg in ty.walk().skip(1) {
309+
for arg in ty.walk() {
312310
if let GenericArgKind::Type(ty) = arg.unpack() {
313-
walk_adts(tcx, ty, f);
314-
}
315-
}
316-
317-
if let TyKind::Adt(adt_def, _) = ty.kind() {
318-
if !f(adt_def.did()) {
319-
return;
320-
}
321-
for field in adt_def.all_fields() {
322-
let field_ty = tcx.type_of(field.did);
323-
walk_adts(tcx, field_ty, f);
311+
if let TyKind::Adt(adt_def, _) = ty.kind() {
312+
if !f(adt_def.did()) {
313+
continue;
314+
}
315+
for field in adt_def.all_fields() {
316+
let field_ty = tcx.type_of(field.did);
317+
walk_adts(tcx, field_ty, f);
318+
}
319+
}
324320
}
325321
}
326322
}

0 commit comments

Comments
 (0)