Skip to content

Commit 39a68e9

Browse files
committed
Clean up dropck_outlives PhantomData handling
1 parent 0a9371a commit 39a68e9

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/librustc_traits/dropck_outlives.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustc::traits::{FulfillmentContext, Normalized, ObligationCause};
1414
use rustc::traits::query::{CanonicalTyGoal, NoSolution};
1515
use rustc::traits::query::dropck_outlives::{DtorckConstraint, DropckOutlivesResult};
1616
use rustc::ty::{self, ParamEnvAnd, Ty, TyCtxt};
17-
use rustc::ty::subst::{UnpackedKind, Subst};
17+
use rustc::ty::subst::{Subst, Substs};
1818
use rustc::util::nodemap::FxHashSet;
1919
use rustc_data_structures::sync::Lrc;
2020
use syntax::codemap::{Span, DUMMY_SP};
@@ -280,14 +280,11 @@ crate fn adt_dtorck_constraint<'a, 'tcx>(
280280
if def.is_phantom_data() {
281281
// The first generic parameter here is guaranteed to be a type because it's
282282
// `PhantomData`.
283-
let param = &tcx.generics_of(def_id).params[0];
284-
let ty = match tcx.mk_param_from_def(param).unpack() {
285-
UnpackedKind::Type(ty) => ty,
286-
_ => unreachable!(),
287-
};
283+
let substs = Substs::identity_for_item(tcx, def_id);
284+
assert_eq!(substs.len(), 1);
288285
let result = DtorckConstraint {
289286
outlives: vec![],
290-
dtorck_types: vec![ty],
287+
dtorck_types: vec![substs.type_at(0)],
291288
overflows: vec![],
292289
};
293290
debug!("dtorck_constraint: {:?} => {:?}", def, result);

0 commit comments

Comments
 (0)