@@ -592,8 +592,6 @@ struct CTypesVisitorState<'tcx> {
592
592
/// The original type being checked, before we recursed
593
593
/// to any other types it contains.
594
594
base_ty : Ty < ' tcx > ,
595
- /// Number of times we recursed while checking the type
596
- recursion_depth : usize ,
597
595
}
598
596
599
597
enum FfiResult < ' tcx > {
@@ -899,23 +897,12 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
899
897
900
898
// Protect against infinite recursion, for example
901
899
// `struct S(*mut S);`.
900
+ // FIXME: A recursion limit is necessary as well, for irregular
901
+ // recursive types.
902
902
if !acc. cache . insert ( ty) {
903
903
return FfiSafe ;
904
904
}
905
905
906
- // Additional recursion check for more complex types like
907
- // `struct A<T> { v: *const A<A<T>>, ... }` for which the
908
- // cache check above won't be enough (fixes #130310)
909
- if !tcx. recursion_limit ( ) . value_within_limit ( acc. recursion_depth ) {
910
- return FfiUnsafe {
911
- ty : acc. base_ty ,
912
- reason : fluent:: lint_improper_ctypes_recursion_limit_reached,
913
- help : None ,
914
- } ;
915
- }
916
-
917
- acc. recursion_depth += 1 ;
918
-
919
906
match * ty. kind ( ) {
920
907
ty:: Adt ( def, args) => {
921
908
if let Some ( boxed) = ty. boxed_ty ( )
@@ -1261,8 +1248,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
1261
1248
return ;
1262
1249
}
1263
1250
1264
- let mut acc =
1265
- CTypesVisitorState { cache : FxHashSet :: default ( ) , base_ty : ty, recursion_depth : 0 } ;
1251
+ let mut acc = CTypesVisitorState { cache : FxHashSet :: default ( ) , base_ty : ty } ;
1266
1252
match self . check_type_for_ffi ( & mut acc, ty) {
1267
1253
FfiResult :: FfiSafe => { }
1268
1254
FfiResult :: FfiPhantom ( ty) => {
0 commit comments