@@ -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,15 @@ 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 {
168
+ if !self . cx . tcx . recursion_limit ( ) . value_within_limit ( depth) {
169
+ return false ;
170
+ }
165
171
if let Some ( adt) = ty. ty_adt_def ( ) {
166
172
let mut iter = get_attr (
167
173
self . cx . sess ( ) ,
@@ -176,13 +182,13 @@ impl<'cx, 'others, 'tcx> AttrChecker<'cx, 'others, 'tcx> {
176
182
rustc_middle:: ty:: Adt ( a, b) => {
177
183
for f in a. all_fields ( ) {
178
184
let ty = f. ty ( self . cx . tcx , b) ;
179
- if self . has_sig_drop_attr ( ty) {
185
+ if self . has_sig_drop_attr ( ty, depth ) {
180
186
return true ;
181
187
}
182
188
}
183
189
for generic_arg in * b {
184
190
if let GenericArgKind :: Type ( ty) = generic_arg. unpack ( )
185
- && self . has_sig_drop_attr ( ty)
191
+ && self . has_sig_drop_attr ( ty, depth )
186
192
{
187
193
return true ;
188
194
}
@@ -192,7 +198,7 @@ impl<'cx, 'others, 'tcx> AttrChecker<'cx, 'others, 'tcx> {
192
198
rustc_middle:: ty:: Array ( ty, _)
193
199
| rustc_middle:: ty:: RawPtr ( ty, _)
194
200
| rustc_middle:: ty:: Ref ( _, ty, _)
195
- | rustc_middle:: ty:: Slice ( ty) => self . has_sig_drop_attr ( * ty) ,
201
+ | rustc_middle:: ty:: Slice ( ty) => self . has_sig_drop_attr ( * ty, depth ) ,
196
202
_ => false ,
197
203
}
198
204
}
@@ -268,7 +274,7 @@ impl<'tcx> Visitor<'tcx> for StmtsChecker<'_, '_, '_, '_, 'tcx> {
268
274
apa. has_expensive_expr_after_last_attr = false ;
269
275
} ;
270
276
let mut ac = AttrChecker :: new ( self . cx , self . type_cache ) ;
271
- if ac. has_sig_drop_attr ( self . cx . typeck_results ( ) . expr_ty ( expr) ) {
277
+ if ac. has_sig_drop_attr ( self . cx . typeck_results ( ) . expr_ty ( expr) , 0 ) {
272
278
if let hir:: StmtKind :: Let ( local) = self . ap . curr_stmt . kind
273
279
&& let hir:: PatKind :: Binding ( _, hir_id, ident, _) = local. pat . kind
274
280
&& !self . ap . apas . contains_key ( & hir_id)
0 commit comments