Skip to content

Commit

Permalink
walk_args_and_fields -> walk_adts
Browse files Browse the repository at this point in the history
  • Loading branch information
aneksteind committed Jun 16, 2023
1 parent 8e34144 commit 9d20b20
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions c2rust-analyze/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ fn foreign_mentioned_tys(tcx: TyCtxt) -> HashSet<DefId> {
_ => None,
})
{
walk_args_and_fields(tcx, ty, &mut |did| foreign_mentioned_tys.insert(did));
walk_adt(tcx, ty, &mut |did| foreign_mentioned_tys.insert(did));
}
foreign_mentioned_tys
}
Expand All @@ -302,15 +302,15 @@ fn foreign_mentioned_tys(tcx: TyCtxt) -> HashSet<DefId> {
/// of a type are finite in length.
/// We only look for ADTs rather than other FFI-crossing types because ADTs
/// are the only nominal ones, which are the ones that we may rewrite.
fn walk_args_and_fields<'tcx, F>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, f: &mut F)
fn walk_adt<'tcx, F>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, f: &mut F)
where
F: FnMut(DefId) -> bool,
{
// the first type encountered in the walk is `ty`, and the
// relevant handling for that is below, so we can skip it here
for arg in ty.walk().skip(1) {
if let GenericArgKind::Type(ty) = arg.unpack() {
walk_args_and_fields(tcx, ty, f);
walk_adt(tcx, ty, f);
}
}

Expand All @@ -320,7 +320,7 @@ where
}
for field in adt_def.all_fields() {
let field_ty = tcx.type_of(field.did);
walk_args_and_fields(tcx, field_ty, f);
walk_adt(tcx, field_ty, f);
}
}
}
Expand Down

0 comments on commit 9d20b20

Please sign in to comment.