@@ -40,16 +40,13 @@ declare_lint! {
40
40
}
41
41
42
42
fn is_non_trait_box ( ty : ty:: Ty ) -> bool {
43
- match ty. sty {
44
- ty:: TyBox ( inner) => !inner. is_trait ( ) ,
45
- _ => false ,
46
- }
43
+ ty. is_box ( ) && !ty. boxed_ty ( ) . is_trait ( )
47
44
}
48
45
49
46
struct EscapeDelegate < ' a , ' tcx : ' a > {
50
47
set : NodeSet ,
51
48
tcx : ty:: TyCtxt < ' a , ' tcx , ' tcx > ,
52
- tables : & ' a ty:: Tables < ' tcx > ,
49
+ tables : & ' a ty:: TypeckTables < ' tcx > ,
53
50
target : TargetDataLayout ,
54
51
too_large_for_stack : u64 ,
55
52
}
@@ -204,16 +201,16 @@ impl<'a, 'tcx: 'a> EscapeDelegate<'a, 'tcx> {
204
201
fn is_large_box ( & self , ty : ty:: Ty < ' tcx > ) -> bool {
205
202
// Large types need to be boxed to avoid stack
206
203
// overflows.
207
- match ty. sty {
208
- ty :: TyBox ( inner) => {
209
- self . tcx . infer_ctxt ( ( ) , Reveal :: All ) . enter ( |infcx| if let Ok ( layout) = inner. layout ( & infcx) {
210
- let size = layout. size ( & self . target ) ;
211
- size. bytes ( ) > self . too_large_for_stack
212
- } else {
213
- false
214
- } )
215
- } ,
216
- _ => false ,
204
+ if ty. is_box ( ) {
205
+ let inner = ty . boxed_ty ( ) ;
206
+ self . tcx . infer_ctxt ( ( ) , Reveal :: All ) . enter ( |infcx| if let Ok ( layout) = inner. layout ( & infcx) {
207
+ let size = layout. size ( & self . target ) ;
208
+ size. bytes ( ) > self . too_large_for_stack
209
+ } else {
210
+ false
211
+ } )
212
+ } else {
213
+ false
217
214
}
218
215
}
219
216
}
0 commit comments