@@ -19,7 +19,7 @@ use rustc_index::bit_set::GrowableBitSet;
1919use rustc_macros:: HashStable ;
2020use rustc_session:: Limit ;
2121use rustc_span:: sym;
22- use rustc_target:: abi:: { Integer , IntegerType , Size , TargetDataLayout } ;
22+ use rustc_target:: abi:: { Integer , IntegerType , Size } ;
2323use rustc_target:: spec:: abi:: Abi ;
2424use smallvec:: SmallVec ;
2525use std:: { fmt, iter} ;
@@ -1085,7 +1085,7 @@ impl<'tcx> Ty<'tcx> {
10851085 #[ inline]
10861086 pub fn needs_drop ( self , tcx : TyCtxt < ' tcx > , param_env : ty:: ParamEnv < ' tcx > ) -> bool {
10871087 // Avoid querying in simple cases.
1088- match needs_drop_components ( self , & tcx . data_layout ) {
1088+ match needs_drop_components ( tcx , self ) {
10891089 Err ( AlwaysRequiresDrop ) => true ,
10901090 Ok ( components) => {
10911091 let query_ty = match * components {
@@ -1118,7 +1118,7 @@ impl<'tcx> Ty<'tcx> {
11181118 #[ inline]
11191119 pub fn has_significant_drop ( self , tcx : TyCtxt < ' tcx > , param_env : ty:: ParamEnv < ' tcx > ) -> bool {
11201120 // Avoid querying in simple cases.
1121- match needs_drop_components ( self , & tcx . data_layout ) {
1121+ match needs_drop_components ( tcx , self ) {
11221122 Err ( AlwaysRequiresDrop ) => true ,
11231123 Ok ( components) => {
11241124 let query_ty = match * components {
@@ -1278,10 +1278,10 @@ impl<'tcx> ExplicitSelf<'tcx> {
12781278/// *any* of the returned types need drop. Returns `Err(AlwaysRequiresDrop)` if
12791279/// this type always needs drop.
12801280pub fn needs_drop_components < ' tcx > (
1281+ tcx : TyCtxt < ' tcx > ,
12811282 ty : Ty < ' tcx > ,
1282- target_layout : & TargetDataLayout ,
12831283) -> Result < SmallVec < [ Ty < ' tcx > ; 2 ] > , AlwaysRequiresDrop > {
1284- match ty. kind ( ) {
1284+ match * ty. kind ( ) {
12851285 ty:: Infer ( ty:: FreshIntTy ( _) )
12861286 | ty:: Infer ( ty:: FreshFloatTy ( _) )
12871287 | ty:: Bool
@@ -1303,11 +1303,11 @@ pub fn needs_drop_components<'tcx>(
13031303
13041304 ty:: Dynamic ( ..) | ty:: Error ( _) => Err ( AlwaysRequiresDrop ) ,
13051305
1306- ty:: Slice ( ty) => needs_drop_components ( * ty , target_layout ) ,
1306+ ty:: Slice ( ty) => needs_drop_components ( tcx , ty ) ,
13071307 ty:: Array ( elem_ty, size) => {
1308- match needs_drop_components ( * elem_ty , target_layout ) {
1308+ match needs_drop_components ( tcx , elem_ty ) {
13091309 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 ) {
13111311 // Arrays of size zero don't need drop, even if their element
13121312 // type does.
13131313 Some ( 0 ) => Ok ( SmallVec :: new ( ) ) ,
@@ -1321,7 +1321,7 @@ pub fn needs_drop_components<'tcx>(
13211321 }
13221322 // If any field needs drop, then the whole tuple does.
13231323 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 ) ?) ;
13251325 Ok ( acc)
13261326 } ) ,
13271327
0 commit comments