Skip to content

Commit 130bda9

Browse files
committed
add support for walking function pointer types
1 parent a2e99a5 commit 130bda9

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

c2rust-analyze/src/main.rs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -295,18 +295,27 @@ where
295295
}
296296
}
297297

298-
if let TyKind::Adt(adt_def, _) = ty.kind() {
299-
if !f(adt_def.did()) {
300-
return;
301-
}
302-
for field in adt_def.all_fields() {
303-
let field_ty = tcx.type_of(field.did);
304-
for arg in field_ty.walk() {
305-
if let GenericArgKind::Type(ty) = arg.unpack() {
306-
walk_args_and_fields(tcx, ty, f)
298+
match ty.kind() {
299+
TyKind::Adt(adt_def, _) => {
300+
if !f(adt_def.did()) {
301+
return;
302+
}
303+
for field in adt_def.all_fields() {
304+
let field_ty = tcx.type_of(field.did);
305+
for arg in field_ty.walk() {
306+
if let GenericArgKind::Type(ty) = arg.unpack() {
307+
walk_args_and_fields(tcx, ty, f)
308+
}
307309
}
308310
}
309311
}
312+
TyKind::FnPtr(sig) => {
313+
let sig = tcx.erase_late_bound_regions(*sig);
314+
for ty in sig.inputs_and_output {
315+
walk_args_and_fields(tcx, ty, f)
316+
}
317+
}
318+
_ => (),
310319
}
311320
}
312321

0 commit comments

Comments
 (0)