@@ -73,45 +73,6 @@ pub fn type_is_fat_ptr<'tcx>(cx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
7373 }
7474}
7575
76- /// If `type_needs_drop` returns true, then `ty` is definitely
77- /// non-copy and *might* have a destructor attached; if it returns
78- /// false, then `ty` definitely has no destructor (i.e. no drop glue).
79- ///
80- /// (Note that this implies that if `ty` has a destructor attached,
81- /// then `type_needs_drop` will definitely return `true` for `ty`.)
82- pub fn type_needs_drop < ' tcx > ( cx : & ty:: ctxt < ' tcx > , ty : Ty < ' tcx > ) -> bool {
83- type_needs_drop_given_env ( cx, ty, & cx. empty_parameter_environment ( ) )
84- }
85-
86- /// Core implementation of type_needs_drop, potentially making use of
87- /// and/or updating caches held in the `param_env`.
88- fn type_needs_drop_given_env < ' a , ' tcx > ( cx : & ty:: ctxt < ' tcx > ,
89- ty : Ty < ' tcx > ,
90- param_env : & ty:: ParameterEnvironment < ' a , ' tcx > ) -> bool {
91- // Issue #22536: We first query type_moves_by_default. It sees a
92- // normalized version of the type, and therefore will definitely
93- // know whether the type implements Copy (and thus needs no
94- // cleanup/drop/zeroing) ...
95- let implements_copy = !ty. moves_by_default ( param_env, DUMMY_SP ) ;
96-
97- if implements_copy { return false ; }
98-
99- // ... (issue #22536 continued) but as an optimization, still use
100- // prior logic of asking if the `needs_drop` bit is set; we need
101- // not zero non-Copy types if they have no destructor.
102-
103- // FIXME(#22815): Note that calling `ty::type_contents` is a
104- // conservative heuristic; it may report that `needs_drop` is set
105- // when actual type does not actually have a destructor associated
106- // with it. But since `ty` absolutely did not have the `Copy`
107- // bound attached (see above), it is sound to treat it as having a
108- // destructor (e.g. zero its memory on move).
109-
110- let contents = ty. type_contents ( cx) ;
111- debug ! ( "type_needs_drop ty={:?} contents={:?}" , ty, contents) ;
112- contents. needs_drop ( cx)
113- }
114-
11576fn type_is_newtype_immediate < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > , ty : Ty < ' tcx > ) -> bool {
11677 match ty. sty {
11778 ty:: TyStruct ( def, substs) => {
@@ -518,7 +479,7 @@ impl<'a, 'tcx> FunctionContext<'a, 'tcx> {
518479 /// This is the same as `common::type_needs_drop`, except that it
519480 /// may use or update caches within this `FunctionContext`.
520481 pub fn type_needs_drop ( & self , ty : Ty < ' tcx > ) -> bool {
521- type_needs_drop_given_env ( self . ccx . tcx ( ) , ty, & self . param_env )
482+ self . ccx . tcx ( ) . type_needs_drop_given_env ( ty, & self . param_env )
522483 }
523484
524485 pub fn eh_personality ( & self ) -> ValueRef {
0 commit comments