@@ -19,7 +19,7 @@ use rustc_index::bit_set::GrowableBitSet;
19
19
use rustc_macros:: HashStable ;
20
20
use rustc_session:: Limit ;
21
21
use rustc_span:: sym;
22
- use rustc_target:: abi:: { Integer , IntegerType , Size , TargetDataLayout } ;
22
+ use rustc_target:: abi:: { Integer , IntegerType , Size } ;
23
23
use rustc_target:: spec:: abi:: Abi ;
24
24
use smallvec:: SmallVec ;
25
25
use std:: { fmt, iter} ;
@@ -1085,7 +1085,7 @@ impl<'tcx> Ty<'tcx> {
1085
1085
#[ inline]
1086
1086
pub fn needs_drop ( self , tcx : TyCtxt < ' tcx > , param_env : ty:: ParamEnv < ' tcx > ) -> bool {
1087
1087
// Avoid querying in simple cases.
1088
- match needs_drop_components ( self , & tcx . data_layout ) {
1088
+ match needs_drop_components ( tcx , self ) {
1089
1089
Err ( AlwaysRequiresDrop ) => true ,
1090
1090
Ok ( components) => {
1091
1091
let query_ty = match * components {
@@ -1118,7 +1118,7 @@ impl<'tcx> Ty<'tcx> {
1118
1118
#[ inline]
1119
1119
pub fn has_significant_drop ( self , tcx : TyCtxt < ' tcx > , param_env : ty:: ParamEnv < ' tcx > ) -> bool {
1120
1120
// Avoid querying in simple cases.
1121
- match needs_drop_components ( self , & tcx . data_layout ) {
1121
+ match needs_drop_components ( tcx , self ) {
1122
1122
Err ( AlwaysRequiresDrop ) => true ,
1123
1123
Ok ( components) => {
1124
1124
let query_ty = match * components {
@@ -1278,10 +1278,10 @@ impl<'tcx> ExplicitSelf<'tcx> {
1278
1278
/// *any* of the returned types need drop. Returns `Err(AlwaysRequiresDrop)` if
1279
1279
/// this type always needs drop.
1280
1280
pub fn needs_drop_components < ' tcx > (
1281
+ tcx : TyCtxt < ' tcx > ,
1281
1282
ty : Ty < ' tcx > ,
1282
- target_layout : & TargetDataLayout ,
1283
1283
) -> Result < SmallVec < [ Ty < ' tcx > ; 2 ] > , AlwaysRequiresDrop > {
1284
- match ty. kind ( ) {
1284
+ match * ty. kind ( ) {
1285
1285
ty:: Infer ( ty:: FreshIntTy ( _) )
1286
1286
| ty:: Infer ( ty:: FreshFloatTy ( _) )
1287
1287
| ty:: Bool
@@ -1303,11 +1303,11 @@ pub fn needs_drop_components<'tcx>(
1303
1303
1304
1304
ty:: Dynamic ( ..) | ty:: Error ( _) => Err ( AlwaysRequiresDrop ) ,
1305
1305
1306
- ty:: Slice ( ty) => needs_drop_components ( * ty , target_layout ) ,
1306
+ ty:: Slice ( ty) => needs_drop_components ( tcx , ty ) ,
1307
1307
ty:: Array ( elem_ty, size) => {
1308
- match needs_drop_components ( * elem_ty , target_layout ) {
1308
+ match needs_drop_components ( tcx , elem_ty ) {
1309
1309
Ok ( v) if v. is_empty ( ) => Ok ( v) ,
1310
- res => match size. try_to_bits ( target_layout . pointer_size ) {
1310
+ res => match size. try_to_target_usize ( tcx ) {
1311
1311
// Arrays of size zero don't need drop, even if their element
1312
1312
// type does.
1313
1313
Some ( 0 ) => Ok ( SmallVec :: new ( ) ) ,
@@ -1321,7 +1321,7 @@ pub fn needs_drop_components<'tcx>(
1321
1321
}
1322
1322
// If any field needs drop, then the whole tuple does.
1323
1323
ty:: Tuple ( fields) => fields. iter ( ) . try_fold ( SmallVec :: new ( ) , move |mut acc, elem| {
1324
- acc. extend ( needs_drop_components ( elem , target_layout ) ?) ;
1324
+ acc. extend ( needs_drop_components ( tcx , elem ) ?) ;
1325
1325
Ok ( acc)
1326
1326
} ) ,
1327
1327
0 commit comments