@@ -73,45 +73,6 @@ pub fn type_is_fat_ptr<'tcx>(cx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
73
73
}
74
74
}
75
75
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
-
115
76
fn type_is_newtype_immediate < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > , ty : Ty < ' tcx > ) -> bool {
116
77
match ty. sty {
117
78
ty:: TyStruct ( def, substs) => {
@@ -518,7 +479,7 @@ impl<'a, 'tcx> FunctionContext<'a, 'tcx> {
518
479
/// This is the same as `common::type_needs_drop`, except that it
519
480
/// may use or update caches within this `FunctionContext`.
520
481
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 )
522
483
}
523
484
524
485
pub fn eh_personality ( & self ) -> ValueRef {
0 commit comments