diff options
| author | varkor <github@varkor.com> | 2018-04-19 00:40:22 +0100 |
|---|---|---|
| committer | varkor <github@varkor.com> | 2018-05-15 14:21:32 +0100 |
| commit | 4bed895cab365a9a020fcc033b83603e7d23e4e4 (patch) | |
| tree | cd23e54543650e47e4574ae26aede79edbdb5796 /src/librustc_traits | |
| parent | 5e89312a22993c946f462aff0d0fa0447210762d (diff) | |
| download | rust-4bed895cab365a9a020fcc033b83603e7d23e4e4.tar.gz rust-4bed895cab365a9a020fcc033b83603e7d23e4e4.zip | |
Pull common parameters into GenericParamDef
This leads to a lot of simplifications, as most code doesn't actually need to know about the specific lifetime/type data; rather, it's concerned with properties like name, index and def_id.
Diffstat (limited to 'src/librustc_traits')
| -rw-r--r-- | src/librustc_traits/dropck_outlives.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/librustc_traits/dropck_outlives.rs b/src/librustc_traits/dropck_outlives.rs index da38081a602..6c2128de272 100644 --- a/src/librustc_traits/dropck_outlives.rs +++ b/src/librustc_traits/dropck_outlives.rs @@ -13,7 +13,7 @@ use rustc::hir::def_id::DefId; use rustc::traits::{FulfillmentContext, Normalized, ObligationCause}; use rustc::traits::query::{CanonicalTyGoal, NoSolution}; use rustc::traits::query::dropck_outlives::{DtorckConstraint, DropckOutlivesResult}; -use rustc::ty::{self, ParamEnvAnd, Ty, TyCtxt, GenericParamDef}; +use rustc::ty::{self, ParamEnvAnd, Ty, TyCtxt}; use rustc::ty::subst::Subst; use rustc::util::nodemap::FxHashSet; use rustc_data_structures::sync::Lrc; @@ -278,13 +278,11 @@ crate fn adt_dtorck_constraint<'a, 'tcx>( debug!("dtorck_constraint: {:?}", def); if def.is_phantom_data() { - let type_param = match tcx.generics_of(def_id).params[0] { - GenericParamDef::Type(ty) => ty, - GenericParamDef::Lifetime(_) => unreachable!(), - }; + // 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 result = DtorckConstraint { outlives: vec![], - dtorck_types: vec![tcx.mk_param_from_def(&type_param)], + dtorck_types: vec![tcx.mk_ty_param_from_def(param)], overflows: vec![], }; debug!("dtorck_constraint: {:?} => {:?}", def, result); |
