Skip to content

Commit

Permalink
add support for walking function pointer types
Browse files Browse the repository at this point in the history
  • Loading branch information
aneksteind committed Jun 16, 2023
1 parent a2e99a5 commit 130bda9
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions c2rust-analyze/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,18 +295,27 @@ where
}
}

if let TyKind::Adt(adt_def, _) = ty.kind() {
if !f(adt_def.did()) {
return;
}
for field in adt_def.all_fields() {
let field_ty = tcx.type_of(field.did);
for arg in field_ty.walk() {
if let GenericArgKind::Type(ty) = arg.unpack() {
walk_args_and_fields(tcx, ty, f)
match ty.kind() {
TyKind::Adt(adt_def, _) => {
if !f(adt_def.did()) {
return;
}
for field in adt_def.all_fields() {
let field_ty = tcx.type_of(field.did);
for arg in field_ty.walk() {
if let GenericArgKind::Type(ty) = arg.unpack() {
walk_args_and_fields(tcx, ty, f)
}
}
}
}
TyKind::FnPtr(sig) => {
let sig = tcx.erase_late_bound_regions(*sig);
for ty in sig.inputs_and_output {
walk_args_and_fields(tcx, ty, f)
}
}
_ => (),
}
}

Expand Down

0 comments on commit 130bda9

Please sign in to comment.