@@ -144,7 +144,10 @@ impl<'cx, 'others, 'tcx> AttrChecker<'cx, 'others, 'tcx> {
144
144
Self { cx, type_cache }
145
145
}
146
146
147
- fn has_sig_drop_attr ( & mut self , ty : Ty < ' tcx > ) -> bool {
147
+ fn has_sig_drop_attr ( & mut self , ty : Ty < ' tcx > , depth : usize ) -> bool {
148
+ if !self . cx . tcx . recursion_limit ( ) . value_within_limit ( depth) {
149
+ return false ;
150
+ }
148
151
let ty = self
149
152
. cx
150
153
. tcx
@@ -156,12 +159,12 @@ impl<'cx, 'others, 'tcx> AttrChecker<'cx, 'others, 'tcx> {
156
159
e. insert ( false ) ;
157
160
} ,
158
161
}
159
- let value = self . has_sig_drop_attr_uncached ( ty) ;
162
+ let value = self . has_sig_drop_attr_uncached ( ty, depth + 1 ) ;
160
163
self . type_cache . insert ( ty, value) ;
161
164
value
162
165
}
163
166
164
- fn has_sig_drop_attr_uncached ( & mut self , ty : Ty < ' tcx > ) -> bool {
167
+ fn has_sig_drop_attr_uncached ( & mut self , ty : Ty < ' tcx > , depth : usize ) -> bool {
165
168
if let Some ( adt) = ty. ty_adt_def ( ) {
166
169
let mut iter = get_attr (
167
170
self . cx . sess ( ) ,
@@ -176,13 +179,13 @@ impl<'cx, 'others, 'tcx> AttrChecker<'cx, 'others, 'tcx> {
176
179
rustc_middle:: ty:: Adt ( a, b) => {
177
180
for f in a. all_fields ( ) {
178
181
let ty = f. ty ( self . cx . tcx , b) ;
179
- if self . has_sig_drop_attr ( ty) {
182
+ if self . has_sig_drop_attr ( ty, depth ) {
180
183
return true ;
181
184
}
182
185
}
183
186
for generic_arg in * b {
184
187
if let GenericArgKind :: Type ( ty) = generic_arg. unpack ( )
185
- && self . has_sig_drop_attr ( ty)
188
+ && self . has_sig_drop_attr ( ty, depth )
186
189
{
187
190
return true ;
188
191
}
@@ -192,7 +195,7 @@ impl<'cx, 'others, 'tcx> AttrChecker<'cx, 'others, 'tcx> {
192
195
rustc_middle:: ty:: Array ( ty, _)
193
196
| rustc_middle:: ty:: RawPtr ( ty, _)
194
197
| rustc_middle:: ty:: Ref ( _, ty, _)
195
- | rustc_middle:: ty:: Slice ( ty) => self . has_sig_drop_attr ( * ty) ,
198
+ | rustc_middle:: ty:: Slice ( ty) => self . has_sig_drop_attr ( * ty, depth ) ,
196
199
_ => false ,
197
200
}
198
201
}
@@ -268,7 +271,7 @@ impl<'tcx> Visitor<'tcx> for StmtsChecker<'_, '_, '_, '_, 'tcx> {
268
271
apa. has_expensive_expr_after_last_attr = false ;
269
272
} ;
270
273
let mut ac = AttrChecker :: new ( self . cx , self . type_cache ) ;
271
- if ac. has_sig_drop_attr ( self . cx . typeck_results ( ) . expr_ty ( expr) ) {
274
+ if ac. has_sig_drop_attr ( self . cx . typeck_results ( ) . expr_ty ( expr) , 0 ) {
272
275
if let hir:: StmtKind :: Let ( local) = self . ap . curr_stmt . kind
273
276
&& let hir:: PatKind :: Binding ( _, hir_id, ident, _) = local. pat . kind
274
277
&& !self . ap . apas . contains_key ( & hir_id)
0 commit comments