]> git.lizzy.rs Git - rust.git/commitdiff
Clean up dropck_outlives PhantomData handling
authorvarkor <github@varkor.com>
Tue, 15 May 2018 12:48:04 +0000 (13:48 +0100)
committervarkor <github@varkor.com>
Tue, 15 May 2018 13:22:25 +0000 (14:22 +0100)
src/librustc_traits/dropck_outlives.rs

index 7a39b46f799d28b14ad45433d960a696647959e3..219c6b9aefba51f72be5cacf674fcfd98413d0b6 100644 (file)
@@ -14,7 +14,7 @@
 use rustc::traits::query::{CanonicalTyGoal, NoSolution};
 use rustc::traits::query::dropck_outlives::{DtorckConstraint, DropckOutlivesResult};
 use rustc::ty::{self, ParamEnvAnd, Ty, TyCtxt};
-use rustc::ty::subst::{UnpackedKind, Subst};
+use rustc::ty::subst::{Subst, Substs};
 use rustc::util::nodemap::FxHashSet;
 use rustc_data_structures::sync::Lrc;
 use syntax::codemap::{Span, DUMMY_SP};
@@ -280,14 +280,11 @@ fn dtorck_constraint_for_ty<'a, 'gcx, 'tcx>(
     if def.is_phantom_data() {
         // The first generic parameter here is guaranteed to be a type because it's
         // `PhantomData`.
-        let param = &tcx.generics_of(def_id).params[0];
-        let ty = match tcx.mk_param_from_def(param).unpack() {
-            UnpackedKind::Type(ty) => ty,
-            _ => unreachable!(),
-        };
+        let substs = Substs::identity_for_item(tcx, def_id);
+        assert_eq!(substs.len(), 1);
         let result = DtorckConstraint {
             outlives: vec![],
-            dtorck_types: vec![ty],
+            dtorck_types: vec![substs.type_at(0)],
             overflows: vec![],
         };
         debug!("dtorck_constraint: {:?} => {:?}", def, result);