@@ -190,74 +190,6 @@ impl<'tcx> FromIterator<DtorckConstraint<'tcx>> for DtorckConstraint<'tcx> {
190190 }
191191}
192192
193- /// This returns true if the type `ty` is "trivial" for
194- /// dropck-outlives -- that is, if it doesn't require any types to
195- /// outlive. This is similar but not *quite* the same as the
196- /// `needs_drop` test in the compiler already -- that is, for every
197- /// type T for which this function return true, needs-drop would
198- /// return `false`. But the reverse does not hold: in particular,
199- /// `needs_drop` returns false for `PhantomData`, but it is not
200- /// trivial for dropck-outlives.
201- ///
202- /// Note also that `needs_drop` requires a "global" type (i.e., one
203- /// with erased regions), but this function does not.
204- pub fn trivial_dropck_outlives < ' tcx > ( tcx : TyCtxt < ' tcx > , ty : Ty < ' tcx > ) -> bool {
205- match ty. kind ( ) {
206- // None of these types have a destructor and hence they do not
207- // require anything in particular to outlive the dtor's
208- // execution.
209- ty:: Infer ( ty:: FreshIntTy ( _) )
210- | ty:: Infer ( ty:: FreshFloatTy ( _) )
211- | ty:: Bool
212- | ty:: Int ( _)
213- | ty:: Uint ( _)
214- | ty:: Float ( _)
215- | ty:: Never
216- | ty:: FnDef ( ..)
217- | ty:: FnPtr ( _)
218- | ty:: Char
219- | ty:: GeneratorWitness ( ..)
220- | ty:: RawPtr ( _)
221- | ty:: Ref ( ..)
222- | ty:: Str
223- | ty:: Foreign ( ..)
224- | ty:: Error ( _) => true ,
225-
226- // [T; N] and [T] have same properties as T.
227- ty:: Array ( ty, _) | ty:: Slice ( ty) => trivial_dropck_outlives ( tcx, ty) ,
228-
229- // (T1..Tn) and closures have same properties as T1..Tn --
230- // check if *any* of those are trivial.
231- ty:: Tuple ( ref tys) => tys. iter ( ) . all ( |t| trivial_dropck_outlives ( tcx, t. expect_ty ( ) ) ) ,
232- ty:: Closure ( _, ref substs) => {
233- substs. as_closure ( ) . upvar_tys ( ) . all ( |t| trivial_dropck_outlives ( tcx, t) )
234- }
235-
236- ty:: Adt ( def, _) => {
237- if Some ( def. did ) == tcx. lang_items ( ) . manually_drop ( ) {
238- // `ManuallyDrop` never has a dtor.
239- true
240- } else {
241- // Other types might. Moreover, PhantomData doesn't
242- // have a dtor, but it is considered to own its
243- // content, so it is non-trivial. Unions can have `impl Drop`,
244- // and hence are non-trivial as well.
245- false
246- }
247- }
248-
249- // The following *might* require a destructor: needs deeper inspection.
250- ty:: Dynamic ( ..)
251- | ty:: Projection ( ..)
252- | ty:: Param ( _)
253- | ty:: Opaque ( ..)
254- | ty:: Placeholder ( ..)
255- | ty:: Infer ( _)
256- | ty:: Bound ( ..)
257- | ty:: Generator ( ..) => false ,
258- }
259- }
260-
261193#[ derive( Debug , HashStable ) ]
262194pub struct CandidateStep < ' tcx > {
263195 pub self_ty : Canonical < ' tcx , QueryResponse < ' tcx , Ty < ' tcx > > > ,
0 commit comments