From bea3d67c77dd643ef1f89c8bd6562e90b373cec4 Mon Sep 17 00:00:00 2001 From: varkor Date: Wed, 25 Sep 2019 16:39:44 +0100 Subject: [PATCH 1/2] Rename `subst::Kind` to `subst::GenericArg` --- src/librustc/ich/impls_ty.rs | 2 +- src/librustc/infer/canonical/canonicalizer.rs | 6 +- src/librustc/infer/canonical/mod.rs | 28 ++-- .../infer/canonical/query_response.rs | 43 ++--- src/librustc/infer/canonical/substitute.rs | 8 +- src/librustc/infer/error_reporting/mod.rs | 4 +- src/librustc/infer/mod.rs | 4 +- src/librustc/infer/nll_relate/mod.rs | 4 +- src/librustc/infer/opaque_types/mod.rs | 21 ++- src/librustc/infer/outlives/obligations.rs | 8 +- src/librustc/lint/context.rs | 4 +- src/librustc/mir/interpret/mod.rs | 4 +- src/librustc/traits/query/dropck_outlives.rs | 10 +- src/librustc/traits/util.rs | 4 +- src/librustc/ty/context.rs | 32 ++-- src/librustc/ty/flags.rs | 8 +- src/librustc/ty/print/mod.rs | 18 +- src/librustc/ty/print/pretty.rs | 26 +-- src/librustc/ty/relate.rs | 22 +-- src/librustc/ty/sty.rs | 12 +- src/librustc/ty/subst.rs | 154 ++++++++++-------- src/librustc/ty/util.rs | 16 +- .../debuginfo/metadata.rs | 4 +- src/librustc_codegen_llvm/debuginfo/mod.rs | 4 +- .../symbol_names/legacy.rs | 6 +- src/librustc_codegen_utils/symbol_names/v0.rs | 20 +-- .../error_reporting/region_name.rs | 14 +- .../nll/type_check/constraint_conversion.rs | 8 +- .../nll/type_check/liveness/polonius.rs | 4 +- .../borrow_check/nll/type_check/mod.rs | 6 +- src/librustc_mir/hair/cx/mod.rs | 4 +- src/librustc_mir/hair/pattern/mod.rs | 4 +- .../interpret/intrinsics/type_name.rs | 6 +- src/librustc_traits/chalk_context/mod.rs | 16 +- .../chalk_context/program_clauses/builtin.rs | 14 +- .../chalk_context/resolvent_ops.rs | 4 +- src/librustc_traits/generic_types.rs | 4 +- src/librustc_traits/type_op.rs | 4 +- src/librustc_typeck/astconv.rs | 13 +- src/librustc_typeck/check/dropck.rs | 8 +- src/librustc_typeck/check/mod.rs | 8 +- src/librustc_typeck/check/pat.rs | 4 +- src/librustc_typeck/check/regionck.rs | 8 +- src/librustc_typeck/check/wfcheck.rs | 6 +- src/librustc_typeck/collect.rs | 4 +- .../outlives/implicit_infer.rs | 6 +- src/librustc_typeck/outlives/mod.rs | 8 +- src/librustc_typeck/outlives/utils.rs | 13 +- src/librustc_typeck/variance/constraints.rs | 14 +- src/librustdoc/clean/mod.rs | 10 +- 50 files changed, 341 insertions(+), 321 deletions(-) diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs index f230c53728748..56b1560772997 100644 --- a/src/librustc/ich/impls_ty.rs +++ b/src/librustc/ich/impls_ty.rs @@ -56,7 +56,7 @@ where } } -impl<'a, 'tcx> HashStable> for ty::subst::Kind<'tcx> { +impl<'a, 'tcx> HashStable> for ty::subst::GenericArg<'tcx> { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { diff --git a/src/librustc/infer/canonical/canonicalizer.rs b/src/librustc/infer/canonical/canonicalizer.rs index bd003735a892c..2ea1317a94fd9 100644 --- a/src/librustc/infer/canonical/canonicalizer.rs +++ b/src/librustc/infer/canonical/canonicalizer.rs @@ -13,7 +13,7 @@ use crate::infer::InferCtxt; use crate::mir::interpret::ConstValue; use std::sync::atomic::Ordering; use crate::ty::fold::{TypeFoldable, TypeFolder}; -use crate::ty::subst::Kind; +use crate::ty::subst::GenericArg; use crate::ty::{self, BoundVar, InferConst, List, Ty, TyCtxt, TypeFlags}; use crate::ty::flags::FlagComputation; @@ -282,7 +282,7 @@ struct Canonicalizer<'cx, 'tcx> { query_state: &'cx mut OriginalQueryValues<'tcx>, // Note that indices is only used once `var_values` is big enough to be // heap-allocated. - indices: FxHashMap, BoundVar>, + indices: FxHashMap, BoundVar>, canonicalize_region_mode: &'cx dyn CanonicalizeRegionMode, needs_canonical_flags: TypeFlags, @@ -566,7 +566,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> { /// or returns an existing variable if `kind` has already been /// seen. `kind` is expected to be an unbound variable (or /// potentially a free region). - fn canonical_var(&mut self, info: CanonicalVarInfo, kind: Kind<'tcx>) -> BoundVar { + fn canonical_var(&mut self, info: CanonicalVarInfo, kind: GenericArg<'tcx>) -> BoundVar { let Canonicalizer { variables, query_state, diff --git a/src/librustc/infer/canonical/mod.rs b/src/librustc/infer/canonical/mod.rs index 6840611d4be79..4e442608f0e7e 100644 --- a/src/librustc/infer/canonical/mod.rs +++ b/src/librustc/infer/canonical/mod.rs @@ -32,7 +32,7 @@ use smallvec::SmallVec; use std::ops::Index; use syntax::source_map::Span; use crate::ty::fold::TypeFoldable; -use crate::ty::subst::Kind; +use crate::ty::subst::GenericArg; use crate::ty::{self, BoundVar, InferConst, Lift, List, Region, TyCtxt}; mod canonicalizer; @@ -66,7 +66,7 @@ impl<'tcx> UseSpecializedDecodable for CanonicalVarInfos<'tcx> {} /// canonicalized query response. #[derive(Clone, Debug, PartialEq, Eq, Hash, RustcDecodable, RustcEncodable, HashStable)] pub struct CanonicalVarValues<'tcx> { - pub var_values: IndexVec>, + pub var_values: IndexVec>, } /// When we canonicalize a value to form a query, we wind up replacing @@ -83,7 +83,7 @@ pub struct OriginalQueryValues<'tcx> { /// This is equivalent to `CanonicalVarValues`, but using a /// `SmallVec` yields a significant performance win. - pub var_values: SmallVec<[Kind<'tcx>; 8]>, + pub var_values: SmallVec<[GenericArg<'tcx>; 8]>, } impl Default for OriginalQueryValues<'tcx> { @@ -308,7 +308,7 @@ impl<'tcx, V> Canonical<'tcx, V> { } pub type QueryOutlivesConstraint<'tcx> = - ty::Binder, Region<'tcx>>>; + ty::Binder, Region<'tcx>>>; impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> { /// Creates a substitution S for the canonical value with fresh @@ -359,7 +359,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> { variables: &List, universe_map: impl Fn(ty::UniverseIndex) -> ty::UniverseIndex, ) -> CanonicalVarValues<'tcx> { - let var_values: IndexVec> = variables + let var_values: IndexVec> = variables .iter() .map(|info| self.instantiate_canonical_var(span, *info, &universe_map)) .collect(); @@ -376,7 +376,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> { span: Span, cv_info: CanonicalVarInfo, universe_map: impl Fn(ty::UniverseIndex) -> ty::UniverseIndex, - ) -> Kind<'tcx> { + ) -> GenericArg<'tcx> { match cv_info.kind { CanonicalVarKind::Ty(ty_kind) => { let ty = match ty_kind { @@ -495,19 +495,19 @@ impl<'tcx> CanonicalVarValues<'tcx> { /// we'll return a substitution `subst` with: /// `subst.var_values == [Type(^0), Lifetime(^1), Type(^2)]`. pub fn make_identity(&self, tcx: TyCtxt<'tcx>) -> Self { - use crate::ty::subst::UnpackedKind; + use crate::ty::subst::GenericArgKind; CanonicalVarValues { var_values: self.var_values.iter() .zip(0..) .map(|(kind, i)| match kind.unpack() { - UnpackedKind::Type(..) => tcx.mk_ty( + GenericArgKind::Type(..) => tcx.mk_ty( ty::Bound(ty::INNERMOST, ty::BoundVar::from_u32(i).into()) ).into(), - UnpackedKind::Lifetime(..) => tcx.mk_region( + GenericArgKind::Lifetime(..) => tcx.mk_region( ty::ReLateBound(ty::INNERMOST, ty::BoundRegion::BrAnon(i)) ).into(), - UnpackedKind::Const(ct) => { + GenericArgKind::Const(ct) => { tcx.mk_const(ty::Const { ty: ct.ty, val: ConstValue::Infer( @@ -522,8 +522,8 @@ impl<'tcx> CanonicalVarValues<'tcx> { } impl<'a, 'tcx> IntoIterator for &'a CanonicalVarValues<'tcx> { - type Item = Kind<'tcx>; - type IntoIter = ::std::iter::Cloned<::std::slice::Iter<'a, Kind<'tcx>>>; + type Item = GenericArg<'tcx>; + type IntoIter = ::std::iter::Cloned<::std::slice::Iter<'a, GenericArg<'tcx>>>; fn into_iter(self) -> Self::IntoIter { self.var_values.iter().cloned() @@ -570,9 +570,9 @@ BraceStructLiftImpl! { } impl<'tcx> Index for CanonicalVarValues<'tcx> { - type Output = Kind<'tcx>; + type Output = GenericArg<'tcx>; - fn index(&self, value: BoundVar) -> &Kind<'tcx> { + fn index(&self, value: BoundVar) -> &GenericArg<'tcx> { &self.var_values[value] } } diff --git a/src/librustc/infer/canonical/query_response.rs b/src/librustc/infer/canonical/query_response.rs index ae1624fc5a242..18c1b41d5bb4c 100644 --- a/src/librustc/infer/canonical/query_response.rs +++ b/src/librustc/infer/canonical/query_response.rs @@ -25,7 +25,7 @@ use crate::traits::query::{Fallible, NoSolution}; use crate::traits::TraitEngine; use crate::traits::{Obligation, ObligationCause, PredicateObligation}; use crate::ty::fold::TypeFoldable; -use crate::ty::subst::{Kind, UnpackedKind}; +use crate::ty::subst::{GenericArg, GenericArgKind}; use crate::ty::{self, BoundVar, InferConst, Ty, TyCtxt}; use crate::util::captures::Captures; @@ -298,11 +298,14 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> { &v.var_values[BoundVar::new(index)] }); match (original_value.unpack(), result_value.unpack()) { - (UnpackedKind::Lifetime(ty::ReErased), UnpackedKind::Lifetime(ty::ReErased)) => { - // no action needed + ( + GenericArgKind::Lifetime(ty::ReErased), + GenericArgKind::Lifetime(ty::ReErased), + ) => { + // No action needed. } - (UnpackedKind::Lifetime(v_o), UnpackedKind::Lifetime(v_r)) => { + (GenericArgKind::Lifetime(v_o), GenericArgKind::Lifetime(v_r)) => { // To make `v_o = v_r`, we emit `v_o: v_r` and `v_r: v_o`. if v_o != v_r { output_query_region_constraints @@ -314,12 +317,12 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> { } } - (UnpackedKind::Type(v1), UnpackedKind::Type(v2)) => { + (GenericArgKind::Type(v1), GenericArgKind::Type(v2)) => { let ok = self.at(cause, param_env).eq(v1, v2)?; obligations.extend(ok.into_obligations()); } - (UnpackedKind::Const(v1), UnpackedKind::Const(v2)) => { + (GenericArgKind::Const(v1), GenericArgKind::Const(v2)) => { let ok = self.at(cause, param_env).eq(v1, v2)?; obligations.extend(ok.into_obligations()); } @@ -462,14 +465,14 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> { // is directly equal to one of the canonical variables in the // result, then we can type the corresponding value from the // input. See the example above. - let mut opt_values: IndexVec>> = + let mut opt_values: IndexVec>> = IndexVec::from_elem_n(None, query_response.variables.len()); // In terms of our example above, we are iterating over pairs like: // [(?A, Vec), ('static, '?1), (?B, ?0)] for (original_value, result_value) in original_values.var_values.iter().zip(result_values) { match result_value.unpack() { - UnpackedKind::Type(result_value) => { + GenericArgKind::Type(result_value) => { // e.g., here `result_value` might be `?0` in the example above... if let ty::Bound(debruijn, b) = result_value.kind { // ...in which case we would set `canonical_vars[0]` to `Some(?U)`. @@ -479,7 +482,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> { opt_values[b.var] = Some(*original_value); } } - UnpackedKind::Lifetime(result_value) => { + GenericArgKind::Lifetime(result_value) => { // e.g., here `result_value` might be `'?1` in the example above... if let &ty::RegionKind::ReLateBound(debruijn, br) = result_value { // ... in which case we would set `canonical_vars[0]` to `Some('static)`. @@ -489,7 +492,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> { opt_values[br.assert_bound_var()] = Some(*original_value); } } - UnpackedKind::Const(result_value) => { + GenericArgKind::Const(result_value) => { if let ty::Const { val: ConstValue::Infer(InferConst::Canonical(debrujin, b)), .. @@ -553,7 +556,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> { // canonical variable; this is taken from // `query_response.var_values` after applying the substitution // `result_subst`. - let substituted_query_response = |index: BoundVar| -> Kind<'tcx> { + let substituted_query_response = |index: BoundVar| -> GenericArg<'tcx> { query_response.substitute_projected(self.tcx, &result_subst, |v| &v.var_values[index]) }; @@ -586,17 +589,17 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> { cause.clone(), param_env, match k1.unpack() { - UnpackedKind::Lifetime(r1) => ty::Predicate::RegionOutlives( + GenericArgKind::Lifetime(r1) => ty::Predicate::RegionOutlives( ty::Binder::bind( ty::OutlivesPredicate(r1, r2) ) ), - UnpackedKind::Type(t1) => ty::Predicate::TypeOutlives( + GenericArgKind::Type(t1) => ty::Predicate::TypeOutlives( ty::Binder::bind( ty::OutlivesPredicate(t1, r2) ) ), - UnpackedKind::Const(..) => { + GenericArgKind::Const(..) => { // Consts cannot outlive one another, so we don't expect to // ecounter this branch. span_bug!(cause.span, "unexpected const outlives {:?}", constraint); @@ -613,7 +616,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> { cause: &ObligationCause<'tcx>, param_env: ty::ParamEnv<'tcx>, variables1: &OriginalQueryValues<'tcx>, - variables2: impl Fn(BoundVar) -> Kind<'tcx>, + variables2: impl Fn(BoundVar) -> GenericArg<'tcx>, ) -> InferResult<'tcx, ()> { self.commit_if_ok(|_| { let mut obligations = vec![]; @@ -621,21 +624,21 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> { let value2 = variables2(BoundVar::new(index)); match (value1.unpack(), value2.unpack()) { - (UnpackedKind::Type(v1), UnpackedKind::Type(v2)) => { + (GenericArgKind::Type(v1), GenericArgKind::Type(v2)) => { obligations .extend(self.at(cause, param_env).eq(v1, v2)?.into_obligations()); } ( - UnpackedKind::Lifetime(ty::ReErased), - UnpackedKind::Lifetime(ty::ReErased), + GenericArgKind::Lifetime(ty::ReErased), + GenericArgKind::Lifetime(ty::ReErased), ) => { // no action needed } - (UnpackedKind::Lifetime(v1), UnpackedKind::Lifetime(v2)) => { + (GenericArgKind::Lifetime(v1), GenericArgKind::Lifetime(v2)) => { obligations .extend(self.at(cause, param_env).eq(v1, v2)?.into_obligations()); } - (UnpackedKind::Const(v1), UnpackedKind::Const(v2)) => { + (GenericArgKind::Const(v1), GenericArgKind::Const(v2)) => { let ok = self.at(cause, param_env).eq(v1, v2)?; obligations.extend(ok.into_obligations()); } diff --git a/src/librustc/infer/canonical/substitute.rs b/src/librustc/infer/canonical/substitute.rs index 1234b96ab110c..4f5bb09c9167a 100644 --- a/src/librustc/infer/canonical/substitute.rs +++ b/src/librustc/infer/canonical/substitute.rs @@ -8,7 +8,7 @@ use crate::infer::canonical::{Canonical, CanonicalVarValues}; use crate::ty::fold::TypeFoldable; -use crate::ty::subst::UnpackedKind; +use crate::ty::subst::GenericArgKind; use crate::ty::{self, TyCtxt}; impl<'tcx, V> Canonical<'tcx, V> { @@ -58,21 +58,21 @@ where } else { let fld_r = |br: ty::BoundRegion| { match var_values.var_values[br.assert_bound_var()].unpack() { - UnpackedKind::Lifetime(l) => l, + GenericArgKind::Lifetime(l) => l, r => bug!("{:?} is a region but value is {:?}", br, r), } }; let fld_t = |bound_ty: ty::BoundTy| { match var_values.var_values[bound_ty.var].unpack() { - UnpackedKind::Type(ty) => ty, + GenericArgKind::Type(ty) => ty, r => bug!("{:?} is a type but value is {:?}", bound_ty, r), } }; let fld_c = |bound_ct: ty::BoundVar, _| { match var_values.var_values[bound_ct].unpack() { - UnpackedKind::Const(ct) => ct, + GenericArgKind::Const(ct) => ct, c => bug!("{:?} is a const but value is {:?}", bound_ct, c), } }; diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index 15a664cb33b6f..f28a52a1d8d7d 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -464,7 +464,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { use hir::def_id::CrateNum; use hir::map::DisambiguatedDefPathData; use ty::print::Printer; - use ty::subst::Kind; + use ty::subst::GenericArg; struct AbsolutePathPrinter<'tcx> { tcx: TyCtxt<'tcx>, @@ -548,7 +548,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { fn path_generic_args( self, print_prefix: impl FnOnce(Self) -> Result, - _args: &[Kind<'tcx>], + _args: &[GenericArg<'tcx>], ) -> Result { print_prefix(self) } diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index c1782f53f0d2f..ca07496afed08 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -20,7 +20,7 @@ use crate::traits::{self, ObligationCause, PredicateObligations, TraitEngine}; use crate::ty::error::{ExpectedFound, TypeError, UnconstrainedNumeric}; use crate::ty::fold::{TypeFolder, TypeFoldable}; use crate::ty::relate::RelateResult; -use crate::ty::subst::{Kind, InternalSubsts, SubstsRef}; +use crate::ty::subst::{GenericArg, InternalSubsts, SubstsRef}; use crate::ty::{self, GenericParamDefKind, Ty, TyCtxt, InferConst}; use crate::ty::{FloatVid, IntVid, TyVid, ConstVid}; use crate::util::nodemap::FxHashMap; @@ -1110,7 +1110,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { self.next_region_var_in_universe(RegionVariableOrigin::NLL(origin), universe) } - pub fn var_for_def(&self, span: Span, param: &ty::GenericParamDef) -> Kind<'tcx> { + pub fn var_for_def(&self, span: Span, param: &ty::GenericParamDef) -> GenericArg<'tcx> { match param.kind { GenericParamDefKind::Lifetime => { // Create a region inference variable for the given diff --git a/src/librustc/infer/nll_relate/mod.rs b/src/librustc/infer/nll_relate/mod.rs index 50a2c95ed6f22..47e5c2b59ef36 100644 --- a/src/librustc/infer/nll_relate/mod.rs +++ b/src/librustc/infer/nll_relate/mod.rs @@ -26,7 +26,7 @@ use crate::traits::DomainGoal; use crate::ty::error::TypeError; use crate::ty::fold::{TypeFoldable, TypeVisitor}; use crate::ty::relate::{self, Relate, RelateResult, TypeRelation}; -use crate::ty::subst::Kind; +use crate::ty::subst::GenericArg; use crate::ty::{self, Ty, TyCtxt, InferConst}; use crate::mir::interpret::ConstValue; use rustc_data_structures::fx::FxHashMap; @@ -124,7 +124,7 @@ pub trait TypeRelatingDelegate<'tcx> { #[derive(Clone, Debug)] struct ScopesAndKind<'tcx> { scopes: Vec>, - kind: Kind<'tcx>, + kind: GenericArg<'tcx>, } #[derive(Clone, Debug, Default)] diff --git a/src/librustc/infer/opaque_types/mod.rs b/src/librustc/infer/opaque_types/mod.rs index 9b447f192a97a..0b746e5dfb623 100644 --- a/src/librustc/infer/opaque_types/mod.rs +++ b/src/librustc/infer/opaque_types/mod.rs @@ -7,7 +7,7 @@ use crate::middle::region; use crate::mir::interpret::ConstValue; use crate::traits::{self, PredicateObligation}; use crate::ty::fold::{BottomUpFolder, TypeFoldable, TypeFolder, TypeVisitor}; -use crate::ty::subst::{InternalSubsts, Kind, SubstsRef, UnpackedKind}; +use crate::ty::subst::{InternalSubsts, GenericArg, SubstsRef, GenericArgKind}; use crate::ty::{self, GenericParamDefKind, Ty, TyCtxt}; use crate::util::nodemap::DefIdMap; use errors::DiagnosticBuilder; @@ -570,7 +570,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { // `impl Trait` return type, resulting in the parameters // shifting. let id_substs = InternalSubsts::identity_for_item(gcx, def_id); - let map: FxHashMap, Kind<'tcx>> = opaque_defn + let map: FxHashMap, GenericArg<'tcx>> = opaque_defn .substs .iter() .enumerate() @@ -759,7 +759,7 @@ struct ReverseMapper<'tcx> { tainted_by_errors: bool, opaque_type_def_id: DefId, - map: FxHashMap, Kind<'tcx>>, + map: FxHashMap, GenericArg<'tcx>>, map_missing_regions_to_empty: bool, /// initially `Some`, set to `None` once error has been reported @@ -774,7 +774,7 @@ impl ReverseMapper<'tcx> { tcx: TyCtxt<'tcx>, tainted_by_errors: bool, opaque_type_def_id: DefId, - map: FxHashMap, Kind<'tcx>>, + map: FxHashMap, GenericArg<'tcx>>, hidden_ty: Ty<'tcx>, span: Span, ) -> Self { @@ -789,7 +789,10 @@ impl ReverseMapper<'tcx> { } } - fn fold_kind_mapping_missing_regions_to_empty(&mut self, kind: Kind<'tcx>) -> Kind<'tcx> { + fn fold_kind_mapping_missing_regions_to_empty( + &mut self, + kind: GenericArg<'tcx>, + ) -> GenericArg<'tcx> { assert!(!self.map_missing_regions_to_empty); self.map_missing_regions_to_empty = true; let kind = kind.fold_with(self); @@ -797,7 +800,7 @@ impl ReverseMapper<'tcx> { kind } - fn fold_kind_normally(&mut self, kind: Kind<'tcx>) -> Kind<'tcx> { + fn fold_kind_normally(&mut self, kind: GenericArg<'tcx>) -> GenericArg<'tcx> { assert!(!self.map_missing_regions_to_empty); kind.fold_with(self) } @@ -822,7 +825,7 @@ impl TypeFolder<'tcx> for ReverseMapper<'tcx> { let generics = self.tcx().generics_of(self.opaque_type_def_id); match self.map.get(&r.into()).map(|k| k.unpack()) { - Some(UnpackedKind::Lifetime(r1)) => r1, + Some(GenericArgKind::Lifetime(r1)) => r1, Some(u) => panic!("region mapped to unexpected kind: {:?}", u), None if generics.parent.is_some() => { if !self.map_missing_regions_to_empty && !self.tainted_by_errors { @@ -919,7 +922,7 @@ impl TypeFolder<'tcx> for ReverseMapper<'tcx> { match self.map.get(&ty.into()).map(|k| k.unpack()) { // Found it in the substitution list; replace with the parameter from the // opaque type. - Some(UnpackedKind::Type(t1)) => t1, + Some(GenericArgKind::Type(t1)) => t1, Some(u) => panic!("type mapped to unexpected kind: {:?}", u), None => { self.tcx.sess @@ -949,7 +952,7 @@ impl TypeFolder<'tcx> for ReverseMapper<'tcx> { match self.map.get(&ct.into()).map(|k| k.unpack()) { // Found it in the substitution list, replace with the parameter from the // opaque type. - Some(UnpackedKind::Const(c1)) => c1, + Some(GenericArgKind::Const(c1)) => c1, Some(u) => panic!("const mapped to unexpected kind: {:?}", u), None => { self.tcx.sess diff --git a/src/librustc/infer/outlives/obligations.rs b/src/librustc/infer/outlives/obligations.rs index df491aef54fb9..f7806188775fa 100644 --- a/src/librustc/infer/outlives/obligations.rs +++ b/src/librustc/infer/outlives/obligations.rs @@ -67,7 +67,7 @@ use crate::hir; use crate::traits::ObligationCause; use crate::ty::outlives::Component; use crate::ty::{self, Region, Ty, TyCtxt, TypeFoldable}; -use crate::ty::subst::UnpackedKind; +use crate::ty::subst::GenericArgKind; impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> { /// Registers that the given region obligation must be resolved @@ -433,13 +433,13 @@ where for k in projection_ty.substs { match k.unpack() { - UnpackedKind::Lifetime(lt) => { + GenericArgKind::Lifetime(lt) => { self.delegate.push_sub_region_constraint(origin.clone(), region, lt); } - UnpackedKind::Type(ty) => { + GenericArgKind::Type(ty) => { self.type_must_outlive(origin.clone(), ty, region); } - UnpackedKind::Const(_) => { + GenericArgKind::Const(_) => { // Const parameters don't impose constraints. } } diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index e2582346de84c..3483efbd8408f 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -27,7 +27,7 @@ use crate::lint::builtin::BuiltinLintDiagnostics; use crate::lint::levels::{LintLevelSets, LintLevelsBuilder}; use crate::middle::privacy::AccessLevels; use crate::session::{config, early_error, Session}; -use crate::ty::{self, print::Printer, subst::Kind, TyCtxt, Ty}; +use crate::ty::{self, print::Printer, subst::GenericArg, TyCtxt, Ty}; use crate::ty::layout::{LayoutError, LayoutOf, TyLayout}; use crate::util::nodemap::FxHashMap; use crate::util::common::time; @@ -882,7 +882,7 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> { fn path_generic_args( self, print_prefix: impl FnOnce(Self) -> Result, - _args: &[Kind<'tcx>], + _args: &[GenericArg<'tcx>], ) -> Result { print_prefix(self) } diff --git a/src/librustc/mir/interpret/mod.rs b/src/librustc/mir/interpret/mod.rs index 23433c2e8834d..cd58396d95c62 100644 --- a/src/librustc/mir/interpret/mod.rs +++ b/src/librustc/mir/interpret/mod.rs @@ -109,7 +109,7 @@ pub use self::pointer::{Pointer, PointerArithmetic, CheckInAllocMsg}; use crate::mir; use crate::hir::def_id::DefId; -use crate::ty::{self, TyCtxt, Instance, subst::UnpackedKind}; +use crate::ty::{self, TyCtxt, Instance, subst::GenericArgKind}; use crate::ty::codec::TyDecoder; use crate::ty::layout::{self, Size}; use std::io; @@ -426,7 +426,7 @@ impl<'tcx> AllocMap<'tcx> { // this for generic functions. Lifetime parameters are ignored. let is_generic = instance.substs.into_iter().any(|kind| { match kind.unpack() { - UnpackedKind::Lifetime(_) => false, + GenericArgKind::Lifetime(_) => false, _ => true, } }); diff --git a/src/librustc/traits/query/dropck_outlives.rs b/src/librustc/traits/query/dropck_outlives.rs index 673cae1ca0309..c3c43132d8540 100644 --- a/src/librustc/traits/query/dropck_outlives.rs +++ b/src/librustc/traits/query/dropck_outlives.rs @@ -3,7 +3,7 @@ use crate::infer::InferOk; use crate::infer::canonical::OriginalQueryValues; use std::iter::FromIterator; use syntax::source_map::Span; -use crate::ty::subst::Kind; +use crate::ty::subst::GenericArg; use crate::ty::{self, Ty, TyCtxt}; impl<'cx, 'tcx> At<'cx, 'tcx> { @@ -24,7 +24,7 @@ impl<'cx, 'tcx> At<'cx, 'tcx> { /// /// [#1238]: https://github.com/rust-lang/rfcs/blob/master/text/1238-nonparametric-dropck.md /// [#1327]: https://github.com/rust-lang/rfcs/blob/master/text/1327-dropck-param-eyepatch.md - pub fn dropck_outlives(&self, ty: Ty<'tcx>) -> InferOk<'tcx, Vec>> { + pub fn dropck_outlives(&self, ty: Ty<'tcx>) -> InferOk<'tcx, Vec>> { debug!( "dropck_outlives(ty={:?}, param_env={:?})", ty, self.param_env, @@ -80,7 +80,7 @@ impl<'cx, 'tcx> At<'cx, 'tcx> { #[derive(Clone, Debug, Default)] pub struct DropckOutlivesResult<'tcx> { - pub kinds: Vec>, + pub kinds: Vec>, pub overflows: Vec>, } @@ -104,7 +104,7 @@ impl<'tcx> DropckOutlivesResult<'tcx> { tcx: TyCtxt<'tcx>, span: Span, ty: Ty<'tcx>, - ) -> Vec> { + ) -> Vec> { self.report_overflows(tcx, span, ty); let DropckOutlivesResult { kinds, overflows: _ } = self; kinds @@ -117,7 +117,7 @@ impl<'tcx> DropckOutlivesResult<'tcx> { pub struct DtorckConstraint<'tcx> { /// Types that are required to be alive in order for this /// type to be valid for destruction. - pub outlives: Vec>, + pub outlives: Vec>, /// Types that could not be resolved: projections and params. pub dtorck_types: Vec>, diff --git a/src/librustc/traits/util.rs b/src/librustc/traits/util.rs index 3e5520dd46557..6a99d12d1a425 100644 --- a/src/librustc/traits/util.rs +++ b/src/librustc/traits/util.rs @@ -7,7 +7,7 @@ use crate::hir::def_id::DefId; use crate::traits::specialize::specialization_graph::NodeItem; use crate::ty::{self, Ty, TyCtxt, ToPredicate, ToPolyTraitRef}; use crate::ty::outlives::Component; -use crate::ty::subst::{Kind, Subst, SubstsRef}; +use crate::ty::subst::{GenericArg, Subst, SubstsRef}; use crate::util::nodemap::FxHashSet; use super::{Obligation, ObligationCause, PredicateObligation, SelectionContext, Normalized}; @@ -551,7 +551,7 @@ impl<'tcx> TyCtxt<'tcx> { trait_def_id: DefId, recursion_depth: usize, self_ty: Ty<'tcx>, - params: &[Kind<'tcx>]) + params: &[GenericArg<'tcx>]) -> PredicateObligation<'tcx> { let trait_ref = ty::TraitRef { diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 8a466567319e7..bfaaca688306a 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -23,7 +23,7 @@ use crate::middle::resolve_lifetime::{self, ObjectLifetimeDefault}; use crate::middle::stability; use crate::mir::{Body, interpret, ProjectionKind, Promoted}; use crate::mir::interpret::{ConstValue, Allocation, Scalar}; -use crate::ty::subst::{Kind, InternalSubsts, SubstsRef, Subst}; +use crate::ty::subst::{GenericArg, InternalSubsts, SubstsRef, Subst}; use crate::ty::ReprOptions; use crate::traits; use crate::traits::{Clause, Clauses, GoalKind, Goal, Goals}; @@ -39,7 +39,7 @@ use crate::ty::GenericParamDefKind; use crate::ty::layout::{LayoutDetails, TargetDataLayout, VariantIdx}; use crate::ty::query; use crate::ty::steal::Steal; -use crate::ty::subst::{UserSubsts, UnpackedKind}; +use crate::ty::subst::{UserSubsts, GenericArgKind}; use crate::ty::{BoundVar, BindingMode}; use crate::ty::CanonicalPolyFnSig; use crate::util::common::ErrorReported; @@ -828,7 +828,7 @@ impl CanonicalUserType<'tcx> { user_substs.substs.iter().zip(BoundVar::new(0)..).all(|(kind, cvar)| { match kind.unpack() { - UnpackedKind::Type(ty) => match ty.kind { + GenericArgKind::Type(ty) => match ty.kind { ty::Bound(debruijn, b) => { // We only allow a `ty::INNERMOST` index in substitutions. assert_eq!(debruijn, ty::INNERMOST); @@ -837,7 +837,7 @@ impl CanonicalUserType<'tcx> { _ => false, }, - UnpackedKind::Lifetime(r) => match r { + GenericArgKind::Lifetime(r) => match r { ty::ReLateBound(debruijn, br) => { // We only allow a `ty::INNERMOST` index in substitutions. assert_eq!(*debruijn, ty::INNERMOST); @@ -846,7 +846,7 @@ impl CanonicalUserType<'tcx> { _ => false, }, - UnpackedKind::Const(ct) => match ct.val { + GenericArgKind::Const(ct) => match ct.val { ConstValue::Infer(InferConst::Canonical(debruijn, b)) => { // We only allow a `ty::INNERMOST` index in substitutions. assert_eq!(debruijn, ty::INNERMOST); @@ -1701,7 +1701,7 @@ nop_list_lift!{CanonicalVarInfo => CanonicalVarInfo} nop_list_lift!{ProjectionKind => ProjectionKind} // This is the impl for `&'a InternalSubsts<'a>`. -nop_list_lift!{Kind<'a> => Kind<'tcx>} +nop_list_lift!{GenericArg<'a> => GenericArg<'tcx>} pub mod tls { use super::{GlobalCtxt, TyCtxt, ptr_eq}; @@ -2129,8 +2129,8 @@ impl<'tcx> Borrow<[CanonicalVarInfo]> for Interned<'tcx, List> } } -impl<'tcx> Borrow<[Kind<'tcx>]> for Interned<'tcx, InternalSubsts<'tcx>> { - fn borrow<'a>(&'a self) -> &'a [Kind<'tcx>] { +impl<'tcx> Borrow<[GenericArg<'tcx>]> for Interned<'tcx, InternalSubsts<'tcx>> { + fn borrow<'a>(&'a self) -> &'a [GenericArg<'tcx>] { &self.0[..] } } @@ -2250,7 +2250,7 @@ slice_interners!( existential_predicates: _intern_existential_predicates(ExistentialPredicate<'tcx>), predicates: _intern_predicates(Predicate<'tcx>), type_list: _intern_type_list(Ty<'tcx>), - substs: _intern_substs(Kind<'tcx>), + substs: _intern_substs(GenericArg<'tcx>), clauses: _intern_clauses(Clause<'tcx>), goal_list: _intern_goals(Goal<'tcx>), projs: _intern_projs(ProjectionKind) @@ -2452,13 +2452,13 @@ impl<'tcx> TyCtxt<'tcx> { #[inline] pub fn intern_tup(self, ts: &[Ty<'tcx>]) -> Ty<'tcx> { - let kinds: Vec<_> = ts.into_iter().map(|&t| Kind::from(t)).collect(); + let kinds: Vec<_> = ts.into_iter().map(|&t| GenericArg::from(t)).collect(); self.mk_ty(Tuple(self.intern_substs(&kinds))) } pub fn mk_tup], Ty<'tcx>>>(self, iter: I) -> I::Output { iter.intern_with(|ts| { - let kinds: Vec<_> = ts.into_iter().map(|&t| Kind::from(t)).collect(); + let kinds: Vec<_> = ts.into_iter().map(|&t| GenericArg::from(t)).collect(); self.mk_ty(Tuple(self.intern_substs(&kinds))) }) } @@ -2592,7 +2592,7 @@ impl<'tcx> TyCtxt<'tcx> { } - pub fn mk_param_from_def(self, param: &ty::GenericParamDef) -> Kind<'tcx> { + pub fn mk_param_from_def(self, param: &ty::GenericParamDef) -> GenericArg<'tcx> { match param.kind { GenericParamDefKind::Lifetime => { self.mk_region(ty::ReEarlyBound(param.to_early_bound_region_data())).into() @@ -2637,7 +2637,7 @@ impl<'tcx> TyCtxt<'tcx> { } } - pub fn intern_substs(self, ts: &[Kind<'tcx>]) -> &'tcx List> { + pub fn intern_substs(self, ts: &[GenericArg<'tcx>]) -> &'tcx List> { if ts.len() == 0 { List::empty() } else { @@ -2710,14 +2710,14 @@ impl<'tcx> TyCtxt<'tcx> { iter.intern_with(|xs| self.intern_type_list(xs)) } - pub fn mk_substs], - &'tcx List>>>(self, iter: I) -> I::Output { + pub fn mk_substs], + &'tcx List>>>(self, iter: I) -> I::Output { iter.intern_with(|xs| self.intern_substs(xs)) } pub fn mk_substs_trait(self, self_ty: Ty<'tcx>, - rest: &[Kind<'tcx>]) + rest: &[GenericArg<'tcx>]) -> SubstsRef<'tcx> { self.mk_substs(iter::once(self_ty.into()).chain(rest.iter().cloned())) diff --git a/src/librustc/ty/flags.rs b/src/librustc/ty/flags.rs index b2d74f963b0b3..297c001dae927 100644 --- a/src/librustc/ty/flags.rs +++ b/src/librustc/ty/flags.rs @@ -1,4 +1,4 @@ -use crate::ty::subst::{SubstsRef, UnpackedKind}; +use crate::ty::subst::{SubstsRef, GenericArgKind}; use crate::ty::{self, Ty, TypeFlags, InferConst}; use crate::mir::interpret::ConstValue; @@ -266,9 +266,9 @@ impl FlagComputation { fn add_substs(&mut self, substs: SubstsRef<'_>) { for kind in substs { match kind.unpack() { - UnpackedKind::Type(ty) => self.add_ty(ty), - UnpackedKind::Lifetime(lt) => self.add_region(lt), - UnpackedKind::Const(ct) => self.add_const(ct), + GenericArgKind::Type(ty) => self.add_ty(ty), + GenericArgKind::Lifetime(lt) => self.add_region(lt), + GenericArgKind::Const(ct) => self.add_const(ct), } } } diff --git a/src/librustc/ty/print/mod.rs b/src/librustc/ty/print/mod.rs index 727397d7a29ab..d216c81f8a6c2 100644 --- a/src/librustc/ty/print/mod.rs +++ b/src/librustc/ty/print/mod.rs @@ -1,7 +1,7 @@ use crate::hir::map::{DefPathData, DisambiguatedDefPathData}; use crate::hir::def_id::{CrateNum, DefId}; use crate::ty::{self, DefIdTree, Ty, TyCtxt}; -use crate::ty::subst::{Kind, Subst}; +use crate::ty::subst::{GenericArg, Subst}; use rustc_data_structures::fx::FxHashSet; @@ -43,7 +43,7 @@ pub trait Printer<'tcx>: Sized { fn print_def_path( self, def_id: DefId, - substs: &'tcx [Kind<'tcx>], + substs: &'tcx [GenericArg<'tcx>], ) -> Result { self.default_print_def_path(def_id, substs) } @@ -51,7 +51,7 @@ pub trait Printer<'tcx>: Sized { fn print_impl_path( self, impl_def_id: DefId, - substs: &'tcx [Kind<'tcx>], + substs: &'tcx [GenericArg<'tcx>], self_ty: Ty<'tcx>, trait_ref: Option>, ) -> Result { @@ -106,7 +106,7 @@ pub trait Printer<'tcx>: Sized { fn path_generic_args( self, print_prefix: impl FnOnce(Self) -> Result, - args: &[Kind<'tcx>], + args: &[GenericArg<'tcx>], ) -> Result; // Defaults (should not be overriden): @@ -114,7 +114,7 @@ pub trait Printer<'tcx>: Sized { fn default_print_def_path( self, def_id: DefId, - substs: &'tcx [Kind<'tcx>], + substs: &'tcx [GenericArg<'tcx>], ) -> Result { debug!("default_print_def_path: def_id={:?}, substs={:?}", def_id, substs); let key = self.tcx().def_key(def_id); @@ -189,8 +189,8 @@ pub trait Printer<'tcx>: Sized { fn generic_args_to_print( &self, generics: &'tcx ty::Generics, - substs: &'tcx [Kind<'tcx>], - ) -> &'tcx [Kind<'tcx>] { + substs: &'tcx [GenericArg<'tcx>], + ) -> &'tcx [GenericArg<'tcx>] { let mut own_params = generics.parent_count..generics.count(); // Don't print args for `Self` parameters (of traits). @@ -203,7 +203,7 @@ pub trait Printer<'tcx>: Sized { match param.kind { ty::GenericParamDefKind::Lifetime => false, ty::GenericParamDefKind::Type { has_default, .. } => { - has_default && substs[param.index as usize] == Kind::from( + has_default && substs[param.index as usize] == GenericArg::from( self.tcx().type_of(param.def_id).subst(self.tcx(), substs) ) } @@ -217,7 +217,7 @@ pub trait Printer<'tcx>: Sized { fn default_print_impl_path( self, impl_def_id: DefId, - _substs: &'tcx [Kind<'tcx>], + _substs: &'tcx [GenericArg<'tcx>], self_ty: Ty<'tcx>, impl_trait_ref: Option>, ) -> Result { diff --git a/src/librustc/ty/print/pretty.rs b/src/librustc/ty/print/pretty.rs index a38a00ff5b759..2bc87d6b8ba5e 100644 --- a/src/librustc/ty/print/pretty.rs +++ b/src/librustc/ty/print/pretty.rs @@ -5,7 +5,7 @@ use crate::hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE}; use crate::middle::cstore::{ExternCrate, ExternCrateSource}; use crate::middle::region; use crate::ty::{self, DefIdTree, ParamConst, Ty, TyCtxt, TypeFoldable}; -use crate::ty::subst::{Kind, Subst, UnpackedKind}; +use crate::ty::subst::{GenericArg, Subst, GenericArgKind}; use crate::ty::layout::{Integer, IntegerExt, Size}; use crate::mir::interpret::{ConstValue, sign_extend, Scalar, truncate}; @@ -183,7 +183,7 @@ pub trait PrettyPrinter<'tcx>: fn print_value_path( self, def_id: DefId, - substs: &'tcx [Kind<'tcx>], + substs: &'tcx [GenericArg<'tcx>], ) -> Result { self.print_def_path(def_id, substs) } @@ -764,13 +764,13 @@ pub trait PrettyPrinter<'tcx>: // Don't print `'_` if there's no unerased regions. let print_regions = args.iter().any(|arg| { match arg.unpack() { - UnpackedKind::Lifetime(r) => *r != ty::ReErased, + GenericArgKind::Lifetime(r) => *r != ty::ReErased, _ => false, } }); let mut args = args.iter().cloned().filter(|arg| { match arg.unpack() { - UnpackedKind::Lifetime(_) => print_regions, + GenericArgKind::Lifetime(_) => print_regions, _ => true, } }); @@ -1081,7 +1081,7 @@ impl Printer<'tcx> for FmtPrinter<'_, 'tcx, F> { fn print_def_path( mut self, def_id: DefId, - substs: &'tcx [Kind<'tcx>], + substs: &'tcx [GenericArg<'tcx>], ) -> Result { define_scoped_cx!(self); @@ -1245,20 +1245,20 @@ impl Printer<'tcx> for FmtPrinter<'_, 'tcx, F> { fn path_generic_args( mut self, print_prefix: impl FnOnce(Self) -> Result, - args: &[Kind<'tcx>], + args: &[GenericArg<'tcx>], ) -> Result { self = print_prefix(self)?; // Don't print `'_` if there's no unerased regions. let print_regions = args.iter().any(|arg| { match arg.unpack() { - UnpackedKind::Lifetime(r) => *r != ty::ReErased, + GenericArgKind::Lifetime(r) => *r != ty::ReErased, _ => false, } }); let args = args.iter().cloned().filter(|arg| { match arg.unpack() { - UnpackedKind::Lifetime(_) => print_regions, + GenericArgKind::Lifetime(_) => print_regions, _ => true, } }); @@ -1282,7 +1282,7 @@ impl PrettyPrinter<'tcx> for FmtPrinter<'_, 'tcx, F> { fn print_value_path( mut self, def_id: DefId, - substs: &'tcx [Kind<'tcx>], + substs: &'tcx [GenericArg<'tcx>], ) -> Result { let was_in_value = std::mem::replace(&mut self.in_value, true); self = self.print_def_path(def_id, substs)?; @@ -1778,11 +1778,11 @@ define_print_and_forward_display! { } } - Kind<'tcx> { + GenericArg<'tcx> { match self.unpack() { - UnpackedKind::Lifetime(lt) => p!(print(lt)), - UnpackedKind::Type(ty) => p!(print(ty)), - UnpackedKind::Const(ct) => p!(print(ct)), + GenericArgKind::Lifetime(lt) => p!(print(lt)), + GenericArgKind::Type(ty) => p!(print(ty)), + GenericArgKind::Const(ct) => p!(print(ct)), } } } diff --git a/src/librustc/ty/relate.rs b/src/librustc/ty/relate.rs index d6bd4eeb7367a..2af6963f7122a 100644 --- a/src/librustc/ty/relate.rs +++ b/src/librustc/ty/relate.rs @@ -5,7 +5,7 @@ //! subtyping, type equality, etc. use crate::hir::def_id::DefId; -use crate::ty::subst::{Kind, UnpackedKind, SubstsRef}; +use crate::ty::subst::{GenericArg, GenericArgKind, SubstsRef}; use crate::ty::{self, Ty, TyCtxt, TypeFoldable}; use crate::ty::error::{ExpectedFound, TypeError}; use crate::mir::interpret::{ConstValue, Scalar}; @@ -711,29 +711,29 @@ impl<'tcx, T: Relate<'tcx>> Relate<'tcx> for Box { } } -impl<'tcx> Relate<'tcx> for Kind<'tcx> { +impl<'tcx> Relate<'tcx> for GenericArg<'tcx> { fn relate>( relation: &mut R, - a: &Kind<'tcx>, - b: &Kind<'tcx>, - ) -> RelateResult<'tcx, Kind<'tcx>> { + a: &GenericArg<'tcx>, + b: &GenericArg<'tcx>, + ) -> RelateResult<'tcx, GenericArg<'tcx>> { match (a.unpack(), b.unpack()) { - (UnpackedKind::Lifetime(a_lt), UnpackedKind::Lifetime(b_lt)) => { + (GenericArgKind::Lifetime(a_lt), GenericArgKind::Lifetime(b_lt)) => { Ok(relation.relate(&a_lt, &b_lt)?.into()) } - (UnpackedKind::Type(a_ty), UnpackedKind::Type(b_ty)) => { + (GenericArgKind::Type(a_ty), GenericArgKind::Type(b_ty)) => { Ok(relation.relate(&a_ty, &b_ty)?.into()) } - (UnpackedKind::Const(a_ct), UnpackedKind::Const(b_ct)) => { + (GenericArgKind::Const(a_ct), GenericArgKind::Const(b_ct)) => { Ok(relation.relate(&a_ct, &b_ct)?.into()) } - (UnpackedKind::Lifetime(unpacked), x) => { + (GenericArgKind::Lifetime(unpacked), x) => { bug!("impossible case reached: can't relate: {:?} with {:?}", unpacked, x) } - (UnpackedKind::Type(unpacked), x) => { + (GenericArgKind::Type(unpacked), x) => { bug!("impossible case reached: can't relate: {:?} with {:?}", unpacked, x) } - (UnpackedKind::Const(unpacked), x) => { + (GenericArgKind::Const(unpacked), x) => { bug!("impossible case reached: can't relate: {:?} with {:?}", unpacked, x) } } diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index 6510aea8c256d..91479751ef41d 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -10,7 +10,7 @@ use crate::middle::region; use polonius_engine::Atom; use rustc_data_structures::indexed_vec::Idx; use rustc_macros::HashStable; -use crate::ty::subst::{InternalSubsts, Subst, SubstsRef, Kind, UnpackedKind}; +use crate::ty::subst::{InternalSubsts, Subst, SubstsRef, GenericArg, GenericArgKind}; use crate::ty::{self, AdtDef, Discr, DefIdTree, TypeFlags, Ty, TyCtxt, TypeFoldable}; use crate::ty::{List, TyS, ParamEnvAnd, ParamEnv}; use crate::ty::layout::VariantIdx; @@ -320,7 +320,7 @@ pub struct ClosureSubsts<'tcx> { struct SplitClosureSubsts<'tcx> { closure_kind_ty: Ty<'tcx>, closure_sig_ty: Ty<'tcx>, - upvar_kinds: &'tcx [Kind<'tcx>], + upvar_kinds: &'tcx [GenericArg<'tcx>], } impl<'tcx> ClosureSubsts<'tcx> { @@ -345,7 +345,7 @@ impl<'tcx> ClosureSubsts<'tcx> { ) -> impl Iterator> + 'tcx { let SplitClosureSubsts { upvar_kinds, .. } = self.split(def_id, tcx); upvar_kinds.iter().map(|t| { - if let UnpackedKind::Type(ty) = t.unpack() { + if let GenericArgKind::Type(ty) = t.unpack() { ty } else { bug!("upvar should be type") @@ -402,7 +402,7 @@ struct SplitGeneratorSubsts<'tcx> { yield_ty: Ty<'tcx>, return_ty: Ty<'tcx>, witness: Ty<'tcx>, - upvar_kinds: &'tcx [Kind<'tcx>], + upvar_kinds: &'tcx [GenericArg<'tcx>], } impl<'tcx> GeneratorSubsts<'tcx> { @@ -434,7 +434,7 @@ impl<'tcx> GeneratorSubsts<'tcx> { ) -> impl Iterator> + 'tcx { let SplitGeneratorSubsts { upvar_kinds, .. } = self.split(def_id, tcx); upvar_kinds.iter().map(|t| { - if let UnpackedKind::Type(ty) = t.unpack() { + if let GenericArgKind::Type(ty) = t.unpack() { ty } else { bug!("upvar should be type") @@ -584,7 +584,7 @@ impl<'tcx> UpvarSubsts<'tcx> { UpvarSubsts::Generator(substs) => substs.split(def_id, tcx).upvar_kinds, }; upvar_kinds.iter().map(|t| { - if let UnpackedKind::Type(ty) = t.unpack() { + if let GenericArgKind::Type(ty) = t.unpack() { ty } else { bug!("upvar should be type") diff --git a/src/librustc/ty/subst.rs b/src/librustc/ty/subst.rs index b5debc179e923..e5bee3cfbd06e 100644 --- a/src/librustc/ty/subst.rs +++ b/src/librustc/ty/subst.rs @@ -20,11 +20,11 @@ use std::num::NonZeroUsize; /// An entity in the Rust type system, which can be one of /// several kinds (types, lifetimes, and consts). -/// To reduce memory usage, a `Kind` is a interned pointer, +/// To reduce memory usage, a `GenericArg` is a interned pointer, /// with the lowest 2 bits being reserved for a tag to /// indicate the type (`Ty`, `Region`, or `Const`) it points to. #[derive(Copy, Clone, PartialEq, Eq, Hash)] -pub struct Kind<'tcx> { +pub struct GenericArg<'tcx> { ptr: NonZeroUsize, marker: PhantomData<(Ty<'tcx>, ty::Region<'tcx>, &'tcx ty::Const<'tcx>)> } @@ -35,33 +35,33 @@ const REGION_TAG: usize = 0b01; const CONST_TAG: usize = 0b10; #[derive(Debug, RustcEncodable, RustcDecodable, PartialEq, Eq, PartialOrd, Ord, HashStable)] -pub enum UnpackedKind<'tcx> { +pub enum GenericArgKind<'tcx> { Lifetime(ty::Region<'tcx>), Type(Ty<'tcx>), Const(&'tcx ty::Const<'tcx>), } -impl<'tcx> UnpackedKind<'tcx> { - fn pack(self) -> Kind<'tcx> { +impl<'tcx> GenericArgKind<'tcx> { + fn pack(self) -> GenericArg<'tcx> { let (tag, ptr) = match self { - UnpackedKind::Lifetime(lt) => { + GenericArgKind::Lifetime(lt) => { // Ensure we can use the tag bits. assert_eq!(mem::align_of_val(lt) & TAG_MASK, 0); (REGION_TAG, lt as *const _ as usize) } - UnpackedKind::Type(ty) => { + GenericArgKind::Type(ty) => { // Ensure we can use the tag bits. assert_eq!(mem::align_of_val(ty) & TAG_MASK, 0); (TYPE_TAG, ty as *const _ as usize) } - UnpackedKind::Const(ct) => { + GenericArgKind::Const(ct) => { // Ensure we can use the tag bits. assert_eq!(mem::align_of_val(ct) & TAG_MASK, 0); (CONST_TAG, ct as *const _ as usize) } }; - Kind { + GenericArg { ptr: unsafe { NonZeroUsize::new_unchecked(ptr | tag) }, @@ -70,115 +70,115 @@ impl<'tcx> UnpackedKind<'tcx> { } } -impl fmt::Debug for Kind<'tcx> { +impl fmt::Debug for GenericArg<'tcx> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.unpack() { - UnpackedKind::Lifetime(lt) => lt.fmt(f), - UnpackedKind::Type(ty) => ty.fmt(f), - UnpackedKind::Const(ct) => ct.fmt(f), + GenericArgKind::Lifetime(lt) => lt.fmt(f), + GenericArgKind::Type(ty) => ty.fmt(f), + GenericArgKind::Const(ct) => ct.fmt(f), } } } -impl<'tcx> Ord for Kind<'tcx> { - fn cmp(&self, other: &Kind<'_>) -> Ordering { +impl<'tcx> Ord for GenericArg<'tcx> { + fn cmp(&self, other: &GenericArg<'_>) -> Ordering { self.unpack().cmp(&other.unpack()) } } -impl<'tcx> PartialOrd for Kind<'tcx> { - fn partial_cmp(&self, other: &Kind<'_>) -> Option { +impl<'tcx> PartialOrd for GenericArg<'tcx> { + fn partial_cmp(&self, other: &GenericArg<'_>) -> Option { Some(self.cmp(&other)) } } -impl<'tcx> From> for Kind<'tcx> { - fn from(r: ty::Region<'tcx>) -> Kind<'tcx> { - UnpackedKind::Lifetime(r).pack() +impl<'tcx> From> for GenericArg<'tcx> { + fn from(r: ty::Region<'tcx>) -> GenericArg<'tcx> { + GenericArgKind::Lifetime(r).pack() } } -impl<'tcx> From> for Kind<'tcx> { - fn from(ty: Ty<'tcx>) -> Kind<'tcx> { - UnpackedKind::Type(ty).pack() +impl<'tcx> From> for GenericArg<'tcx> { + fn from(ty: Ty<'tcx>) -> GenericArg<'tcx> { + GenericArgKind::Type(ty).pack() } } -impl<'tcx> From<&'tcx ty::Const<'tcx>> for Kind<'tcx> { - fn from(c: &'tcx ty::Const<'tcx>) -> Kind<'tcx> { - UnpackedKind::Const(c).pack() +impl<'tcx> From<&'tcx ty::Const<'tcx>> for GenericArg<'tcx> { + fn from(c: &'tcx ty::Const<'tcx>) -> GenericArg<'tcx> { + GenericArgKind::Const(c).pack() } } -impl<'tcx> Kind<'tcx> { +impl<'tcx> GenericArg<'tcx> { #[inline] - pub fn unpack(self) -> UnpackedKind<'tcx> { + pub fn unpack(self) -> GenericArgKind<'tcx> { let ptr = self.ptr.get(); unsafe { match ptr & TAG_MASK { - REGION_TAG => UnpackedKind::Lifetime(&*((ptr & !TAG_MASK) as *const _)), - TYPE_TAG => UnpackedKind::Type(&*((ptr & !TAG_MASK) as *const _)), - CONST_TAG => UnpackedKind::Const(&*((ptr & !TAG_MASK) as *const _)), + REGION_TAG => GenericArgKind::Lifetime(&*((ptr & !TAG_MASK) as *const _)), + TYPE_TAG => GenericArgKind::Type(&*((ptr & !TAG_MASK) as *const _)), + CONST_TAG => GenericArgKind::Const(&*((ptr & !TAG_MASK) as *const _)), _ => intrinsics::unreachable() } } } - /// Unpack the `Kind` as a type when it is known certainly to be a type. + /// Unpack the `GenericArg` as a type when it is known certainly to be a type. /// This is true in cases where `Substs` is used in places where the kinds are known /// to be limited (e.g. in tuples, where the only parameters are type parameters). pub fn expect_ty(self) -> Ty<'tcx> { match self.unpack() { - UnpackedKind::Type(ty) => ty, + GenericArgKind::Type(ty) => ty, _ => bug!("expected a type, but found another kind"), } } } -impl<'a, 'tcx> Lift<'tcx> for Kind<'a> { - type Lifted = Kind<'tcx>; +impl<'a, 'tcx> Lift<'tcx> for GenericArg<'a> { + type Lifted = GenericArg<'tcx>; fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { match self.unpack() { - UnpackedKind::Lifetime(lt) => tcx.lift(<).map(|lt| lt.into()), - UnpackedKind::Type(ty) => tcx.lift(&ty).map(|ty| ty.into()), - UnpackedKind::Const(ct) => tcx.lift(&ct).map(|ct| ct.into()), + GenericArgKind::Lifetime(lt) => tcx.lift(<).map(|lt| lt.into()), + GenericArgKind::Type(ty) => tcx.lift(&ty).map(|ty| ty.into()), + GenericArgKind::Const(ct) => tcx.lift(&ct).map(|ct| ct.into()), } } } -impl<'tcx> TypeFoldable<'tcx> for Kind<'tcx> { +impl<'tcx> TypeFoldable<'tcx> for GenericArg<'tcx> { fn super_fold_with>(&self, folder: &mut F) -> Self { match self.unpack() { - UnpackedKind::Lifetime(lt) => lt.fold_with(folder).into(), - UnpackedKind::Type(ty) => ty.fold_with(folder).into(), - UnpackedKind::Const(ct) => ct.fold_with(folder).into(), + GenericArgKind::Lifetime(lt) => lt.fold_with(folder).into(), + GenericArgKind::Type(ty) => ty.fold_with(folder).into(), + GenericArgKind::Const(ct) => ct.fold_with(folder).into(), } } fn super_visit_with>(&self, visitor: &mut V) -> bool { match self.unpack() { - UnpackedKind::Lifetime(lt) => lt.visit_with(visitor), - UnpackedKind::Type(ty) => ty.visit_with(visitor), - UnpackedKind::Const(ct) => ct.visit_with(visitor), + GenericArgKind::Lifetime(lt) => lt.visit_with(visitor), + GenericArgKind::Type(ty) => ty.visit_with(visitor), + GenericArgKind::Const(ct) => ct.visit_with(visitor), } } } -impl<'tcx> Encodable for Kind<'tcx> { +impl<'tcx> Encodable for GenericArg<'tcx> { fn encode(&self, e: &mut E) -> Result<(), E::Error> { self.unpack().encode(e) } } -impl<'tcx> Decodable for Kind<'tcx> { - fn decode(d: &mut D) -> Result, D::Error> { - Ok(UnpackedKind::decode(d)?.pack()) +impl<'tcx> Decodable for GenericArg<'tcx> { + fn decode(d: &mut D) -> Result, D::Error> { + Ok(GenericArgKind::decode(d)?.pack()) } } /// A substitution mapping generic parameters to new values. -pub type InternalSubsts<'tcx> = List>; +pub type InternalSubsts<'tcx> = List>; pub type SubstsRef<'tcx> = &'tcx InternalSubsts<'tcx>; @@ -232,7 +232,7 @@ impl<'a, 'tcx> InternalSubsts<'tcx> { /// substitute defaults of generic parameters. pub fn for_item(tcx: TyCtxt<'tcx>, def_id: DefId, mut mk_kind: F) -> SubstsRef<'tcx> where - F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Kind<'tcx>, + F: FnMut(&ty::GenericParamDef, &[GenericArg<'tcx>]) -> GenericArg<'tcx>, { let defs = tcx.generics_of(def_id); let count = defs.count(); @@ -243,7 +243,7 @@ impl<'a, 'tcx> InternalSubsts<'tcx> { pub fn extend_to(&self, tcx: TyCtxt<'tcx>, def_id: DefId, mut mk_kind: F) -> SubstsRef<'tcx> where - F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Kind<'tcx>, + F: FnMut(&ty::GenericParamDef, &[GenericArg<'tcx>]) -> GenericArg<'tcx>, { Self::for_item(tcx, def_id, |param, substs| { self.get(param.index as usize) @@ -253,12 +253,12 @@ impl<'a, 'tcx> InternalSubsts<'tcx> { } fn fill_item( - substs: &mut SmallVec<[Kind<'tcx>; 8]>, + substs: &mut SmallVec<[GenericArg<'tcx>; 8]>, tcx: TyCtxt<'tcx>, defs: &ty::Generics, mk_kind: &mut F, ) where - F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Kind<'tcx>, + F: FnMut(&ty::GenericParamDef, &[GenericArg<'tcx>]) -> GenericArg<'tcx>, { if let Some(def_id) = defs.parent { let parent_defs = tcx.generics_of(def_id); @@ -267,10 +267,10 @@ impl<'a, 'tcx> InternalSubsts<'tcx> { Self::fill_single(substs, defs, mk_kind) } - fn fill_single(substs: &mut SmallVec<[Kind<'tcx>; 8]>, + fn fill_single(substs: &mut SmallVec<[GenericArg<'tcx>; 8]>, defs: &ty::Generics, mk_kind: &mut F) - where F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Kind<'tcx> + where F: FnMut(&ty::GenericParamDef, &[GenericArg<'tcx>]) -> GenericArg<'tcx> { substs.reserve(defs.params.len()); for param in &defs.params { @@ -287,7 +287,7 @@ impl<'a, 'tcx> InternalSubsts<'tcx> { #[inline] pub fn types(&'a self) -> impl DoubleEndedIterator> + 'a { self.iter().filter_map(|k| { - if let UnpackedKind::Type(ty) = k.unpack() { + if let GenericArgKind::Type(ty) = k.unpack() { Some(ty) } else { None @@ -298,7 +298,7 @@ impl<'a, 'tcx> InternalSubsts<'tcx> { #[inline] pub fn regions(&'a self) -> impl DoubleEndedIterator> + 'a { self.iter().filter_map(|k| { - if let UnpackedKind::Lifetime(lt) = k.unpack() { + if let GenericArgKind::Lifetime(lt) = k.unpack() { Some(lt) } else { None @@ -309,7 +309,7 @@ impl<'a, 'tcx> InternalSubsts<'tcx> { #[inline] pub fn consts(&'a self) -> impl DoubleEndedIterator> + 'a { self.iter().filter_map(|k| { - if let UnpackedKind::Const(ct) = k.unpack() { + if let GenericArgKind::Const(ct) = k.unpack() { Some(ct) } else { None @@ -320,10 +320,10 @@ impl<'a, 'tcx> InternalSubsts<'tcx> { #[inline] pub fn non_erasable_generics( &'a self - ) -> impl DoubleEndedIterator> + 'a { + ) -> impl DoubleEndedIterator> + 'a { self.iter().filter_map(|k| { match k.unpack() { - UnpackedKind::Lifetime(_) => None, + GenericArgKind::Lifetime(_) => None, generic => Some(generic), } }) @@ -331,7 +331,7 @@ impl<'a, 'tcx> InternalSubsts<'tcx> { #[inline] pub fn type_at(&self, i: usize) -> Ty<'tcx> { - if let UnpackedKind::Type(ty) = self[i].unpack() { + if let GenericArgKind::Type(ty) = self[i].unpack() { ty } else { bug!("expected type for param #{} in {:?}", i, self); @@ -340,7 +340,7 @@ impl<'a, 'tcx> InternalSubsts<'tcx> { #[inline] pub fn region_at(&self, i: usize) -> ty::Region<'tcx> { - if let UnpackedKind::Lifetime(lt) = self[i].unpack() { + if let GenericArgKind::Lifetime(lt) = self[i].unpack() { lt } else { bug!("expected region for param #{} in {:?}", i, self); @@ -349,7 +349,7 @@ impl<'a, 'tcx> InternalSubsts<'tcx> { #[inline] pub fn const_at(&self, i: usize) -> &'tcx ty::Const<'tcx> { - if let UnpackedKind::Const(ct) = self[i].unpack() { + if let GenericArgKind::Const(ct) = self[i].unpack() { ct } else { bug!("expected const for param #{} in {:?}", i, self); @@ -357,7 +357,7 @@ impl<'a, 'tcx> InternalSubsts<'tcx> { } #[inline] - pub fn type_for_def(&self, def: &ty::GenericParamDef) -> Kind<'tcx> { + pub fn type_for_def(&self, def: &ty::GenericParamDef) -> GenericArg<'tcx> { self.type_at(def.index as usize).into() } @@ -409,15 +409,25 @@ impl<'tcx> rustc_serialize::UseSpecializedDecodable for SubstsRef<'tcx> {} // there is more information available (for better errors). pub trait Subst<'tcx>: Sized { - fn subst(&self, tcx: TyCtxt<'tcx>, substs: &[Kind<'tcx>]) -> Self { + fn subst(&self, tcx: TyCtxt<'tcx>, substs: &[GenericArg<'tcx>]) -> Self { self.subst_spanned(tcx, substs, None) } - fn subst_spanned(&self, tcx: TyCtxt<'tcx>, substs: &[Kind<'tcx>], span: Option) -> Self; + fn subst_spanned( + &self, + tcx: TyCtxt<'tcx>, + substs: &[GenericArg<'tcx>], + span: Option, + ) -> Self; } impl<'tcx, T: TypeFoldable<'tcx>> Subst<'tcx> for T { - fn subst_spanned(&self, tcx: TyCtxt<'tcx>, substs: &[Kind<'tcx>], span: Option) -> T { + fn subst_spanned( + &self, + tcx: TyCtxt<'tcx>, + substs: &[GenericArg<'tcx>], + span: Option, + ) -> T { let mut folder = SubstFolder { tcx, substs, span, @@ -433,7 +443,7 @@ impl<'tcx, T: TypeFoldable<'tcx>> Subst<'tcx> for T { struct SubstFolder<'a, 'tcx> { tcx: TyCtxt<'tcx>, - substs: &'a [Kind<'tcx>], + substs: &'a [GenericArg<'tcx>], /// The location for which the substitution is performed, if available. span: Option, @@ -468,7 +478,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> { ty::ReEarlyBound(data) => { let rk = self.substs.get(data.index as usize).map(|k| k.unpack()); match rk { - Some(UnpackedKind::Lifetime(lt)) => { + Some(GenericArgKind::Lifetime(lt)) => { self.shift_region_through_binders(lt) } _ => { @@ -537,7 +547,7 @@ impl<'a, 'tcx> SubstFolder<'a, 'tcx> { // Look up the type in the substitutions. It really should be in there. let opt_ty = self.substs.get(p.index as usize).map(|k| k.unpack()); let ty = match opt_ty { - Some(UnpackedKind::Type(ty)) => ty, + Some(GenericArgKind::Type(ty)) => ty, Some(kind) => { let span = self.span.unwrap_or(DUMMY_SP); span_bug!( @@ -578,7 +588,7 @@ impl<'a, 'tcx> SubstFolder<'a, 'tcx> { // Look up the const in the substitutions. It really should be in there. let opt_ct = self.substs.get(p.index as usize).map(|k| k.unpack()); let ct = match opt_ct { - Some(UnpackedKind::Const(ct)) => ct, + Some(GenericArgKind::Const(ct)) => ct, Some(kind) => { let span = self.span.unwrap_or(DUMMY_SP); span_bug!( diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index 714ebf4c42ff8..c4d8e452441cb 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -8,7 +8,7 @@ use crate::mir::interpret::{sign_extend, truncate}; use crate::ich::NodeIdHashingMode; use crate::traits::{self, ObligationCause}; use crate::ty::{self, DefIdTree, Ty, TyCtxt, GenericParamDefKind, TypeFoldable}; -use crate::ty::subst::{Subst, InternalSubsts, SubstsRef, UnpackedKind}; +use crate::ty::subst::{Subst, InternalSubsts, SubstsRef, GenericArgKind}; use crate::ty::query::TyCtxtAt; use crate::ty::TyKind::*; use crate::ty::layout::{Integer, IntegerExt}; @@ -510,7 +510,7 @@ impl<'tcx> TyCtxt<'tcx> { /// destructor of `def` itself. For the destructors of the /// contents, you need `adt_dtorck_constraint`. pub fn destructor_constraints(self, def: &'tcx ty::AdtDef) - -> Vec> + -> Vec> { let dtor = match def.destructor(self) { None => { @@ -557,23 +557,23 @@ impl<'tcx> TyCtxt<'tcx> { let result = item_substs.iter().zip(impl_substs.iter()) .filter(|&(_, &k)| { match k.unpack() { - UnpackedKind::Lifetime(&ty::RegionKind::ReEarlyBound(ref ebr)) => { + GenericArgKind::Lifetime(&ty::RegionKind::ReEarlyBound(ref ebr)) => { !impl_generics.region_param(ebr, self).pure_wrt_drop } - UnpackedKind::Type(&ty::TyS { + GenericArgKind::Type(&ty::TyS { kind: ty::Param(ref pt), .. }) => { !impl_generics.type_param(pt, self).pure_wrt_drop } - UnpackedKind::Const(&ty::Const { + GenericArgKind::Const(&ty::Const { val: ConstValue::Param(ref pc), .. }) => { !impl_generics.const_param(pc, self).pure_wrt_drop } - UnpackedKind::Lifetime(_) | - UnpackedKind::Type(_) | - UnpackedKind::Const(_) => { + GenericArgKind::Lifetime(_) | + GenericArgKind::Type(_) | + GenericArgKind::Const(_) => { // Not a type, const or region param: this should be reported // as an error. false diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs index 02d68f47c7e7d..1696e56c01eff 100644 --- a/src/librustc_codegen_llvm/debuginfo/metadata.rs +++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs @@ -30,7 +30,7 @@ use rustc::ty::Instance; use rustc::ty::{self, AdtKind, ParamEnv, Ty, TyCtxt}; use rustc::ty::layout::{self, Align, Integer, IntegerExt, LayoutOf, PrimitiveExt, Size, TyLayout, VariantIdx}; -use rustc::ty::subst::UnpackedKind; +use rustc::ty::subst::GenericArgKind; use rustc::session::config::{self, DebugInfo}; use rustc::util::nodemap::FxHashMap; use rustc_fs_util::path_to_c_string; @@ -2096,7 +2096,7 @@ fn compute_type_parameters(cx: &CodegenCx<'ll, 'tcx>, ty: Ty<'tcx>) -> Option<&' let generics = cx.tcx.generics_of(def.did); let names = get_parameter_names(cx, generics); let template_params: Vec<_> = substs.iter().zip(names).filter_map(|(kind, name)| { - if let UnpackedKind::Type(ty) = kind.unpack() { + if let GenericArgKind::Type(ty) = kind.unpack() { let actual_type = cx.tcx.normalize_erasing_regions(ParamEnv::reveal_all(), ty); let actual_type_metadata = type_metadata(cx, actual_type, syntax_pos::DUMMY_SP); diff --git a/src/librustc_codegen_llvm/debuginfo/mod.rs b/src/librustc_codegen_llvm/debuginfo/mod.rs index 08a37ce9bbfc8..4efa1993d4322 100644 --- a/src/librustc_codegen_llvm/debuginfo/mod.rs +++ b/src/librustc_codegen_llvm/debuginfo/mod.rs @@ -15,7 +15,7 @@ use crate::llvm::debuginfo::{DIFile, DIType, DIScope, DIBuilder, DISubprogram, D DISPFlags, DILexicalBlock}; use rustc::hir::CodegenFnAttrFlags; use rustc::hir::def_id::{DefId, CrateNum, LOCAL_CRATE}; -use rustc::ty::subst::{SubstsRef, UnpackedKind}; +use rustc::ty::subst::{SubstsRef, GenericArgKind}; use crate::abi::Abi; use crate::common::CodegenCx; @@ -460,7 +460,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { let template_params: Vec<_> = if cx.sess().opts.debuginfo == DebugInfo::Full { let names = get_parameter_names(cx, generics); substs.iter().zip(names).filter_map(|(kind, name)| { - if let UnpackedKind::Type(ty) = kind.unpack() { + if let GenericArgKind::Type(ty) = kind.unpack() { let actual_type = cx.tcx.normalize_erasing_regions(ParamEnv::reveal_all(), ty); let actual_type_metadata = diff --git a/src/librustc_codegen_utils/symbol_names/legacy.rs b/src/librustc_codegen_utils/symbol_names/legacy.rs index 1b094e26c2443..277aa2db33a1b 100644 --- a/src/librustc_codegen_utils/symbol_names/legacy.rs +++ b/src/librustc_codegen_utils/symbol_names/legacy.rs @@ -3,7 +3,7 @@ use rustc::hir::map::{DefPathData, DisambiguatedDefPathData}; use rustc::ich::NodeIdHashingMode; use rustc::mir::interpret::{ConstValue, Scalar}; use rustc::ty::print::{PrettyPrinter, Printer, Print}; -use rustc::ty::subst::{Kind, UnpackedKind}; +use rustc::ty::subst::{GenericArg, GenericArgKind}; use rustc::ty::{self, Ty, TyCtxt, TypeFoldable, Instance}; use rustc::util::common::record_time; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; @@ -341,13 +341,13 @@ impl Printer<'tcx> for SymbolPrinter<'tcx> { fn path_generic_args( mut self, print_prefix: impl FnOnce(Self) -> Result, - args: &[Kind<'tcx>], + args: &[GenericArg<'tcx>], ) -> Result { self = print_prefix(self)?; let args = args.iter().cloned().filter(|arg| { match arg.unpack() { - UnpackedKind::Lifetime(_) => false, + GenericArgKind::Lifetime(_) => false, _ => true, } }); diff --git a/src/librustc_codegen_utils/symbol_names/v0.rs b/src/librustc_codegen_utils/symbol_names/v0.rs index f1f5913425d01..a63236305dc11 100644 --- a/src/librustc_codegen_utils/symbol_names/v0.rs +++ b/src/librustc_codegen_utils/symbol_names/v0.rs @@ -3,7 +3,7 @@ use rustc::hir::def_id::{CrateNum, DefId}; use rustc::hir::map::{DefPathData, DisambiguatedDefPathData}; use rustc::ty::{self, Ty, TyCtxt, TypeFoldable, Instance}; use rustc::ty::print::{Printer, Print}; -use rustc::ty::subst::{Kind, Subst, UnpackedKind}; +use rustc::ty::subst::{GenericArg, Subst, GenericArgKind}; use rustc_data_structures::base_n; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_target::spec::abi::Abi; @@ -56,7 +56,7 @@ struct CompressionCaches<'tcx> { start_offset: usize, // The values are start positions in `out`, in bytes. - paths: FxHashMap<(DefId, &'tcx [Kind<'tcx>]), usize>, + paths: FxHashMap<(DefId, &'tcx [GenericArg<'tcx>]), usize>, types: FxHashMap, usize>, consts: FxHashMap<&'tcx ty::Const<'tcx>, usize>, } @@ -234,7 +234,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> { fn print_def_path( mut self, def_id: DefId, - substs: &'tcx [Kind<'tcx>], + substs: &'tcx [GenericArg<'tcx>], ) -> Result { if let Some(&i) = self.compress.as_ref().and_then(|c| c.paths.get(&(def_id, substs))) { return self.print_backref(i); @@ -256,7 +256,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> { fn print_impl_path( self, impl_def_id: DefId, - substs: &'tcx [Kind<'tcx>], + substs: &'tcx [GenericArg<'tcx>], mut self_ty: Ty<'tcx>, mut impl_trait_ref: Option>, ) -> Result { @@ -619,18 +619,18 @@ impl Printer<'tcx> for SymbolMangler<'tcx> { fn path_generic_args( mut self, print_prefix: impl FnOnce(Self) -> Result, - args: &[Kind<'tcx>], + args: &[GenericArg<'tcx>], ) -> Result { // Don't print any regions if they're all erased. let print_regions = args.iter().any(|arg| { match arg.unpack() { - UnpackedKind::Lifetime(r) => *r != ty::ReErased, + GenericArgKind::Lifetime(r) => *r != ty::ReErased, _ => false, } }); let args = args.iter().cloned().filter(|arg| { match arg.unpack() { - UnpackedKind::Lifetime(_) => print_regions, + GenericArgKind::Lifetime(_) => print_regions, _ => true, } }); @@ -643,13 +643,13 @@ impl Printer<'tcx> for SymbolMangler<'tcx> { self = print_prefix(self)?; for arg in args { match arg.unpack() { - UnpackedKind::Lifetime(lt) => { + GenericArgKind::Lifetime(lt) => { self = lt.print(self)?; } - UnpackedKind::Type(ty) => { + GenericArgKind::Type(ty) => { self = ty.print(self)?; } - UnpackedKind::Const(c) => { + GenericArgKind::Const(c) => { self.push("K"); // FIXME(const_generics) implement `ty::print::Print` on `ty::Const`. // self = c.print(self)?; diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs index ff77083a34dfa..90e5480d2fb79 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs @@ -12,7 +12,7 @@ use rustc::hir::def::{Res, DefKind}; use rustc::hir::def_id::DefId; use rustc::infer::InferCtxt; use rustc::mir::Body; -use rustc::ty::subst::{SubstsRef, UnpackedKind}; +use rustc::ty::subst::{SubstsRef, GenericArgKind}; use rustc::ty::{self, RegionKind, RegionVid, Ty, TyCtxt}; use rustc::ty::print::RegionHighlightMode; use rustc_errors::DiagnosticBuilder; @@ -667,24 +667,24 @@ impl<'tcx> RegionInferenceContext<'tcx> { ) -> Option<&'hir hir::Lifetime> { for (kind, hir_arg) in substs.iter().zip(&args.args) { match (kind.unpack(), hir_arg) { - (UnpackedKind::Lifetime(r), hir::GenericArg::Lifetime(lt)) => { + (GenericArgKind::Lifetime(r), hir::GenericArg::Lifetime(lt)) => { if r.to_region_vid() == needle_fr { return Some(lt); } } - (UnpackedKind::Type(ty), hir::GenericArg::Type(hir_ty)) => { + (GenericArgKind::Type(ty), hir::GenericArg::Type(hir_ty)) => { search_stack.push((ty, hir_ty)); } - (UnpackedKind::Const(_ct), hir::GenericArg::Const(_hir_ct)) => { + (GenericArgKind::Const(_ct), hir::GenericArg::Const(_hir_ct)) => { // Lifetimes cannot be found in consts, so we don't need // to search anything here. } - (UnpackedKind::Lifetime(_), _) - | (UnpackedKind::Type(_), _) - | (UnpackedKind::Const(_), _) => { + (GenericArgKind::Lifetime(_), _) + | (GenericArgKind::Type(_), _) + | (GenericArgKind::Const(_), _) => { // I *think* that HIR lowering should ensure this // doesn't happen, even in erroneous // programs. Else we should use delay-span-bug. diff --git a/src/librustc_mir/borrow_check/nll/type_check/constraint_conversion.rs b/src/librustc_mir/borrow_check/nll/type_check/constraint_conversion.rs index 8de014522dea7..c88f1cac35040 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/constraint_conversion.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/constraint_conversion.rs @@ -10,7 +10,7 @@ use rustc::infer::outlives::obligations::{TypeOutlives, TypeOutlivesDelegate}; use rustc::infer::region_constraints::{GenericKind, VerifyBound}; use rustc::infer::{self, InferCtxt, SubregionOrigin}; use rustc::mir::ConstraintCategory; -use rustc::ty::subst::UnpackedKind; +use rustc::ty::subst::GenericArgKind; use rustc::ty::{self, TyCtxt}; use syntax_pos::DUMMY_SP; @@ -101,13 +101,13 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> { }); match k1.unpack() { - UnpackedKind::Lifetime(r1) => { + GenericArgKind::Lifetime(r1) => { let r1_vid = self.to_region_vid(r1); let r2_vid = self.to_region_vid(r2); self.add_outlives(r1_vid, r2_vid); } - UnpackedKind::Type(t1) => { + GenericArgKind::Type(t1) => { // we don't actually use this for anything, but // the `TypeOutlives` code needs an origin. let origin = infer::RelateParamBound(DUMMY_SP, t1); @@ -121,7 +121,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> { ).type_must_outlive(origin, t1, r2); } - UnpackedKind::Const(_) => { + GenericArgKind::Const(_) => { // Consts cannot outlive one another, so we // don't need to handle any relations here. } diff --git a/src/librustc_mir/borrow_check/nll/type_check/liveness/polonius.rs b/src/librustc_mir/borrow_check/nll/type_check/liveness/polonius.rs index d61464b3f387d..e37ddbda4be02 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/liveness/polonius.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/liveness/polonius.rs @@ -4,7 +4,7 @@ use crate::dataflow::move_paths::{LookupResult, MoveData}; use crate::util::liveness::{categorize, DefUse}; use rustc::mir::visit::{MutatingUseContext, PlaceContext, Visitor}; use rustc::mir::{Body, Local, Location, Place}; -use rustc::ty::subst::Kind; +use rustc::ty::subst::GenericArg; use rustc::ty::Ty; use super::TypeChecker; @@ -125,7 +125,7 @@ pub(super) fn populate_access_facts( pub(super) fn add_var_drops_regions( typeck: &mut TypeChecker<'_, 'tcx>, local: Local, - kind: &Kind<'tcx>, + kind: &GenericArg<'tcx>, ) { debug!("add_var_drops_region(local={:?}, kind={:?}", local, kind); let tcx = typeck.tcx(); diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs index eadc58cc80027..e3e509799c936 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs @@ -36,7 +36,7 @@ use rustc::traits::query::{Fallible, NoSolution}; use rustc::traits::{self, ObligationCause, PredicateObligations}; use rustc::ty::adjustment::{PointerCast}; use rustc::ty::fold::TypeFoldable; -use rustc::ty::subst::{Subst, SubstsRef, UnpackedKind, UserSubsts}; +use rustc::ty::subst::{Subst, SubstsRef, GenericArgKind, UserSubsts}; use rustc::ty::{ self, RegionVid, ToPolyTraitRef, Ty, TyCtxt, UserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, @@ -2575,7 +2575,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { }); match k1.unpack() { - UnpackedKind::Lifetime(r1) => { + GenericArgKind::Lifetime(r1) => { // constraint is r1: r2 let r1_vid = self.borrowck_context.universal_regions.to_region_vid(r1); let r2_vid = self.borrowck_context.universal_regions.to_region_vid(r2); @@ -2589,7 +2589,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { ), )) } - UnpackedKind::Type(_) | UnpackedKind::Const(_) => None, + GenericArgKind::Type(_) | GenericArgKind::Const(_) => None, } }) .collect(); diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs index 740dc2011cab1..676827d3b3eba 100644 --- a/src/librustc_mir/hair/cx/mod.rs +++ b/src/librustc_mir/hair/cx/mod.rs @@ -12,7 +12,7 @@ use rustc::middle::region; use rustc::infer::InferCtxt; use rustc::ty::subst::Subst; use rustc::ty::{self, Ty, TyCtxt}; -use rustc::ty::subst::{Kind, InternalSubsts}; +use rustc::ty::subst::{GenericArg, InternalSubsts}; use rustc::ty::layout::VariantIdx; use syntax::ast; use syntax::attr; @@ -169,7 +169,7 @@ impl<'a, 'tcx> Cx<'a, 'tcx> { trait_def_id: DefId, method_name: Symbol, self_ty: Ty<'tcx>, - params: &[Kind<'tcx>]) + params: &[GenericArg<'tcx>]) -> &'tcx ty::Const<'tcx> { let substs = self.tcx.mk_substs_trait(self_ty, params); for item in self.tcx.associated_items(trait_def_id) { diff --git a/src/librustc_mir/hair/pattern/mod.rs b/src/librustc_mir/hair/pattern/mod.rs index 162251bf76e7f..e42f6125f21d9 100644 --- a/src/librustc_mir/hair/pattern/mod.rs +++ b/src/librustc_mir/hair/pattern/mod.rs @@ -17,7 +17,7 @@ use rustc::mir::interpret::{GlobalId, ConstValue, sign_extend, AllocId, Pointer} use rustc::traits::{ObligationCause, PredicateObligation}; use rustc::ty::{self, Region, TyCtxt, AdtDef, Ty, UserType, DefIdTree}; use rustc::ty::{CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations}; -use rustc::ty::subst::{SubstsRef, Kind}; +use rustc::ty::subst::{SubstsRef, GenericArg}; use rustc::ty::layout::{VariantIdx, Size}; use rustc::hir::{self, PatKind, RangeEnd}; use rustc::hir::def::{CtorOf, Res, DefKind, CtorKind}; @@ -1357,7 +1357,7 @@ macro_rules! CloneImpls { CloneImpls!{ <'tcx> Span, Field, Mutability, ast::Name, hir::HirId, usize, ty::Const<'tcx>, Region<'tcx>, Ty<'tcx>, BindingMode, &'tcx AdtDef, - SubstsRef<'tcx>, &'tcx Kind<'tcx>, UserType<'tcx>, + SubstsRef<'tcx>, &'tcx GenericArg<'tcx>, UserType<'tcx>, UserTypeProjection, PatternTypeProjection<'tcx> } diff --git a/src/librustc_mir/interpret/intrinsics/type_name.rs b/src/librustc_mir/interpret/intrinsics/type_name.rs index a6b3b4e0ff67d..a8b4d65e7d4b0 100644 --- a/src/librustc_mir/interpret/intrinsics/type_name.rs +++ b/src/librustc_mir/interpret/intrinsics/type_name.rs @@ -1,6 +1,6 @@ use rustc::ty::{ TyCtxt, Ty, - subst::{UnpackedKind, Kind}, + subst::{GenericArgKind, GenericArg}, print::{Printer, PrettyPrinter, Print}, self, }; @@ -156,12 +156,12 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> { fn path_generic_args( mut self, print_prefix: impl FnOnce(Self) -> Result, - args: &[Kind<'tcx>], + args: &[GenericArg<'tcx>], ) -> Result { self = print_prefix(self)?; let args = args.iter().cloned().filter(|arg| { match arg.unpack() { - UnpackedKind::Lifetime(_) => false, + GenericArgKind::Lifetime(_) => false, _ => true, } }); diff --git a/src/librustc_traits/chalk_context/mod.rs b/src/librustc_traits/chalk_context/mod.rs index fe66b1932d5e8..06c1df70287c9 100644 --- a/src/librustc_traits/chalk_context/mod.rs +++ b/src/librustc_traits/chalk_context/mod.rs @@ -36,7 +36,7 @@ use rustc::traits::{ use rustc::ty::{self, TyCtxt, InferConst}; use rustc::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; use rustc::ty::query::Providers; -use rustc::ty::subst::{Kind, UnpackedKind}; +use rustc::ty::subst::{GenericArg, GenericArgKind}; use rustc::mir::interpret::ConstValue; use syntax_pos::DUMMY_SP; @@ -64,7 +64,7 @@ crate struct ChalkInferenceContext<'cx, 'tcx> { #[derive(Copy, Clone, Debug)] crate struct UniverseMap; -crate type RegionConstraint<'tcx> = ty::OutlivesPredicate, ty::Region<'tcx>>; +crate type RegionConstraint<'tcx> = ty::OutlivesPredicate, ty::Region<'tcx>>; #[derive(Clone, Debug, PartialEq, Eq, Hash)] crate struct ConstrainedSubst<'tcx> { @@ -109,7 +109,7 @@ impl context::Context for ChalkArenas<'tcx> { type BindersGoal = ty::Binder>; - type Parameter = Kind<'tcx>; + type Parameter = GenericArg<'tcx>; type ProgramClause = Clause<'tcx>; @@ -271,21 +271,21 @@ impl context::ContextOps> for ChalkContext<'tcx> { subst.var_values .iter_enumerated() .all(|(cvar, kind)| match kind.unpack() { - UnpackedKind::Lifetime(r) => match r { + GenericArgKind::Lifetime(r) => match r { &ty::ReLateBound(debruijn, br) => { debug_assert_eq!(debruijn, ty::INNERMOST); cvar == br.assert_bound_var() } _ => false, }, - UnpackedKind::Type(ty) => match ty.kind { + GenericArgKind::Type(ty) => match ty.kind { ty::Bound(debruijn, bound_ty) => { debug_assert_eq!(debruijn, ty::INNERMOST); cvar == bound_ty.var } _ => false, }, - UnpackedKind::Const(ct) => match ct.val { + GenericArgKind::Const(ct) => match ct.val { ConstValue::Infer(InferConst::Canonical(debruijn, bound_ct)) => { debug_assert_eq!(debruijn, ty::INNERMOST); cvar == bound_ct @@ -454,8 +454,8 @@ impl context::UnificationOps, ChalkArenas<'tcx>> &mut self, environment: &Environment<'tcx>, variance: ty::Variance, - a: &Kind<'tcx>, - b: &Kind<'tcx>, + a: &GenericArg<'tcx>, + b: &GenericArg<'tcx>, ) -> Fallible> { self.infcx.commit_if_ok(|_| { unify(self.infcx, *environment, variance, a, b) diff --git a/src/librustc_traits/chalk_context/program_clauses/builtin.rs b/src/librustc_traits/chalk_context/program_clauses/builtin.rs index cc5ca3d92c9c1..6790f14f69bbd 100644 --- a/src/librustc_traits/chalk_context/program_clauses/builtin.rs +++ b/src/librustc_traits/chalk_context/program_clauses/builtin.rs @@ -5,7 +5,7 @@ use rustc::traits::{ ProgramClauseCategory, }; use rustc::ty::{self, Ty, TyCtxt}; -use rustc::ty::subst::{Kind, InternalSubsts, Subst}; +use rustc::ty::subst::{GenericArg, InternalSubsts, Subst}; use rustc::hir; use rustc::hir::def_id::DefId; use crate::lowering::Lower; @@ -17,7 +17,7 @@ use crate::generic_types; fn builtin_impl_clause( tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, - nested: &[Kind<'tcx>], + nested: &[GenericArg<'tcx>], trait_def_id: DefId, ) -> ProgramClause<'tcx> { ProgramClause { @@ -124,7 +124,7 @@ crate fn assemble_builtin_sized_impls<'tcx>( ty: Ty<'tcx>, clauses: &mut Vec>, ) { - let mut push_builtin_impl = |ty: Ty<'tcx>, nested: &[Kind<'tcx>]| { + let mut push_builtin_impl = |ty: Ty<'tcx>, nested: &[GenericArg<'tcx>]| { let clause = builtin_impl_clause(tcx, ty, nested, sized_def_id); // Bind innermost bound vars that may exist in `ty` and `nested`. clauses.push(Clause::ForAll(ty::Binder::bind(clause))); @@ -185,7 +185,7 @@ crate fn assemble_builtin_sized_impls<'tcx>( let adt = tcx.mk_ty(ty::Adt(adt_def, substs)); let sized_constraint = adt_def.sized_constraint(tcx) .iter() - .map(|ty| Kind::from(ty.subst(tcx, substs))) + .map(|ty| GenericArg::from(ty.subst(tcx, substs))) .collect::>(); push_builtin_impl(adt, &sized_constraint); } @@ -228,7 +228,7 @@ crate fn assemble_builtin_copy_clone_impls<'tcx>( ty: Ty<'tcx>, clauses: &mut Vec>, ) { - let mut push_builtin_impl = |ty: Ty<'tcx>, nested: &[Kind<'tcx>]| { + let mut push_builtin_impl = |ty: Ty<'tcx>, nested: &[GenericArg<'tcx>]| { let clause = builtin_impl_clause(tcx, ty, nested, trait_def_id); // Bind innermost bound vars that may exist in `ty` and `nested`. clauses.push(Clause::ForAll(ty::Binder::bind(clause))); @@ -255,7 +255,7 @@ crate fn assemble_builtin_copy_clone_impls<'tcx>( let element_ty = generic_types::bound(tcx, 0); push_builtin_impl( tcx.mk_ty(ty::Array(element_ty, length)), - &[Kind::from(element_ty)], + &[GenericArg::from(element_ty)], ); } &ty::Tuple(type_list) => { @@ -266,7 +266,7 @@ crate fn assemble_builtin_copy_clone_impls<'tcx>( let closure_ty = generic_types::closure(tcx, def_id); let upvar_tys: Vec<_> = match &closure_ty.kind { ty::Closure(_, substs) => { - substs.upvar_tys(def_id, tcx).map(|ty| Kind::from(ty)).collect() + substs.upvar_tys(def_id, tcx).map(|ty| GenericArg::from(ty)).collect() }, _ => bug!(), }; diff --git a/src/librustc_traits/chalk_context/resolvent_ops.rs b/src/librustc_traits/chalk_context/resolvent_ops.rs index a871ad4b160e9..8facec1e9e35f 100644 --- a/src/librustc_traits/chalk_context/resolvent_ops.rs +++ b/src/librustc_traits/chalk_context/resolvent_ops.rs @@ -17,7 +17,7 @@ use rustc::traits::{ InEnvironment, }; use rustc::ty::{self, Ty, TyCtxt, InferConst}; -use rustc::ty::subst::Kind; +use rustc::ty::subst::GenericArg; use rustc::ty::relate::{Relate, RelateResult, TypeRelation}; use rustc::mir::interpret::ConstValue; use syntax_pos::DUMMY_SP; @@ -151,7 +151,7 @@ impl AnswerSubstitutor<'cx, 'tcx> { fn unify_free_answer_var( &mut self, answer_var: ty::BoundVar, - pending: Kind<'tcx> + pending: GenericArg<'tcx> ) -> RelateResult<'tcx, ()> { let answer_param = &self.answer_subst.var_values[answer_var]; let pending = &ty::fold::shift_out_vars( diff --git a/src/librustc_traits/generic_types.rs b/src/librustc_traits/generic_types.rs index bd2ed94b18d59..e4d15a35137cc 100644 --- a/src/librustc_traits/generic_types.rs +++ b/src/librustc_traits/generic_types.rs @@ -1,7 +1,7 @@ //! Utilities for creating generic types with bound vars in place of parameter values. use rustc::ty::{self, Ty, TyCtxt}; -use rustc::ty::subst::{Kind, SubstsRef, InternalSubsts}; +use rustc::ty::subst::{GenericArg, SubstsRef, InternalSubsts}; use rustc::hir; use rustc::hir::def_id::DefId; use rustc_target::spec::abi; @@ -49,7 +49,7 @@ crate fn type_list(tcx: TyCtxt<'tcx>, arity: usize) -> SubstsRef<'tcx> { (0..arity).into_iter() .map(|i| ty::BoundVar::from(i)) .map(|var| tcx.mk_ty(ty::Bound(ty::INNERMOST, var.into()))) - .map(|ty| Kind::from(ty)) + .map(|ty| GenericArg::from(ty)) ) } diff --git a/src/librustc_traits/type_op.rs b/src/librustc_traits/type_op.rs index cb30eba5b0505..fa36908a1612b 100644 --- a/src/librustc_traits/type_op.rs +++ b/src/librustc_traits/type_op.rs @@ -13,7 +13,7 @@ use rustc::traits::{ Normalized, Obligation, ObligationCause, TraitEngine, TraitEngineExt, }; use rustc::ty::query::Providers; -use rustc::ty::subst::{Kind, Subst, UserSubsts, UserSelfTy}; +use rustc::ty::subst::{GenericArg, Subst, UserSubsts, UserSelfTy}; use rustc::ty::{ FnSig, Lift, ParamEnv, ParamEnvAnd, PolyFnSig, Predicate, Ty, TyCtxt, TypeFoldable, Variance, }; @@ -98,7 +98,7 @@ impl AscribeUserTypeCx<'me, 'tcx> { self.infcx.tcx } - fn subst(&self, value: T, substs: &[Kind<'tcx>]) -> T + fn subst(&self, value: T, substs: &[GenericArg<'tcx>]) -> T where T: TypeFoldable<'tcx>, { diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 2cd74281306f1..339045a4bad8e 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -16,7 +16,7 @@ use rustc::lint::builtin::AMBIGUOUS_ASSOCIATED_ITEMS; use rustc::traits; use rustc::ty::{self, DefIdTree, Ty, TyCtxt, Const, ToPredicate, TypeFoldable}; use rustc::ty::{GenericParamDef, GenericParamDefKind}; -use rustc::ty::subst::{Kind, Subst, InternalSubsts, SubstsRef}; +use rustc::ty::subst::{self, Subst, InternalSubsts, SubstsRef}; use rustc::ty::wf::object_region_bounds; use rustc::mir::interpret::ConstValue; use rustc_target::spec::abi; @@ -465,18 +465,19 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { /// `[T]`. The boolean value indicates whether to infer values /// for arguments whose values were not explicitly provided. /// - `provided_kind`: given the generic parameter and the value from `args_for_def_id`, - /// instantiate a `Kind`. + /// instantiate a `GenericArg`. /// - `inferred_kind`: if no parameter was provided, and inference is enabled, then /// creates a suitable inference variable. pub fn create_substs_for_generic_args<'b>( tcx: TyCtxt<'tcx>, def_id: DefId, - parent_substs: &[Kind<'tcx>], + parent_substs: &[subst::GenericArg<'tcx>], has_self: bool, self_ty: Option>, args_for_def_id: impl Fn(DefId) -> (Option<&'b GenericArgs>, bool), - provided_kind: impl Fn(&GenericParamDef, &GenericArg) -> Kind<'tcx>, - inferred_kind: impl Fn(Option<&[Kind<'tcx>]>, &GenericParamDef, bool) -> Kind<'tcx>, + provided_kind: impl Fn(&GenericParamDef, &GenericArg) -> subst::GenericArg<'tcx>, + inferred_kind: impl Fn(Option<&[subst::GenericArg<'tcx>]>, &GenericParamDef, bool) + -> subst::GenericArg<'tcx>, ) -> SubstsRef<'tcx> { // Collect the segments of the path; we need to substitute arguments // for parameters throughout the entire path (wherever there are @@ -492,7 +493,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { // We manually build up the substitution, rather than using convenience // methods in `subst.rs`, so that we can iterate over the arguments and // parameters in lock-step linearly, instead of trying to match each pair. - let mut substs: SmallVec<[Kind<'tcx>; 8]> = SmallVec::with_capacity(count); + let mut substs: SmallVec<[subst::GenericArg<'tcx>; 8]> = SmallVec::with_capacity(count); // Iterate over each segment of the path. while let Some((def_id, defs)) = stack.pop() { diff --git a/src/librustc_typeck/check/dropck.rs b/src/librustc_typeck/check/dropck.rs index a144e5938c3a8..cb03af46f3dbb 100644 --- a/src/librustc_typeck/check/dropck.rs +++ b/src/librustc_typeck/check/dropck.rs @@ -6,7 +6,7 @@ use rustc::infer::outlives::env::OutlivesEnvironment; use rustc::infer::{self, InferOk, SuppressRegionErrors}; use rustc::middle::region; use rustc::traits::{ObligationCause, TraitEngine, TraitEngineExt}; -use rustc::ty::subst::{Subst, SubstsRef, UnpackedKind}; +use rustc::ty::subst::{Subst, SubstsRef, GenericArgKind}; use rustc::ty::{self, Ty, TyCtxt}; use crate::util::common::ErrorReported; @@ -308,9 +308,9 @@ pub fn check_safety_of_destructor_if_necessary<'a, 'tcx>( let kinds = rcx.fcx.register_infer_ok_obligations(infer_ok); for kind in kinds { match kind.unpack() { - UnpackedKind::Lifetime(r) => rcx.sub_regions(origin(), parent_scope, r), - UnpackedKind::Type(ty) => rcx.type_must_outlive(origin(), ty, parent_scope), - UnpackedKind::Const(_) => { + GenericArgKind::Lifetime(r) => rcx.sub_regions(origin(), parent_scope, r), + GenericArgKind::Type(ty) => rcx.type_must_outlive(origin(), ty, parent_scope), + GenericArgKind::Const(_) => { // Generic consts don't add constraints. } } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 1d572c141211b..c1eb65ee956ae 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -116,7 +116,9 @@ use rustc::ty::adjustment::{ }; use rustc::ty::fold::TypeFoldable; use rustc::ty::query::Providers; -use rustc::ty::subst::{UnpackedKind, Subst, InternalSubsts, SubstsRef, UserSelfTy, UserSubsts}; +use rustc::ty::subst::{ + GenericArgKind, Subst, InternalSubsts, SubstsRef, UserSelfTy, UserSubsts, +}; use rustc::ty::util::{Representability, IntTypeExt, Discr}; use rustc::ty::layout::VariantIdx; use syntax_pos::{self, BytePos, Span, MultiSpan}; @@ -2213,7 +2215,7 @@ impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> { fn ty_infer(&self, param: Option<&ty::GenericParamDef>, span: Span) -> Ty<'tcx> { if let Some(param) = param { - if let UnpackedKind::Type(ty) = self.var_for_def(span, param).unpack() { + if let GenericArgKind::Type(ty) = self.var_for_def(span, param).unpack() { return ty; } unreachable!() @@ -2232,7 +2234,7 @@ impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> { span: Span, ) -> &'tcx Const<'tcx> { if let Some(param) = param { - if let UnpackedKind::Const(ct) = self.var_for_def(span, param).unpack() { + if let GenericArgKind::Const(ct) = self.var_for_def(span, param).unpack() { return ct; } unreachable!() diff --git a/src/librustc_typeck/check/pat.rs b/src/librustc_typeck/check/pat.rs index af3259b987a2e..b20b5bb8dc3a2 100644 --- a/src/librustc_typeck/check/pat.rs +++ b/src/librustc_typeck/check/pat.rs @@ -8,7 +8,7 @@ use rustc::hir::ptr::P; use rustc::infer; use rustc::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use rustc::ty::{self, Ty, BindingMode, TypeFoldable}; -use rustc::ty::subst::Kind; +use rustc::ty::subst::GenericArg; use syntax::ast; use syntax::util::lev_distance::find_best_match_for_name; use syntax_pos::Span; @@ -797,7 +797,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let max_len = cmp::max(expected_len, elements.len()); let element_tys_iter = (0..max_len).map(|_| { - Kind::from(self.next_ty_var( + GenericArg::from(self.next_ty_var( // FIXME: `MiscVariable` for now -- obtaining the span and name information // from all tuple elements isn't trivial. TypeVariableOrigin { diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index ac9f9f1ea25b1..23280542c2b19 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -81,7 +81,7 @@ use rustc::hir::def_id::DefId; use rustc::infer::outlives::env::OutlivesEnvironment; use rustc::infer::{self, RegionObligation, SuppressRegionErrors}; use rustc::ty::adjustment; -use rustc::ty::subst::{SubstsRef, UnpackedKind}; +use rustc::ty::subst::{SubstsRef, GenericArgKind}; use rustc::ty::{self, Ty}; use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; @@ -1401,14 +1401,14 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> { for kind in substs { match kind.unpack() { - UnpackedKind::Lifetime(lt) => { + GenericArgKind::Lifetime(lt) => { self.sub_regions(origin.clone(), expr_region, lt); } - UnpackedKind::Type(ty) => { + GenericArgKind::Type(ty) => { let ty = self.resolve_type(ty); self.type_must_outlive(origin.clone(), ty, expr_region); } - UnpackedKind::Const(_) => { + GenericArgKind::Const(_) => { // Const parameters don't impose constraints. } } diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index f67a8e9054853..da199131bea9f 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -646,7 +646,7 @@ fn check_opaque_types<'fcx, 'tcx>( let mut seen: FxHashMap<_, Vec<_>> = FxHashMap::default(); for (subst, param) in substs.iter().zip(&generics.params) { match subst.unpack() { - ty::subst::UnpackedKind::Type(ty) => match ty.kind { + ty::subst::GenericArgKind::Type(ty) => match ty.kind { ty::Param(..) => {} // Prevent `fn foo() -> Foo` from being defining. _ => { @@ -668,7 +668,7 @@ fn check_opaque_types<'fcx, 'tcx>( } } - ty::subst::UnpackedKind::Lifetime(region) => { + ty::subst::GenericArgKind::Lifetime(region) => { let param_span = tcx.def_span(param.def_id); if let ty::ReStatic = region { tcx @@ -690,7 +690,7 @@ fn check_opaque_types<'fcx, 'tcx>( } } - ty::subst::UnpackedKind::Const(ct) => match ct.val { + ty::subst::GenericArgKind::Const(ct) => match ct.val { ConstValue::Param(_) => {} _ => { tcx.sess diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 6a5be9023be72..bb368736b8e7a 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -25,7 +25,7 @@ use rustc::ty::query::Providers; use rustc::ty::subst::{Subst, InternalSubsts}; use rustc::ty::util::Discr; use rustc::ty::util::IntTypeExt; -use rustc::ty::subst::UnpackedKind; +use rustc::ty::subst::GenericArgKind; use rustc::ty::{self, AdtKind, DefIdTree, ToPolyTraitRef, Ty, TyCtxt, Const}; use rustc::ty::{ReprOptions, ToPredicate}; use rustc::util::captures::Captures; @@ -1580,7 +1580,7 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> { // Skipping binder is ok, since we only use this to find generic parameters and // their positions. for (idx, subst) in substs.iter().enumerate() { - if let UnpackedKind::Type(ty) = subst.unpack() { + if let GenericArgKind::Type(ty) = subst.unpack() { if let ty::Param(p) = ty.kind { if index_map.insert(p, idx).is_some() { // There was already an entry for `p`, meaning a generic parameter diff --git a/src/librustc_typeck/outlives/implicit_infer.rs b/src/librustc_typeck/outlives/implicit_infer.rs index f8d92f625c301..88091d0da0e49 100644 --- a/src/librustc_typeck/outlives/implicit_infer.rs +++ b/src/librustc_typeck/outlives/implicit_infer.rs @@ -1,7 +1,7 @@ use rustc::hir::{self, Node}; use rustc::hir::def_id::DefId; use rustc::hir::itemlikevisit::ItemLikeVisitor; -use rustc::ty::subst::{Kind, Subst, UnpackedKind}; +use rustc::ty::subst::{GenericArg, Subst, GenericArgKind}; use rustc::ty::{self, Ty, TyCtxt}; use rustc::util::nodemap::FxHashMap; @@ -253,7 +253,7 @@ fn insert_required_predicates_to_be_wf<'tcx>( pub fn check_explicit_predicates<'tcx>( tcx: TyCtxt<'tcx>, def_id: DefId, - substs: &[Kind<'tcx>], + substs: &[GenericArg<'tcx>], required_predicates: &mut RequiredPredicates<'tcx>, explicit_map: &mut ExplicitPredicatesMap<'tcx>, ignored_self_ty: Option>, @@ -310,7 +310,7 @@ pub fn check_explicit_predicates<'tcx>( // binding) and thus infer an outlives requirement that `X: // 'b`. if let Some(self_ty) = ignored_self_ty { - if let UnpackedKind::Type(ty) = outlives_predicate.0.unpack() { + if let GenericArgKind::Type(ty) = outlives_predicate.0.unpack() { if ty.walk().any(|ty| ty == self_ty) { debug!("skipping self ty = {:?}", &ty); continue; diff --git a/src/librustc_typeck/outlives/mod.rs b/src/librustc_typeck/outlives/mod.rs index 6b8f6fccd40d7..59aac5c7ffd3f 100644 --- a/src/librustc_typeck/outlives/mod.rs +++ b/src/librustc_typeck/outlives/mod.rs @@ -2,7 +2,7 @@ use hir::Node; use rustc::hir; use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; use rustc::ty::query::Providers; -use rustc::ty::subst::UnpackedKind; +use rustc::ty::subst::GenericArgKind; use rustc::ty::{self, CratePredicatesMap, TyCtxt}; use syntax::symbol::sym; @@ -100,17 +100,17 @@ fn inferred_outlives_crate( .iter() .filter_map( |ty::OutlivesPredicate(kind1, region2)| match kind1.unpack() { - UnpackedKind::Type(ty1) => { + GenericArgKind::Type(ty1) => { Some(ty::Predicate::TypeOutlives(ty::Binder::bind( ty::OutlivesPredicate(ty1, region2) ))) } - UnpackedKind::Lifetime(region1) => { + GenericArgKind::Lifetime(region1) => { Some(ty::Predicate::RegionOutlives( ty::Binder::bind(ty::OutlivesPredicate(region1, region2)) )) } - UnpackedKind::Const(_) => { + GenericArgKind::Const(_) => { // Generic consts don't impose any constraints. None } diff --git a/src/librustc_typeck/outlives/utils.rs b/src/librustc_typeck/outlives/utils.rs index 783890da639f4..d83c97b522c67 100644 --- a/src/librustc_typeck/outlives/utils.rs +++ b/src/librustc_typeck/outlives/utils.rs @@ -1,18 +1,19 @@ use rustc::ty::outlives::Component; -use rustc::ty::subst::{Kind, UnpackedKind}; +use rustc::ty::subst::{GenericArg, GenericArgKind}; use rustc::ty::{self, Region, RegionKind, Ty, TyCtxt}; use smallvec::smallvec; use std::collections::BTreeSet; /// Tracks the `T: 'a` or `'a: 'a` predicates that we have inferred /// must be added to the struct header. -pub type RequiredPredicates<'tcx> = BTreeSet, ty::Region<'tcx>>>; +pub type RequiredPredicates<'tcx> = + BTreeSet, ty::Region<'tcx>>>; /// Given a requirement `T: 'a` or `'b: 'a`, deduce the /// outlives_component and add it to `required_predicates` pub fn insert_outlives_predicate<'tcx>( tcx: TyCtxt<'tcx>, - kind: Kind<'tcx>, + kind: GenericArg<'tcx>, outlived_region: Region<'tcx>, required_predicates: &mut RequiredPredicates<'tcx>, ) { @@ -23,7 +24,7 @@ pub fn insert_outlives_predicate<'tcx>( } match kind.unpack() { - UnpackedKind::Type(ty) => { + GenericArgKind::Type(ty) => { // `T: 'outlived_region` for some type `T` // But T could be a lot of things: // e.g., if `T = &'b u32`, then `'b: 'outlived_region` is @@ -112,14 +113,14 @@ pub fn insert_outlives_predicate<'tcx>( } } - UnpackedKind::Lifetime(r) => { + GenericArgKind::Lifetime(r) => { if !is_free_region(tcx, r) { return; } required_predicates.insert(ty::OutlivesPredicate(kind, outlived_region)); } - UnpackedKind::Const(_) => { + GenericArgKind::Const(_) => { // Generic consts don't impose any constraints. } } diff --git a/src/librustc_typeck/variance/constraints.rs b/src/librustc_typeck/variance/constraints.rs index 16d5fde815f6a..0feaa2566279b 100644 --- a/src/librustc_typeck/variance/constraints.rs +++ b/src/librustc_typeck/variance/constraints.rs @@ -4,7 +4,7 @@ //! We walk the set of items and, for each member, generate new constraints. use hir::def_id::DefId; -use rustc::ty::subst::{SubstsRef, UnpackedKind}; +use rustc::ty::subst::{SubstsRef, GenericArgKind}; use rustc::ty::{self, Ty, TyCtxt}; use rustc::hir; use rustc::hir::itemlikevisit::ItemLikeVisitor; @@ -232,13 +232,13 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { for k in substs { match k.unpack() { - UnpackedKind::Lifetime(lt) => { + GenericArgKind::Lifetime(lt) => { self.add_constraints_from_region(current, lt, variance_i) } - UnpackedKind::Type(ty) => { + GenericArgKind::Type(ty) => { self.add_constraints_from_ty(current, ty, variance_i) } - UnpackedKind::Const(_) => { + GenericArgKind::Const(_) => { // Consts impose no constraints. } } @@ -387,13 +387,13 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { variance_decl, variance_i); match k.unpack() { - UnpackedKind::Lifetime(lt) => { + GenericArgKind::Lifetime(lt) => { self.add_constraints_from_region(current, lt, variance_i) } - UnpackedKind::Type(ty) => { + GenericArgKind::Type(ty) => { self.add_constraints_from_ty(current, ty, variance_i) } - UnpackedKind::Const(_) => { + GenericArgKind::Const(_) => { // Consts impose no constraints. } } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 46b71abac5409..635f07c388626 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -21,7 +21,7 @@ use rustc::hir; use rustc::hir::def::{CtorKind, DefKind, Res}; use rustc::hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE}; use rustc::hir::ptr::P; -use rustc::ty::subst::{InternalSubsts, SubstsRef, UnpackedKind}; +use rustc::ty::subst::{InternalSubsts, SubstsRef, GenericArgKind}; use rustc::ty::{self, DefIdTree, TyCtxt, Region, RegionVid, Ty, AdtKind}; use rustc::ty::fold::TypeFolder; use rustc::ty::layout::VariantIdx; @@ -1100,18 +1100,18 @@ fn external_generic_args( let mut skip_self = has_self; let mut ty_sty = None; let args: Vec<_> = substs.iter().filter_map(|kind| match kind.unpack() { - UnpackedKind::Lifetime(lt) => { + GenericArgKind::Lifetime(lt) => { lt.clean(cx).and_then(|lt| Some(GenericArg::Lifetime(lt))) } - UnpackedKind::Type(_) if skip_self => { + GenericArgKind::Type(_) if skip_self => { skip_self = false; None } - UnpackedKind::Type(ty) => { + GenericArgKind::Type(ty) => { ty_sty = Some(&ty.kind); Some(GenericArg::Type(ty.clean(cx))) } - UnpackedKind::Const(ct) => Some(GenericArg::Const(ct.clean(cx))), + GenericArgKind::Const(ct) => Some(GenericArg::Const(ct.clean(cx))), }).collect(); match trait_did { From e3fb05dc3c32160e89ad354297b168fae11ffba1 Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 26 Sep 2019 12:10:43 +0100 Subject: [PATCH 2/2] Rename some `_sty` variables to `_kind` --- src/librustc/ty/context.rs | 8 ++++---- src/librustc/ty/flags.rs | 8 ++++---- src/librustc_codegen_llvm/builder.rs | 8 ++++---- src/librustdoc/clean/mod.rs | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index bfaaca688306a..6c3bb3ebb7795 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -132,13 +132,13 @@ impl<'tcx> CtxtInterners<'tcx> { #[allow(rustc::usage_of_ty_tykind)] #[inline(never)] fn intern_ty(&self, - st: TyKind<'tcx> + kind: TyKind<'tcx> ) -> Ty<'tcx> { - self.type_.intern(st, |st| { - let flags = super::flags::FlagComputation::for_sty(&st); + self.type_.intern(kind, |kind| { + let flags = super::flags::FlagComputation::for_kind(&kind); let ty_struct = TyS { - kind: st, + kind, flags: flags.flags, outer_exclusive_binder: flags.outer_exclusive_binder, }; diff --git a/src/librustc/ty/flags.rs b/src/librustc/ty/flags.rs index 297c001dae927..6e43aa6a25d55 100644 --- a/src/librustc/ty/flags.rs +++ b/src/librustc/ty/flags.rs @@ -19,9 +19,9 @@ impl FlagComputation { } #[allow(rustc::usage_of_ty_tykind)] - pub fn for_sty(st: &ty::TyKind<'_>) -> FlagComputation { + pub fn for_kind(kind: &ty::TyKind<'_>) -> FlagComputation { let mut result = FlagComputation::new(); - result.add_sty(st); + result.add_kind(kind); result } @@ -63,8 +63,8 @@ impl FlagComputation { } #[allow(rustc::usage_of_ty_tykind)] - fn add_sty(&mut self, st: &ty::TyKind<'_>) { - match st { + fn add_kind(&mut self, kind: &ty::TyKind<'_>) { + match kind { &ty::Bool | &ty::Char | &ty::Int(_) | diff --git a/src/librustc_codegen_llvm/builder.rs b/src/librustc_codegen_llvm/builder.rs index b8b0e77d09830..71a6067fd48a1 100644 --- a/src/librustc_codegen_llvm/builder.rs +++ b/src/librustc_codegen_llvm/builder.rs @@ -324,7 +324,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { use syntax::ast::UintTy::*; use rustc::ty::{Int, Uint}; - let new_sty = match ty.kind { + let new_kind = match ty.kind { Int(Isize) => Int(self.tcx.sess.target.isize_ty), Uint(Usize) => Uint(self.tcx.sess.target.usize_ty), ref t @ Uint(_) | ref t @ Int(_) => t.clone(), @@ -332,7 +332,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { }; let name = match oop { - OverflowOp::Add => match new_sty { + OverflowOp::Add => match new_kind { Int(I8) => "llvm.sadd.with.overflow.i8", Int(I16) => "llvm.sadd.with.overflow.i16", Int(I32) => "llvm.sadd.with.overflow.i32", @@ -347,7 +347,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { _ => unreachable!(), }, - OverflowOp::Sub => match new_sty { + OverflowOp::Sub => match new_kind { Int(I8) => "llvm.ssub.with.overflow.i8", Int(I16) => "llvm.ssub.with.overflow.i16", Int(I32) => "llvm.ssub.with.overflow.i32", @@ -362,7 +362,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { _ => unreachable!(), }, - OverflowOp::Mul => match new_sty { + OverflowOp::Mul => match new_kind { Int(I8) => "llvm.smul.with.overflow.i8", Int(I16) => "llvm.smul.with.overflow.i16", Int(I32) => "llvm.smul.with.overflow.i32", diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 635f07c388626..e4a8720f5eabc 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1098,7 +1098,7 @@ fn external_generic_args( substs: SubstsRef<'_>, ) -> GenericArgs { let mut skip_self = has_self; - let mut ty_sty = None; + let mut ty_kind = None; let args: Vec<_> = substs.iter().filter_map(|kind| match kind.unpack() { GenericArgKind::Lifetime(lt) => { lt.clean(cx).and_then(|lt| Some(GenericArg::Lifetime(lt))) @@ -1108,7 +1108,7 @@ fn external_generic_args( None } GenericArgKind::Type(ty) => { - ty_sty = Some(&ty.kind); + ty_kind = Some(&ty.kind); Some(GenericArg::Type(ty.clean(cx))) } GenericArgKind::Const(ct) => Some(GenericArg::Const(ct.clean(cx))), @@ -1117,8 +1117,8 @@ fn external_generic_args( match trait_did { // Attempt to sugar an external path like Fn<(A, B,), C> to Fn(A, B) -> C Some(did) if cx.tcx.lang_items().fn_trait_kind(did).is_some() => { - assert!(ty_sty.is_some()); - let inputs = match ty_sty { + assert!(ty_kind.is_some()); + let inputs = match ty_kind { Some(ty::Tuple(ref tys)) => tys.iter().map(|t| t.expect_ty().clean(cx)).collect(), _ => return GenericArgs::AngleBracketed { args, bindings }, };