From ccfa5d6df8ee061264c44bb8fbb3b3f35592ba92 Mon Sep 17 00:00:00 2001 From: csmoe Date: Sat, 9 Feb 2019 22:11:53 +0800 Subject: [PATCH 1/2] replace &'tcx Substs with SubstsRef --- src/librustc/dep_graph/dep_node.rs | 4 ++-- src/librustc/infer/combine.rs | 8 +++---- src/librustc/infer/equate.rs | 8 +++---- .../nice_region_error/placeholder_error.rs | 6 ++--- src/librustc/infer/mod.rs | 4 ++-- src/librustc/infer/opaque_types/mod.rs | 6 ++--- src/librustc/middle/exported_symbols.rs | 4 ++-- src/librustc/mir/mod.rs | 6 ++--- src/librustc/mir/tcx.rs | 4 ++-- src/librustc/mir/visit.rs | 6 ++--- src/librustc/traits/mod.rs | 10 ++++---- src/librustc/traits/select.rs | 8 +++---- src/librustc/traits/specialize/mod.rs | 12 +++++----- src/librustc/ty/adjustment.rs | 4 ++-- src/librustc/ty/codec.rs | 10 ++++---- src/librustc/ty/context.rs | 24 +++++++++---------- src/librustc/ty/inhabitedness/mod.rs | 14 +++++------ src/librustc/ty/instance.rs | 12 +++++----- src/librustc/ty/mod.rs | 4 ++-- src/librustc/ty/query/config.rs | 4 ++-- src/librustc/ty/query/keys.rs | 4 ++-- src/librustc/ty/query/mod.rs | 12 +++++----- src/librustc/ty/relate.rs | 22 ++++++++--------- src/librustc/ty/sty.rs | 24 +++++++++---------- src/librustc/ty/subst.rs | 20 +++++++++------- src/librustc/ty/util.rs | 8 +++---- .../back/symbol_export.rs | 6 ++--- src/librustc_codegen_ssa/callee.rs | 6 ++--- src/librustc_codegen_ssa/mir/mod.rs | 4 ++-- src/librustc_codegen_utils/symbol_names.rs | 4 ++-- src/librustc_lint/types.rs | 4 ++-- .../borrow_check/nll/constraint_generation.rs | 4 ++-- .../error_reporting/region_name.rs | 6 ++--- src/librustc_mir/borrow_check/nll/renumber.rs | 4 ++-- .../borrow_check/nll/type_check/mod.rs | 4 ++-- .../borrow_check/nll/universal_regions.rs | 8 +++---- src/librustc_mir/build/mod.rs | 4 ++-- src/librustc_mir/hair/cx/expr.rs | 5 ++-- src/librustc_mir/hair/mod.rs | 4 ++-- src/librustc_mir/hair/pattern/check_match.rs | 4 ++-- src/librustc_mir/hair/pattern/mod.rs | 12 +++++----- src/librustc_mir/interpret/eval_context.rs | 6 ++--- src/librustc_mir/monomorphize/collector.rs | 8 +++---- src/librustc_mir/transform/erase_regions.rs | 4 ++-- src/librustc_mir/transform/generator.rs | 4 ++-- src/librustc_mir/transform/inline.rs | 4 ++-- src/librustc_mir/util/elaborate_drops.rs | 16 ++++++------- src/librustc_passes/rvalue_promotion.rs | 4 ++-- src/librustc_typeck/astconv.rs | 10 ++++---- src/librustc_typeck/check/cast.rs | 4 ++-- src/librustc_typeck/check/method/confirm.rs | 13 +++++----- src/librustc_typeck/check/method/mod.rs | 4 ++-- src/librustc_typeck/check/method/probe.rs | 8 +++---- src/librustc_typeck/check/mod.rs | 8 +++---- src/librustc_typeck/lib.rs | 4 ++-- 55 files changed, 213 insertions(+), 211 deletions(-) diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index 2f91da4f62e3d..0d8f71a50ce52 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -67,7 +67,7 @@ use crate::traits::query::{ }; use crate::ty::{TyCtxt, FnSig, Instance, InstanceDef, ParamEnv, ParamEnvAnd, Predicate, PolyFnSig, PolyTraitRef, Ty}; -use crate::ty::subst::Substs; +use crate::ty::subst::SubstsRef; // erase!() just makes tokens go away. It's used to specify which macro argument // is repeated (i.e., which sub-expression of the macro we are in) but don't need @@ -661,7 +661,7 @@ define_dep_nodes!( <'tcx> [] TypeOpNormalizePolyFnSig(CanonicalTypeOpNormalizeGoal<'tcx, PolyFnSig<'tcx>>), [] TypeOpNormalizeFnSig(CanonicalTypeOpNormalizeGoal<'tcx, FnSig<'tcx>>), - [] SubstituteNormalizeAndTestPredicates { key: (DefId, &'tcx Substs<'tcx>) }, + [] SubstituteNormalizeAndTestPredicates { key: (DefId, SubstsRef<'tcx>) }, [] MethodAutoderefSteps(CanonicalTyGoal<'tcx>), [input] TargetFeaturesWhitelist, diff --git a/src/librustc/infer/combine.rs b/src/librustc/infer/combine.rs index 9cd5a844f1590..6ef902a47dc8d 100644 --- a/src/librustc/infer/combine.rs +++ b/src/librustc/infer/combine.rs @@ -34,7 +34,7 @@ use crate::ty::{IntType, UintType}; use crate::ty::{self, Ty, TyCtxt}; use crate::ty::error::TypeError; use crate::ty::relate::{self, Relate, RelateResult, TypeRelation}; -use crate::ty::subst::Substs; +use crate::ty::subst::SubstsRef; use crate::traits::{Obligation, PredicateObligations}; use syntax::ast; @@ -373,9 +373,9 @@ impl<'cx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx> for Generalizer<'cx, 'gcx, ' fn relate_item_substs(&mut self, item_def_id: DefId, - a_subst: &'tcx Substs<'tcx>, - b_subst: &'tcx Substs<'tcx>) - -> RelateResult<'tcx, &'tcx Substs<'tcx>> + a_subst: SubstsRef<'tcx>, + b_subst: SubstsRef<'tcx>) + -> RelateResult<'tcx, SubstsRef<'tcx>> { if self.ambient_variance == ty::Variance::Invariant { // Avoid fetching the variance if we are in an invariant diff --git a/src/librustc/infer/equate.rs b/src/librustc/infer/equate.rs index a4b62307a60b8..31b01eecf5cb6 100644 --- a/src/librustc/infer/equate.rs +++ b/src/librustc/infer/equate.rs @@ -5,7 +5,7 @@ use crate::hir::def_id::DefId; use crate::ty::{self, Ty, TyCtxt}; use crate::ty::TyVar; -use crate::ty::subst::Substs; +use crate::ty::subst::SubstsRef; use crate::ty::relate::{self, Relate, RelateResult, TypeRelation}; /// Ensures `a` is made equal to `b`. Returns `a` on success. @@ -33,9 +33,9 @@ impl<'combine, 'infcx, 'gcx, 'tcx> TypeRelation<'infcx, 'gcx, 'tcx> fn relate_item_substs(&mut self, _item_def_id: DefId, - a_subst: &'tcx Substs<'tcx>, - b_subst: &'tcx Substs<'tcx>) - -> RelateResult<'tcx, &'tcx Substs<'tcx>> + a_subst: SubstsRef<'tcx>, + b_subst: SubstsRef<'tcx>) + -> RelateResult<'tcx, SubstsRef<'tcx>> { // N.B., once we are equating types, we don't care about // variance, so don't try to lookup the variance here. This diff --git a/src/librustc/infer/error_reporting/nice_region_error/placeholder_error.rs b/src/librustc/infer/error_reporting/nice_region_error/placeholder_error.rs index 3b2fb7d41008e..506388c268bb1 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/placeholder_error.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/placeholder_error.rs @@ -7,7 +7,7 @@ use crate::infer::{SubregionOrigin, TypeTrace}; use crate::traits::{ObligationCause, ObligationCauseCode}; use crate::ty; use crate::ty::error::ExpectedFound; -use crate::ty::subst::Substs; +use crate::ty::subst::SubstsRef; use crate::util::ppaux::RegionHighlightMode; impl NiceRegionError<'me, 'gcx, 'tcx> { @@ -175,8 +175,8 @@ impl NiceRegionError<'me, 'gcx, 'tcx> { sub_placeholder: Option>, sup_placeholder: Option>, trait_def_id: DefId, - expected_substs: &'tcx Substs<'tcx>, - actual_substs: &'tcx Substs<'tcx>, + expected_substs: SubstsRef<'tcx>, + actual_substs: SubstsRef<'tcx>, ) -> DiagnosticBuilder<'me> { debug!( "try_report_placeholders_trait(\ diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index ac2ebece442c8..a02918a493948 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -18,7 +18,7 @@ use crate::traits::{self, ObligationCause, PredicateObligations, TraitEngine}; use crate::ty::error::{ExpectedFound, TypeError, UnconstrainedNumeric}; use crate::ty::fold::TypeFoldable; use crate::ty::relate::RelateResult; -use crate::ty::subst::{Kind, Substs}; +use crate::ty::subst::{Kind, Substs, SubstsRef}; use crate::ty::{self, GenericParamDefKind, Ty, TyCtxt, CtxtInterners}; use crate::ty::{FloatVid, IntVid, TyVid}; use crate::util::nodemap::FxHashMap; @@ -1088,7 +1088,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { /// Given a set of generics defined on a type or impl, returns a substitution mapping each /// type/region parameter to a fresh inference variable. - pub fn fresh_substs_for_item(&self, span: Span, def_id: DefId) -> &'tcx Substs<'tcx> { + pub fn fresh_substs_for_item(&self, span: Span, def_id: DefId) -> SubstsRef<'tcx> { Substs::for_item(self.tcx, def_id, |param, _| self.var_for_def(span, param)) } diff --git a/src/librustc/infer/opaque_types/mod.rs b/src/librustc/infer/opaque_types/mod.rs index e75446b01c11e..079c2a12a8475 100644 --- a/src/librustc/infer/opaque_types/mod.rs +++ b/src/librustc/infer/opaque_types/mod.rs @@ -9,7 +9,7 @@ use crate::traits::{self, PredicateObligation}; use crate::ty::{self, Ty, TyCtxt, GenericParamDefKind}; use crate::ty::fold::{BottomUpFolder, TypeFoldable, TypeFolder}; use crate::ty::outlives::Component; -use crate::ty::subst::{Kind, Substs, UnpackedKind}; +use crate::ty::subst::{Kind, Substs, SubstsRef, UnpackedKind}; use crate::util::nodemap::DefIdMap; pub type OpaqueTypeMap<'tcx> = DefIdMap>; @@ -30,7 +30,7 @@ pub struct OpaqueTypeDecl<'tcx> { /// fn foo<'a, 'b, T>() -> Foo<'a, T> /// /// then `substs` would be `['a, T]`. - pub substs: &'tcx Substs<'tcx>, + pub substs: SubstsRef<'tcx>, /// The type variable that represents the value of the abstract type /// that we require. In other words, after we compile this function, @@ -740,7 +740,7 @@ impl<'a, 'gcx, 'tcx> Instantiator<'a, 'gcx, 'tcx> { &mut self, ty: Ty<'tcx>, def_id: DefId, - substs: &'tcx Substs<'tcx>, + substs: SubstsRef<'tcx>, ) -> Ty<'tcx> { let infcx = self.infcx; let tcx = infcx.tcx; diff --git a/src/librustc/middle/exported_symbols.rs b/src/librustc/middle/exported_symbols.rs index 6c43068a22772..32c7216765533 100644 --- a/src/librustc/middle/exported_symbols.rs +++ b/src/librustc/middle/exported_symbols.rs @@ -5,7 +5,7 @@ use rustc_data_structures::stable_hasher::{StableHasher, HashStable, use std::cmp; use std::mem; use crate::ty; -use crate::ty::subst::Substs; +use crate::ty::subst::SubstsRef; /// The SymbolExportLevel of a symbols specifies from which kinds of crates /// the symbol will be exported. `C` symbols will be exported from any @@ -33,7 +33,7 @@ impl SymbolExportLevel { #[derive(Eq, PartialEq, Debug, Copy, Clone, RustcEncodable, RustcDecodable)] pub enum ExportedSymbol<'tcx> { NonGeneric(DefId), - Generic(DefId, &'tcx Substs<'tcx>), + Generic(DefId, SubstsRef<'tcx>), NoDefId(ty::SymbolName), } diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 001a347c3313a..bfc74979af42c 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -27,7 +27,7 @@ use syntax::ast::{self, Name}; use syntax::symbol::InternedString; use syntax_pos::{Span, DUMMY_SP}; use crate::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; -use crate::ty::subst::{Subst, Substs}; +use crate::ty::subst::{Subst, SubstsRef}; use crate::ty::layout::VariantIdx; use crate::ty::{ self, AdtDef, CanonicalUserTypeAnnotations, ClosureSubsts, GeneratorSubsts, Region, Ty, TyCtxt, @@ -2151,7 +2151,7 @@ impl<'tcx> Operand<'tcx> { pub fn function_handle<'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId, - substs: &'tcx Substs<'tcx>, + substs: SubstsRef<'tcx>, span: Span, ) -> Self { let ty = tcx.type_of(def_id).subst(tcx, substs); @@ -2247,7 +2247,7 @@ pub enum AggregateKind<'tcx> { Adt( &'tcx AdtDef, VariantIdx, - &'tcx Substs<'tcx>, + SubstsRef<'tcx>, Option, Option, ), diff --git a/src/librustc/mir/tcx.rs b/src/librustc/mir/tcx.rs index bf4ac7496d2e7..dbf911851bf2d 100644 --- a/src/librustc/mir/tcx.rs +++ b/src/librustc/mir/tcx.rs @@ -4,7 +4,7 @@ */ use crate::mir::*; -use crate::ty::subst::{Subst, Substs}; +use crate::ty::subst::{Subst, SubstsRef}; use crate::ty::{self, AdtDef, Ty, TyCtxt}; use crate::ty::layout::VariantIdx; use crate::hir; @@ -17,7 +17,7 @@ pub enum PlaceTy<'tcx> { /// Downcast to a particular variant of an enum. Downcast { adt_def: &'tcx AdtDef, - substs: &'tcx Substs<'tcx>, + substs: SubstsRef<'tcx>, variant_index: VariantIdx }, } diff --git a/src/librustc/mir/visit.rs b/src/librustc/mir/visit.rs index e5828039ac29c..4f31cebca088d 100644 --- a/src/librustc/mir/visit.rs +++ b/src/librustc/mir/visit.rs @@ -1,5 +1,5 @@ use crate::hir::def_id::DefId; -use crate::ty::subst::Substs; +use crate::ty::subst::SubstsRef; use crate::ty::{CanonicalUserTypeAnnotation, ClosureSubsts, GeneratorSubsts, Region, Ty}; use crate::mir::*; use syntax_pos::Span; @@ -238,7 +238,7 @@ macro_rules! make_mir_visitor { } fn visit_substs(&mut self, - substs: & $($mutability)? &'tcx Substs<'tcx>, + substs: & $($mutability)? SubstsRef<'tcx>, _: Location) { self.super_substs(substs); } @@ -889,7 +889,7 @@ macro_rules! make_mir_visitor { fn super_const(&mut self, _const: & $($mutability)? &'tcx ty::LazyConst<'tcx>) { } - fn super_substs(&mut self, _substs: & $($mutability)? &'tcx Substs<'tcx>) { + fn super_substs(&mut self, _substs: & $($mutability)? SubstsRef<'tcx>) { } fn super_generator_substs(&mut self, diff --git a/src/librustc/traits/mod.rs b/src/librustc/traits/mod.rs index be6a95948edb9..64ac874e8f1de 100644 --- a/src/librustc/traits/mod.rs +++ b/src/librustc/traits/mod.rs @@ -29,7 +29,7 @@ use crate::mir::interpret::ErrorHandled; use rustc_data_structures::sync::Lrc; use syntax::ast; use syntax_pos::{Span, DUMMY_SP}; -use crate::ty::subst::Substs; +use crate::ty::subst::{Substs, SubstsRef}; use crate::ty::{self, AdtKind, List, Ty, TyCtxt, GenericParamDefKind, ToPredicate}; use crate::ty::error::{ExpectedFound, TypeError}; use crate::ty::fold::{TypeFolder, TypeFoldable, TypeVisitor}; @@ -565,7 +565,7 @@ pub enum Vtable<'tcx, N> { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable)] pub struct VtableImplData<'tcx, N> { pub impl_def_id: DefId, - pub substs: &'tcx Substs<'tcx>, + pub substs: SubstsRef<'tcx>, pub nested: Vec } @@ -622,7 +622,7 @@ pub struct VtableFnPointerData<'tcx, N> { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable)] pub struct VtableTraitAliasData<'tcx, N> { pub alias_def_id: DefId, - pub substs: &'tcx Substs<'tcx>, + pub substs: SubstsRef<'tcx>, pub nested: Vec, } @@ -963,7 +963,7 @@ fn normalize_and_test_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } fn substitute_normalize_and_test_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, - key: (DefId, &'tcx Substs<'tcx>)) + key: (DefId, SubstsRef<'tcx>)) -> bool { debug!("substitute_normalize_and_test_predicates(key={:?})", @@ -983,7 +983,7 @@ fn substitute_normalize_and_test_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx fn vtable_methods<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, trait_ref: ty::PolyTraitRef<'tcx>) - -> Lrc)>>> + -> Lrc)>>> { debug!("vtable_methods({:?})", trait_ref); diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index 05fb40ac10a07..320b591ddcf7b 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -34,7 +34,7 @@ use crate::middle::lang_items; use crate::mir::interpret::GlobalId; use crate::ty::fast_reject; use crate::ty::relate::TypeRelation; -use crate::ty::subst::{Subst, Substs}; +use crate::ty::subst::{Subst, Substs, SubstsRef}; use crate::ty::{self, ToPolyTraitRef, ToPredicate, Ty, TyCtxt, TypeFoldable}; use crate::hir; @@ -2944,7 +2944,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { fn vtable_impl( &mut self, impl_def_id: DefId, - mut substs: Normalized<'tcx, &'tcx Substs<'tcx>>, + mut substs: Normalized<'tcx, SubstsRef<'tcx>>, cause: ObligationCause<'tcx>, recursion_depth: usize, param_env: ty::ParamEnv<'tcx>, @@ -3538,7 +3538,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { impl_def_id: DefId, obligation: &TraitObligation<'tcx>, snapshot: &CombinedSnapshot<'_, 'tcx>, - ) -> Normalized<'tcx, &'tcx Substs<'tcx>> { + ) -> Normalized<'tcx, SubstsRef<'tcx>> { match self.match_impl(impl_def_id, obligation, snapshot) { Ok(substs) => substs, Err(()) => { @@ -3556,7 +3556,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { impl_def_id: DefId, obligation: &TraitObligation<'tcx>, snapshot: &CombinedSnapshot<'_, 'tcx>, - ) -> Result>, ()> { + ) -> Result>, ()> { let impl_trait_ref = self.tcx().impl_trait_ref(impl_def_id).unwrap(); // Before we create the substitutions and everything, first diff --git a/src/librustc/traits/specialize/mod.rs b/src/librustc/traits/specialize/mod.rs index 804f1b9d820a2..9a760065cb1fc 100644 --- a/src/librustc/traits/specialize/mod.rs +++ b/src/librustc/traits/specialize/mod.rs @@ -20,7 +20,7 @@ use rustc_data_structures::sync::Lrc; use syntax_pos::DUMMY_SP; use crate::traits::select::IntercrateAmbiguityCause; use crate::ty::{self, TyCtxt, TypeFoldable}; -use crate::ty::subst::{Subst, Substs}; +use crate::ty::subst::{Subst, Substs, SubstsRef}; use super::{SelectionContext, FulfillmentContext}; use super::util::impl_trait_ref_and_oblig; @@ -73,9 +73,9 @@ pub struct OverlapError { pub fn translate_substs<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>, param_env: ty::ParamEnv<'tcx>, source_impl: DefId, - source_substs: &'tcx Substs<'tcx>, + source_substs: SubstsRef<'tcx>, target_node: specialization_graph::Node) - -> &'tcx Substs<'tcx> { + -> SubstsRef<'tcx> { debug!("translate_substs({:?}, {:?}, {:?}, {:?})", param_env, source_impl, source_substs, target_node); let source_trait_ref = infcx.tcx @@ -114,9 +114,9 @@ pub fn find_associated_item<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, param_env: ty::ParamEnv<'tcx>, item: &ty::AssociatedItem, - substs: &'tcx Substs<'tcx>, + substs: SubstsRef<'tcx>, impl_data: &super::VtableImplData<'tcx, ()>, -) -> (DefId, &'tcx Substs<'tcx>) { +) -> (DefId, SubstsRef<'tcx>) { debug!("find_associated_item({:?}, {:?}, {:?}, {:?})", param_env, item, substs, impl_data); assert!(!substs.needs_infer()); @@ -214,7 +214,7 @@ fn fulfill_implication<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>, param_env: ty::ParamEnv<'tcx>, source_trait_ref: ty::TraitRef<'tcx>, target_impl: DefId) - -> Result<&'tcx Substs<'tcx>, ()> { + -> Result, ()> { debug!("fulfill_implication({:?}, trait_ref={:?} |- {:?} applies)", param_env, source_trait_ref, target_impl); diff --git a/src/librustc/ty/adjustment.rs b/src/librustc/ty/adjustment.rs index ff4fc87542dc3..8d449f5c44cf4 100644 --- a/src/librustc/ty/adjustment.rs +++ b/src/librustc/ty/adjustment.rs @@ -1,7 +1,7 @@ use crate::hir; use crate::hir::def_id::DefId; use crate::ty::{self, Ty, TyCtxt}; -use crate::ty::subst::Substs; +use crate::ty::subst::SubstsRef; /// Represents coercing a value to a different type of value. @@ -98,7 +98,7 @@ pub struct OverloadedDeref<'tcx> { impl<'a, 'gcx, 'tcx> OverloadedDeref<'tcx> { pub fn method_call(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, source: Ty<'tcx>) - -> (DefId, &'tcx Substs<'tcx>) { + -> (DefId, SubstsRef<'tcx>) { let trait_def_id = match self.mutbl { hir::MutImmutable => tcx.lang_items().deref_trait(), hir::MutMutable => tcx.lang_items().deref_mut_trait() diff --git a/src/librustc/ty/codec.rs b/src/librustc/ty/codec.rs index e93de32f7257b..3ab744ebaeb17 100644 --- a/src/librustc/ty/codec.rs +++ b/src/librustc/ty/codec.rs @@ -13,7 +13,7 @@ use crate::rustc_serialize::{Decodable, Decoder, Encoder, Encodable, opaque}; use std::hash::Hash; use std::intrinsics; use crate::ty::{self, Ty, TyCtxt}; -use crate::ty::subst::Substs; +use crate::ty::subst::SubstsRef; use crate::mir::interpret::Allocation; /// The shorthand encoding uses an enum's variant index `usize` @@ -185,7 +185,7 @@ pub fn decode_predicates<'a, 'tcx, D>(decoder: &mut D) } #[inline] -pub fn decode_substs<'a, 'tcx, D>(decoder: &mut D) -> Result<&'tcx Substs<'tcx>, D::Error> +pub fn decode_substs<'a, 'tcx, D>(decoder: &mut D) -> Result, D::Error> where D: TyDecoder<'a, 'tcx>, 'tcx: 'a, { @@ -281,7 +281,7 @@ macro_rules! implement_ty_decoder { use $crate::infer::canonical::CanonicalVarInfos; use $crate::ty; use $crate::ty::codec::*; - use $crate::ty::subst::Substs; + use $crate::ty::subst::SubstsRef; use $crate::hir::def_id::{CrateNum}; use crate::rustc_serialize::{Decoder, SpecializedDecoder}; use std::borrow::Cow; @@ -344,9 +344,9 @@ macro_rules! implement_ty_decoder { } } - impl<$($typaram),*> SpecializedDecoder<&'tcx Substs<'tcx>> + impl<$($typaram),*> SpecializedDecoder> for $DecoderName<$($typaram),*> { - fn specialized_decode(&mut self) -> Result<&'tcx Substs<'tcx>, Self::Error> { + fn specialized_decode(&mut self) -> Result, Self::Error> { decode_substs(self) } } diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index a71c0d4ab963d..68f21ce10788b 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -22,7 +22,7 @@ use crate::middle::resolve_lifetime::{self, ObjectLifetimeDefault}; use crate::middle::stability; use crate::mir::{self, Mir, interpret, ProjectionKind}; use crate::mir::interpret::Allocation; -use crate::ty::subst::{Kind, Substs, Subst}; +use crate::ty::subst::{Kind, Substs, Subst, SubstsRef}; use crate::ty::ReprOptions; use crate::traits; use crate::traits::{Clause, Clauses, GoalKind, Goal, Goals}; @@ -325,7 +325,7 @@ pub struct ResolvedOpaqueTy<'tcx> { /// Generic parameters on the opaque type as passed by this function. /// For `existential type Foo; fn foo() -> Foo { .. }` this is `[T, U]`, not /// `[A, B]` - pub substs: &'tcx Substs<'tcx>, + pub substs: SubstsRef<'tcx>, } #[derive(RustcEncodable, RustcDecodable, Debug)] @@ -352,7 +352,7 @@ pub struct TypeckTables<'tcx> { /// of this node. This only applies to nodes that refer to entities /// parameterized by type parameters, such as generic fns, types, or /// other items. - node_substs: ItemLocalMap<&'tcx Substs<'tcx>>, + node_substs: ItemLocalMap>, /// This will either store the canonicalized types provided by the user /// or the substitutions that the user explicitly gave (if any) attached @@ -548,19 +548,19 @@ impl<'tcx> TypeckTables<'tcx> { self.node_types.get(&id.local_id).cloned() } - pub fn node_substs_mut(&mut self) -> LocalTableInContextMut<'_, &'tcx Substs<'tcx>> { + pub fn node_substs_mut(&mut self) -> LocalTableInContextMut<'_, SubstsRef<'tcx>> { LocalTableInContextMut { local_id_root: self.local_id_root, data: &mut self.node_substs } } - pub fn node_substs(&self, id: hir::HirId) -> &'tcx Substs<'tcx> { + pub fn node_substs(&self, id: hir::HirId) -> SubstsRef<'tcx> { validate_hir_id_for_typeck_tables(self.local_id_root, id, false); self.node_substs.get(&id.local_id).cloned().unwrap_or_else(|| Substs::empty()) } - pub fn node_substs_opt(&self, id: hir::HirId) -> Option<&'tcx Substs<'tcx>> { + pub fn node_substs_opt(&self, id: hir::HirId) -> Option> { validate_hir_id_for_typeck_tables(self.local_id_root, id, false); self.node_substs.get(&id.local_id).cloned() } @@ -1733,7 +1733,7 @@ impl<'gcx> GlobalCtxt<'gcx> { /// A trait implemented for all X<'a> types which can be safely and /// efficiently converted to X<'tcx> as long as they are part of the /// provided TyCtxt<'tcx>. -/// This can be done, for example, for Ty<'tcx> or &'tcx Substs<'tcx> +/// This can be done, for example, for Ty<'tcx> or SubstsRef<'tcx> /// by looking them up in their respective interners. /// /// However, this is still not the best implementation as it does @@ -2507,7 +2507,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } #[inline] - pub fn mk_adt(self, def: &'tcx AdtDef, substs: &'tcx Substs<'tcx>) -> Ty<'tcx> { + pub fn mk_adt(self, def: &'tcx AdtDef, substs: SubstsRef<'tcx>) -> Ty<'tcx> { // take a copy of substs so that we own the vectors inside self.mk_ty(Adt(def, substs)) } @@ -2613,7 +2613,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { #[inline] pub fn mk_fn_def(self, def_id: DefId, - substs: &'tcx Substs<'tcx>) -> Ty<'tcx> { + substs: SubstsRef<'tcx>) -> Ty<'tcx> { self.mk_ty(FnDef(def_id, substs)) } @@ -2634,7 +2634,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { #[inline] pub fn mk_projection(self, item_def_id: DefId, - substs: &'tcx Substs<'tcx>) + substs: SubstsRef<'tcx>) -> Ty<'tcx> { self.mk_ty(Projection(ProjectionTy { item_def_id, @@ -2704,7 +2704,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } #[inline] - pub fn mk_opaque(self, def_id: DefId, substs: &'tcx Substs<'tcx>) -> Ty<'tcx> { + pub fn mk_opaque(self, def_id: DefId, substs: SubstsRef<'tcx>) -> Ty<'tcx> { self.mk_ty(Opaque(def_id, substs)) } @@ -2817,7 +2817,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn mk_substs_trait(self, self_ty: Ty<'tcx>, rest: &[Kind<'tcx>]) - -> &'tcx Substs<'tcx> + -> SubstsRef<'tcx> { self.mk_substs(iter::once(self_ty.into()).chain(rest.iter().cloned())) } diff --git a/src/librustc/ty/inhabitedness/mod.rs b/src/librustc/ty/inhabitedness/mod.rs index 601ffe70eec18..33ec9c874f9ef 100644 --- a/src/librustc/ty/inhabitedness/mod.rs +++ b/src/librustc/ty/inhabitedness/mod.rs @@ -1,6 +1,6 @@ use crate::ty::context::TyCtxt; use crate::ty::{AdtDef, VariantDef, FieldDef, Ty, TyS}; -use crate::ty::{self, DefId, Substs}; +use crate::ty::{self, DefId, SubstsRef}; use crate::ty::{AdtKind, Visibility}; use crate::ty::TyKind::*; @@ -108,7 +108,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn is_enum_variant_uninhabited_from(self, module: DefId, variant: &'tcx VariantDef, - substs: &'tcx Substs<'tcx>) + substs: SubstsRef<'tcx>) -> bool { self.variant_inhabitedness_forest(variant, substs).contains(self, module) @@ -116,13 +116,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn is_variant_uninhabited_from_all_modules(self, variant: &'tcx VariantDef, - substs: &'tcx Substs<'tcx>) + substs: SubstsRef<'tcx>) -> bool { !self.variant_inhabitedness_forest(variant, substs).is_empty() } - fn variant_inhabitedness_forest(self, variant: &'tcx VariantDef, substs: &'tcx Substs<'tcx>) + fn variant_inhabitedness_forest(self, variant: &'tcx VariantDef, substs: SubstsRef<'tcx>) -> DefIdForest { // Determine the ADT kind: let adt_def_id = self.adt_def_id_of_variant(variant); @@ -138,7 +138,7 @@ impl<'a, 'gcx, 'tcx> AdtDef { fn uninhabited_from( &self, tcx: TyCtxt<'a, 'gcx, 'tcx>, - substs: &'tcx Substs<'tcx>) -> DefIdForest + substs: SubstsRef<'tcx>) -> DefIdForest { DefIdForest::intersection(tcx, self.variants.iter().map(|v| { v.uninhabited_from(tcx, substs, self.adt_kind()) @@ -151,7 +151,7 @@ impl<'a, 'gcx, 'tcx> VariantDef { fn uninhabited_from( &self, tcx: TyCtxt<'a, 'gcx, 'tcx>, - substs: &'tcx Substs<'tcx>, + substs: SubstsRef<'tcx>, adt_kind: AdtKind) -> DefIdForest { let is_enum = match adt_kind { @@ -172,7 +172,7 @@ impl<'a, 'gcx, 'tcx> FieldDef { fn uninhabited_from( &self, tcx: TyCtxt<'a, 'gcx, 'tcx>, - substs: &'tcx Substs<'tcx>, + substs: SubstsRef<'tcx>, is_enum: bool, ) -> DefIdForest { let data_uninhabitedness = move || { diff --git a/src/librustc/ty/instance.rs b/src/librustc/ty/instance.rs index 5fc22e3c02b60..709dce4589f6b 100644 --- a/src/librustc/ty/instance.rs +++ b/src/librustc/ty/instance.rs @@ -1,6 +1,6 @@ use crate::hir::Unsafety; use crate::hir::def_id::DefId; -use crate::ty::{self, Ty, PolyFnSig, TypeFoldable, Substs, TyCtxt}; +use crate::ty::{self, Ty, PolyFnSig, TypeFoldable, SubstsRef, TyCtxt}; use crate::traits; use rustc_target::spec::abi::Abi; use crate::util::ppaux; @@ -11,7 +11,7 @@ use std::iter; #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, RustcEncodable, RustcDecodable)] pub struct Instance<'tcx> { pub def: InstanceDef<'tcx>, - pub substs: &'tcx Substs<'tcx>, + pub substs: SubstsRef<'tcx>, } #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, RustcEncodable, RustcDecodable)] @@ -203,7 +203,7 @@ impl<'tcx> fmt::Display for Instance<'tcx> { } impl<'a, 'b, 'tcx> Instance<'tcx> { - pub fn new(def_id: DefId, substs: &'tcx Substs<'tcx>) + pub fn new(def_id: DefId, substs: SubstsRef<'tcx>) -> Instance<'tcx> { assert!(!substs.has_escaping_bound_vars(), "substs of instance {:?} not normalized for codegen: {:?}", @@ -241,7 +241,7 @@ impl<'a, 'b, 'tcx> Instance<'tcx> { pub fn resolve(tcx: TyCtxt<'a, 'tcx, 'tcx>, param_env: ty::ParamEnv<'tcx>, def_id: DefId, - substs: &'tcx Substs<'tcx>) -> Option> { + substs: SubstsRef<'tcx>) -> Option> { debug!("resolve(def_id={:?}, substs={:?})", def_id, substs); let result = if let Some(trait_def_id) = tcx.trait_of_item(def_id) { debug!(" => associated item, attempting to find impl in param_env {:#?}", param_env); @@ -293,7 +293,7 @@ impl<'a, 'b, 'tcx> Instance<'tcx> { pub fn resolve_for_vtable(tcx: TyCtxt<'a, 'tcx, 'tcx>, param_env: ty::ParamEnv<'tcx>, def_id: DefId, - substs: &'tcx Substs<'tcx>) -> Option> { + substs: SubstsRef<'tcx>) -> Option> { debug!("resolve(def_id={:?}, substs={:?})", def_id, substs); let fn_sig = tcx.fn_sig(def_id); let is_vtable_shim = @@ -338,7 +338,7 @@ fn resolve_associated_item<'a, 'tcx>( trait_item: &ty::AssociatedItem, param_env: ty::ParamEnv<'tcx>, trait_id: DefId, - rcvr_substs: &'tcx Substs<'tcx>, + rcvr_substs: SubstsRef<'tcx>, ) -> Option> { let def_id = trait_item.def_id; debug!("resolve_associated_item(trait_item={:?}, \ diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index a3cf7bf488ee7..e098488824f36 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -22,7 +22,7 @@ use crate::session::CrateDisambiguator; use crate::traits::{self, Reveal}; use crate::ty; use crate::ty::layout::VariantIdx; -use crate::ty::subst::{Subst, Substs}; +use crate::ty::subst::{Subst, Substs, SubstsRef}; use crate::ty::util::{IntTypeExt, Discr}; use crate::ty::walk::TypeWalker; use crate::util::captures::Captures; @@ -1067,7 +1067,7 @@ pub enum Predicate<'tcx> { Subtype(PolySubtypePredicate<'tcx>), /// Constant initializer must evaluate successfully. - ConstEvaluatable(DefId, &'tcx Substs<'tcx>), + ConstEvaluatable(DefId, SubstsRef<'tcx>), } /// The crate outlives map is computed during typeck and contains the diff --git a/src/librustc/ty/query/config.rs b/src/librustc/ty/query/config.rs index 1870812893c14..0d3e9f7914ba7 100644 --- a/src/librustc/ty/query/config.rs +++ b/src/librustc/ty/query/config.rs @@ -9,7 +9,7 @@ use crate::traits::query::{ CanonicalTypeOpProvePredicateGoal, CanonicalTypeOpSubtypeGoal, }; use crate::ty::{self, ParamEnvAnd, Ty, TyCtxt}; -use crate::ty::subst::Substs; +use crate::ty::subst::SubstsRef; use crate::ty::query::queries; use crate::ty::query::Query; use crate::ty::query::QueryCache; @@ -914,7 +914,7 @@ impl<'tcx> QueryDescription<'tcx> for queries::optimized_mir<'tcx> { } impl<'tcx> QueryDescription<'tcx> for queries::substitute_normalize_and_test_predicates<'tcx> { - fn describe(tcx: TyCtxt<'_, '_, '_>, key: (DefId, &'tcx Substs<'tcx>)) -> Cow<'static, str> { + fn describe(tcx: TyCtxt<'_, '_, '_>, key: (DefId, SubstsRef<'tcx>)) -> Cow<'static, str> { format!("testing substituted normalized predicates:`{}`", tcx.item_path_str(key.0)).into() } } diff --git a/src/librustc/ty/query/keys.rs b/src/librustc/ty/query/keys.rs index f5eb7374cc19b..d353da801778d 100644 --- a/src/librustc/ty/query/keys.rs +++ b/src/librustc/ty/query/keys.rs @@ -4,7 +4,7 @@ use crate::infer::canonical::Canonical; use crate::hir::def_id::{CrateNum, DefId, LOCAL_CRATE, DefIndex}; use crate::traits; use crate::ty::{self, Ty, TyCtxt}; -use crate::ty::subst::Substs; +use crate::ty::subst::SubstsRef; use crate::ty::fast_reject::SimplifiedType; use crate::mir; @@ -109,7 +109,7 @@ impl Key for (DefId, SimplifiedType) { } } -impl<'tcx> Key for (DefId, &'tcx Substs<'tcx>) { +impl<'tcx> Key for (DefId, SubstsRef<'tcx>) { fn query_crate(&self) -> CrateNum { self.0.krate } diff --git a/src/librustc/ty/query/mod.rs b/src/librustc/ty/query/mod.rs index 740875109d029..ee36a1af8f400 100644 --- a/src/librustc/ty/query/mod.rs +++ b/src/librustc/ty/query/mod.rs @@ -36,8 +36,8 @@ use crate::traits::specialization_graph; use crate::traits::Clauses; use crate::ty::{self, CrateInherentImpls, ParamEnvAnd, Ty, TyCtxt, AdtSizedConstraint}; use crate::ty::steal::Steal; -use crate::ty::subst::Substs; use crate::ty::util::NeedsDrop; +use crate::ty::subst::SubstsRef; use crate::util::nodemap::{DefIdSet, DefIdMap, ItemLocalSet}; use crate::util::common::{ErrorReported}; use crate::util::profiling::ProfileCategory::*; @@ -393,7 +393,7 @@ define_queries! { <'tcx> Other { [] fn vtable_methods: vtable_methods_node(ty::PolyTraitRef<'tcx>) - -> Lrc)>>>, + -> Lrc)>>>, }, Codegen { @@ -493,9 +493,9 @@ define_queries! { <'tcx> Codegen { [] fn upstream_monomorphizations: UpstreamMonomorphizations(CrateNum) - -> Lrc, CrateNum>>>>, + -> Lrc, CrateNum>>>>, [] fn upstream_monomorphizations_for: UpstreamMonomorphizationsFor(DefId) - -> Option, CrateNum>>>, + -> Option, CrateNum>>>, }, Other { @@ -714,7 +714,7 @@ define_queries! { <'tcx> >, [] fn substitute_normalize_and_test_predicates: - substitute_normalize_and_test_predicates_node((DefId, &'tcx Substs<'tcx>)) -> bool, + substitute_normalize_and_test_predicates_node((DefId, SubstsRef<'tcx>)) -> bool, [] fn method_autoderef_steps: MethodAutoderefSteps( CanonicalTyGoal<'tcx> @@ -906,7 +906,7 @@ fn vtable_methods_node<'tcx>(trait_ref: ty::PolyTraitRef<'tcx>) -> DepConstructo DepConstructor::VtableMethods{ trait_ref } } -fn substitute_normalize_and_test_predicates_node<'tcx>(key: (DefId, &'tcx Substs<'tcx>)) +fn substitute_normalize_and_test_predicates_node<'tcx>(key: (DefId, SubstsRef<'tcx>)) -> DepConstructor<'tcx> { DepConstructor::SubstituteNormalizeAndTestPredicates { key } } diff --git a/src/librustc/ty/relate.rs b/src/librustc/ty/relate.rs index db248072d9b50..b15aa86290166 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, Substs}; +use crate::ty::subst::{Kind, UnpackedKind, SubstsRef}; use crate::ty::{self, Ty, TyCtxt, TypeFoldable}; use crate::ty::error::{ExpectedFound, TypeError}; use crate::mir::interpret::GlobalId; @@ -50,9 +50,9 @@ pub trait TypeRelation<'a, 'gcx: 'a+'tcx, 'tcx: 'a> : Sized { /// accordingly. fn relate_item_substs(&mut self, item_def_id: DefId, - a_subst: &'tcx Substs<'tcx>, - b_subst: &'tcx Substs<'tcx>) - -> RelateResult<'tcx, &'tcx Substs<'tcx>> + a_subst: SubstsRef<'tcx>, + b_subst: SubstsRef<'tcx>) + -> RelateResult<'tcx, SubstsRef<'tcx>> { debug!("relate_item_substs(item_def_id={:?}, a_subst={:?}, b_subst={:?})", item_def_id, @@ -123,9 +123,9 @@ impl<'tcx> Relate<'tcx> for ty::TypeAndMut<'tcx> { pub fn relate_substs<'a, 'gcx, 'tcx, R>(relation: &mut R, variances: Option<&Vec>, - a_subst: &'tcx Substs<'tcx>, - b_subst: &'tcx Substs<'tcx>) - -> RelateResult<'tcx, &'tcx Substs<'tcx>> + a_subst: SubstsRef<'tcx>, + b_subst: SubstsRef<'tcx>) + -> RelateResult<'tcx, SubstsRef<'tcx>> where R: TypeRelation<'a, 'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a { let tcx = relation.tcx(); @@ -624,11 +624,11 @@ impl<'tcx> Relate<'tcx> for ty::GeneratorSubsts<'tcx> { } } -impl<'tcx> Relate<'tcx> for &'tcx Substs<'tcx> { +impl<'tcx> Relate<'tcx> for SubstsRef<'tcx> { fn relate<'a, 'gcx, R>(relation: &mut R, - a: &&'tcx Substs<'tcx>, - b: &&'tcx Substs<'tcx>) - -> RelateResult<'tcx, &'tcx Substs<'tcx>> + a: &SubstsRef<'tcx>, + b: &SubstsRef<'tcx>) + -> RelateResult<'tcx, SubstsRef<'tcx>> where R: TypeRelation<'a, 'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a { relate_substs(relation, None, a, b) diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index dd382ec006bd7..31399fbab0a37 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -7,7 +7,7 @@ use crate::mir::interpret::{ConstValue, truncate}; use crate::middle::region; use polonius_engine::Atom; use rustc_data_structures::indexed_vec::Idx; -use crate::ty::subst::{Substs, Subst, Kind, UnpackedKind}; +use crate::ty::subst::{Substs, Subst, SubstsRef, Kind, UnpackedKind}; use crate::ty::{self, AdtDef, TypeFlags, Ty, TyCtxt, TypeFoldable}; use crate::ty::{List, TyS, ParamEnvAnd, ParamEnv}; use crate::util::captures::Captures; @@ -105,7 +105,7 @@ pub enum TyKind<'tcx> { /// That is, even after substitution it is possible that there are type /// variables. This happens when the `Adt` corresponds to an ADT /// definition and not a concrete use of it. - Adt(&'tcx AdtDef, &'tcx Substs<'tcx>), + Adt(&'tcx AdtDef, SubstsRef<'tcx>), /// An unsized FFI type that is opaque to Rust. Written as `extern type T`. Foreign(DefId), @@ -136,7 +136,7 @@ pub enum TyKind<'tcx> { /// fn foo() -> i32 { 1 } /// let bar = foo; // bar: fn() -> i32 {foo} /// ``` - FnDef(DefId, &'tcx Substs<'tcx>), + FnDef(DefId, SubstsRef<'tcx>), /// A pointer to a function. Written as `fn() -> i32`. /// @@ -184,7 +184,7 @@ pub enum TyKind<'tcx> { /// * or the `existential type` declaration /// The substitutions are for the generics of the function in question. /// After typeck, the concrete type can be found in the `types` map. - Opaque(DefId, &'tcx Substs<'tcx>), + Opaque(DefId, SubstsRef<'tcx>), /// A type parameter; for example, `T` in `fn f(x: T) {} Param(ParamTy), @@ -309,7 +309,7 @@ pub struct ClosureSubsts<'tcx> { /// /// These are separated out because codegen wants to pass them around /// when monomorphizing. - pub substs: &'tcx Substs<'tcx>, + pub substs: SubstsRef<'tcx>, } /// Struct returned by `split()`. Note that these are subslices of the @@ -387,7 +387,7 @@ impl<'tcx> ClosureSubsts<'tcx> { #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, RustcEncodable, RustcDecodable)] pub struct GeneratorSubsts<'tcx> { - pub substs: &'tcx Substs<'tcx>, + pub substs: SubstsRef<'tcx>, } struct SplitGeneratorSubsts<'tcx> { @@ -672,11 +672,11 @@ impl<'tcx> Binder<&'tcx List>> { #[derive(Copy, Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)] pub struct TraitRef<'tcx> { pub def_id: DefId, - pub substs: &'tcx Substs<'tcx>, + pub substs: SubstsRef<'tcx>, } impl<'tcx> TraitRef<'tcx> { - pub fn new(def_id: DefId, substs: &'tcx Substs<'tcx>) -> TraitRef<'tcx> { + pub fn new(def_id: DefId, substs: SubstsRef<'tcx>) -> TraitRef<'tcx> { TraitRef { def_id: def_id, substs: substs } } @@ -742,7 +742,7 @@ impl<'tcx> PolyTraitRef<'tcx> { #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)] pub struct ExistentialTraitRef<'tcx> { pub def_id: DefId, - pub substs: &'tcx Substs<'tcx>, + pub substs: SubstsRef<'tcx>, } impl<'a, 'gcx, 'tcx> ExistentialTraitRef<'tcx> { @@ -915,7 +915,7 @@ impl Binder { #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, RustcEncodable, RustcDecodable)] pub struct ProjectionTy<'tcx> { /// The parameters of the associated item. - pub substs: &'tcx Substs<'tcx>, + pub substs: SubstsRef<'tcx>, /// The `DefId` of the `TraitItem` for the associated type `N`. /// @@ -1297,7 +1297,7 @@ impl From for BoundTy { #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, RustcEncodable, RustcDecodable)] pub struct ExistentialProjection<'tcx> { pub item_def_id: DefId, - pub substs: &'tcx Substs<'tcx>, + pub substs: SubstsRef<'tcx>, pub ty: Ty<'tcx>, } @@ -2060,7 +2060,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { /// Used in the HIR by using `Unevaluated` everywhere and later normalizing to `Evaluated` if the /// code is monomorphic enough for that. pub enum LazyConst<'tcx> { - Unevaluated(DefId, &'tcx Substs<'tcx>), + Unevaluated(DefId, SubstsRef<'tcx>), Evaluated(Const<'tcx>), } diff --git a/src/librustc/ty/subst.rs b/src/librustc/ty/subst.rs index 7559ea90b1782..0e033b116a2ac 100644 --- a/src/librustc/ty/subst.rs +++ b/src/librustc/ty/subst.rs @@ -159,10 +159,12 @@ impl<'tcx> Decodable for Kind<'tcx> { /// A substitution mapping generic parameters to new values. pub type Substs<'tcx> = List>; +pub type SubstsRef<'tcx> = &'tcx Substs<'tcx>; + impl<'a, 'gcx, 'tcx> Substs<'tcx> { /// Creates a `Substs` that maps each generic parameter to itself. pub fn identity_for_item(tcx: TyCtxt<'a, 'gcx, 'tcx>, def_id: DefId) - -> &'tcx Substs<'tcx> { + -> SubstsRef<'tcx> { Substs::for_item(tcx, def_id, |param, _| { tcx.mk_param_from_def(param) }) @@ -175,7 +177,7 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> { pub fn bound_vars_for_item( tcx: TyCtxt<'a, 'gcx, 'tcx>, def_id: DefId - ) -> &'tcx Substs<'tcx> { + ) -> SubstsRef<'tcx> { Substs::for_item(tcx, def_id, |param, _| { match param.kind { ty::GenericParamDefKind::Type { .. } => { @@ -205,7 +207,7 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> { pub fn for_item(tcx: TyCtxt<'a, 'gcx, 'tcx>, def_id: DefId, mut mk_kind: F) - -> &'tcx Substs<'tcx> + -> SubstsRef<'tcx> where F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Kind<'tcx> { let defs = tcx.generics_of(def_id); @@ -219,7 +221,7 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> { tcx: TyCtxt<'a, 'gcx, 'tcx>, def_id: DefId, mut mk_kind: F) - -> &'tcx Substs<'tcx> + -> SubstsRef<'tcx> where F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Kind<'tcx> { Substs::for_item(tcx, def_id, |param, substs| { @@ -312,18 +314,18 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> { pub fn rebase_onto(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, source_ancestor: DefId, target_substs: &Substs<'tcx>) - -> &'tcx Substs<'tcx> { + -> SubstsRef<'tcx> { let defs = tcx.generics_of(source_ancestor); tcx.mk_substs(target_substs.iter().chain(&self[defs.params.len()..]).cloned()) } pub fn truncate_to(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, generics: &ty::Generics) - -> &'tcx Substs<'tcx> { + -> SubstsRef<'tcx> { tcx.mk_substs(self.iter().take(generics.count()).cloned()) } } -impl<'tcx> TypeFoldable<'tcx> for &'tcx Substs<'tcx> { +impl<'tcx> TypeFoldable<'tcx> for SubstsRef<'tcx> { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { let params: SmallVec<[_; 8]> = self.iter().map(|k| k.fold_with(folder)).collect(); @@ -341,7 +343,7 @@ impl<'tcx> TypeFoldable<'tcx> for &'tcx Substs<'tcx> { } } -impl<'tcx> serialize::UseSpecializedDecodable for &'tcx Substs<'tcx> {} +impl<'tcx> serialize::UseSpecializedDecodable for SubstsRef<'tcx> {} /////////////////////////////////////////////////////////////////////////// // Public trait `Subst` @@ -563,7 +565,7 @@ pub type CanonicalUserSubsts<'tcx> = Canonical<'tcx, UserSubsts<'tcx>>; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)] pub struct UserSubsts<'tcx> { /// The substitutions for the item as given by the user. - pub substs: &'tcx Substs<'tcx>, + pub substs: SubstsRef<'tcx>, /// The self type, in the case of a `::Item` path (when applied /// to an inherent impl). See `UserSelfTy` below. diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index 1ba7c3bba797c..a7b0807249252 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -7,7 +7,7 @@ use crate::hir::{self, Node}; use crate::ich::NodeIdHashingMode; use crate::traits::{self, ObligationCause}; use crate::ty::{self, Ty, TyCtxt, GenericParamDefKind, TypeFoldable}; -use crate::ty::subst::{Subst, Substs, UnpackedKind}; +use crate::ty::subst::{Subst, Substs, SubstsRef, UnpackedKind}; use crate::ty::query::TyCtxtAt; use crate::ty::TyKind::*; use crate::ty::layout::{Integer, IntegerExt}; @@ -588,7 +588,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { /// Given the `DefId` of some item that has no type parameters, make /// a suitable "empty substs" for it. - pub fn empty_substs_for_def_id(self, item_def_id: DefId) -> &'tcx Substs<'tcx> { + pub fn empty_substs_for_def_id(self, item_def_id: DefId) -> SubstsRef<'tcx> { Substs::for_item(self, item_def_id, |param, _| { match param.kind { GenericParamDefKind::Lifetime => self.types.re_erased.into(), @@ -633,7 +633,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn try_expand_impl_trait_type( self, def_id: DefId, - substs: &'tcx Substs<'tcx>, + substs: SubstsRef<'tcx>, ) -> Result, Ty<'tcx>> { use crate::ty::fold::TypeFolder; @@ -652,7 +652,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { fn expand_opaque_ty( &mut self, def_id: DefId, - substs: &'tcx Substs<'tcx>, + substs: SubstsRef<'tcx>, ) -> Option> { if self.found_recursion { None diff --git a/src/librustc_codegen_ssa/back/symbol_export.rs b/src/librustc_codegen_ssa/back/symbol_export.rs index 16f5880b13f5b..4b01e264f19ed 100644 --- a/src/librustc_codegen_ssa/back/symbol_export.rs +++ b/src/librustc_codegen_ssa/back/symbol_export.rs @@ -11,7 +11,7 @@ use rustc::middle::exported_symbols::{SymbolExportLevel, ExportedSymbol, metadat use rustc::session::config; use rustc::ty::{TyCtxt, SymbolName}; use rustc::ty::query::Providers; -use rustc::ty::subst::Substs; +use rustc::ty::subst::SubstsRef; use rustc::util::nodemap::{FxHashMap, DefIdMap}; use rustc_allocator::ALLOCATOR_METHODS; use rustc_data_structures::indexed_vec::IndexVec; @@ -282,7 +282,7 @@ fn exported_symbols_provider_local<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn upstream_monomorphizations_provider<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, cnum: CrateNum) - -> Lrc, CrateNum>>>> + -> Lrc, CrateNum>>>> { debug_assert!(cnum == LOCAL_CRATE); @@ -334,7 +334,7 @@ fn upstream_monomorphizations_provider<'a, 'tcx>( fn upstream_monomorphizations_for_provider<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) - -> Option, CrateNum>>> + -> Option, CrateNum>>> { debug_assert!(!def_id.is_local()); tcx.upstream_monomorphizations(LOCAL_CRATE) diff --git a/src/librustc_codegen_ssa/callee.rs b/src/librustc_codegen_ssa/callee.rs index 3665d45d1e9c7..4744dd6302fb3 100644 --- a/src/librustc_codegen_ssa/callee.rs +++ b/src/librustc_codegen_ssa/callee.rs @@ -1,12 +1,12 @@ use crate::traits::*; use rustc::ty; -use rustc::ty::subst::Substs; +use rustc::ty::subst::SubstsRef; use rustc::hir::def_id::DefId; pub fn resolve_and_get_fn<'tcx, Cx: CodegenMethods<'tcx>>( cx: &Cx, def_id: DefId, - substs: &'tcx Substs<'tcx>, + substs: SubstsRef<'tcx>, ) -> Cx::Value { cx.get_fn( ty::Instance::resolve( @@ -23,7 +23,7 @@ pub fn resolve_and_get_fn_for_vtable<'tcx, >( cx: &Cx, def_id: DefId, - substs: &'tcx Substs<'tcx>, + substs: SubstsRef<'tcx>, ) -> Cx::Value { cx.get_fn( ty::Instance::resolve_for_vtable( diff --git a/src/librustc_codegen_ssa/mir/mod.rs b/src/librustc_codegen_ssa/mir/mod.rs index 203d84bff5bb3..e1528921a5962 100644 --- a/src/librustc_codegen_ssa/mir/mod.rs +++ b/src/librustc_codegen_ssa/mir/mod.rs @@ -2,7 +2,7 @@ use libc::c_uint; use rustc::ty::{self, Ty, TypeFoldable, UpvarSubsts}; use rustc::ty::layout::{TyLayout, HasTyCtxt}; use rustc::mir::{self, Mir}; -use rustc::ty::subst::Substs; +use rustc::ty::subst::SubstsRef; use rustc::session::config::DebugInfo; use rustc_mir::monomorphize::Instance; use rustc_target::abi::call::{FnType, PassMode}; @@ -85,7 +85,7 @@ pub struct FunctionCx<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> { scopes: IndexVec>, /// If this function is being monomorphized, this contains the type substitutions used. - param_substs: &'tcx Substs<'tcx>, + param_substs: SubstsRef<'tcx>, } impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { diff --git a/src/librustc_codegen_utils/symbol_names.rs b/src/librustc_codegen_utils/symbol_names.rs index 8d105853d92f1..f529cf30a62ea 100644 --- a/src/librustc_codegen_utils/symbol_names.rs +++ b/src/librustc_codegen_utils/symbol_names.rs @@ -94,7 +94,7 @@ use rustc::hir::map::definitions::DefPathData; use rustc::ich::NodeIdHashingMode; use rustc::ty::item_path::{self, ItemPathBuffer, RootMode}; use rustc::ty::query::Providers; -use rustc::ty::subst::Substs; +use rustc::ty::subst::SubstsRef; use rustc::ty::{self, Ty, TyCtxt, TypeFoldable}; use rustc::util::common::record_time; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; @@ -134,7 +134,7 @@ fn get_symbol_hash<'a, 'tcx>( // values for generic type parameters, // if any. - substs: &'tcx Substs<'tcx>, + substs: SubstsRef<'tcx>, ) -> u64 { debug!( "get_symbol_hash(def_id={:?}, parameters={:?})", diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index b6fd641234933..a56c3215f9d69 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -1,7 +1,7 @@ #![allow(non_snake_case)] use rustc::hir::Node; -use rustc::ty::subst::Substs; +use rustc::ty::subst::SubstsRef; use rustc::ty::{self, AdtKind, ParamEnv, Ty, TyCtxt}; use rustc::ty::layout::{self, IntegerExt, LayoutOf, VariantIdx}; use rustc::{lint, util}; @@ -445,7 +445,7 @@ enum FfiResult<'tcx> { /// FIXME: This duplicates code in codegen. fn is_repr_nullable_ptr<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def: &'tcx ty::AdtDef, - substs: &Substs<'tcx>) + substs: SubstsRef<'tcx>) -> bool { if def.variants.len() == 2 { let data_idx; diff --git a/src/librustc_mir/borrow_check/nll/constraint_generation.rs b/src/librustc_mir/borrow_check/nll/constraint_generation.rs index c02c2b4934cf4..9eb09b514741c 100644 --- a/src/librustc_mir/borrow_check/nll/constraint_generation.rs +++ b/src/librustc_mir/borrow_check/nll/constraint_generation.rs @@ -10,8 +10,8 @@ use rustc::mir::{BasicBlock, BasicBlockData, Location, Mir, Place, Rvalue}; use rustc::mir::{SourceInfo, Statement, Terminator}; use rustc::mir::UserTypeProjection; use rustc::ty::fold::TypeFoldable; -use rustc::ty::subst::Substs; use rustc::ty::{self, ClosureSubsts, GeneratorSubsts, RegionVid}; +use rustc::ty::subst::SubstsRef; pub(super) fn generate_constraints<'cx, 'gcx, 'tcx>( infcx: &InferCtxt<'cx, 'gcx, 'tcx>, @@ -50,7 +50,7 @@ impl<'cg, 'cx, 'gcx, 'tcx> Visitor<'tcx> for ConstraintGeneration<'cg, 'cx, 'gcx /// We sometimes have `substs` within an rvalue, or within a /// call. Make them live at the location where they appear. - fn visit_substs(&mut self, substs: &&'tcx Substs<'tcx>, location: Location) { + fn visit_substs(&mut self, substs: &SubstsRef<'tcx>, location: Location) { self.add_regular_live_constraint(*substs, location); self.super_substs(substs); } 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 089640ab7024b..cc01f632e075c 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 @@ -6,7 +6,7 @@ use rustc::hir; use rustc::hir::def_id::DefId; use rustc::infer::InferCtxt; use rustc::mir::Mir; -use rustc::ty::subst::{Substs, UnpackedKind}; +use rustc::ty::subst::{SubstsRef, UnpackedKind}; use rustc::ty::{self, RegionKind, RegionVid, Ty, TyCtxt}; use rustc::util::ppaux::RegionHighlightMode; use rustc_errors::DiagnosticBuilder; @@ -541,7 +541,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// types+hir to search through). fn match_adt_and_segment<'hir>( &self, - substs: &'tcx Substs<'tcx>, + substs: SubstsRef<'tcx>, needle_fr: RegionVid, last_segment: &'hir hir::PathSegment, counter: &mut usize, @@ -587,7 +587,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// `search_stack` the types+hir to search through. fn try_match_adt_and_generic_args<'hir>( &self, - substs: &'tcx Substs<'tcx>, + substs: SubstsRef<'tcx>, needle_fr: RegionVid, args: &'hir hir::GenericArgs, search_stack: &mut Vec<(Ty<'tcx>, &'hir hir::Ty)>, diff --git a/src/librustc_mir/borrow_check/nll/renumber.rs b/src/librustc_mir/borrow_check/nll/renumber.rs index e6a974fd8cc94..eab9e0ae171ed 100644 --- a/src/librustc_mir/borrow_check/nll/renumber.rs +++ b/src/librustc_mir/borrow_check/nll/renumber.rs @@ -1,4 +1,4 @@ -use rustc::ty::subst::Substs; +use rustc::ty::subst::SubstsRef; use rustc::ty::{self, ClosureSubsts, GeneratorSubsts, Ty, TypeFoldable}; use rustc::mir::{Location, Mir}; use rustc::mir::visit::{MutVisitor, TyContext}; @@ -55,7 +55,7 @@ impl<'a, 'gcx, 'tcx> MutVisitor<'tcx> for NLLVisitor<'a, 'gcx, 'tcx> { debug!("visit_ty: ty={:?}", ty); } - fn visit_substs(&mut self, substs: &mut &'tcx Substs<'tcx>, location: Location) { + fn visit_substs(&mut self, substs: &mut SubstsRef<'tcx>, location: Location) { debug!("visit_substs(substs={:?}, location={:?})", substs, location); *substs = self.renumber_regions(&{ *substs }); 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 49f90eb90aaf0..4202d10aa63d0 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::type_op::custom::CustomTypeOp; use rustc::traits::query::{Fallible, NoSolution}; use rustc::traits::{ObligationCause, PredicateObligations}; use rustc::ty::fold::TypeFoldable; -use rustc::ty::subst::{Subst, Substs, UnpackedKind, UserSubsts}; +use rustc::ty::subst::{Subst, SubstsRef, UnpackedKind, UserSubsts}; use rustc::ty::{ self, RegionVid, ToPolyTraitRef, Ty, TyCtxt, TyKind, UserType, CanonicalUserTypeAnnotation, UserTypeAnnotationIndex, @@ -2261,7 +2261,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { &mut self, tcx: TyCtxt<'a, 'gcx, 'tcx>, def_id: DefId, - substs: &'tcx Substs<'tcx>, + substs: SubstsRef<'tcx>, location: Location, ) -> ty::InstantiatedPredicates<'tcx> { if let Some(closure_region_requirements) = tcx.mir_borrowck(def_id).closure_requirements { diff --git a/src/librustc_mir/borrow_check/nll/universal_regions.rs b/src/librustc_mir/borrow_check/nll/universal_regions.rs index a5bf158257700..b418d608f080b 100644 --- a/src/librustc_mir/borrow_check/nll/universal_regions.rs +++ b/src/librustc_mir/borrow_check/nll/universal_regions.rs @@ -17,7 +17,7 @@ use rustc::hir::def_id::DefId; use rustc::hir::{self, BodyOwnerKind, HirId}; use rustc::infer::{InferCtxt, NLLRegionVariableOrigin}; use rustc::ty::fold::TypeFoldable; -use rustc::ty::subst::Substs; +use rustc::ty::subst::{Substs, SubstsRef}; use rustc::ty::{self, ClosureSubsts, GeneratorSubsts, RegionVid, Ty, TyCtxt}; use rustc::util::nodemap::FxHashMap; use rustc_data_structures::indexed_vec::{Idx, IndexVec}; @@ -94,12 +94,12 @@ pub enum DefiningTy<'tcx> { /// The MIR is a fn item with the given `DefId` and substs. The signature /// of the function can be bound then with the `fn_sig` query. - FnDef(DefId, &'tcx Substs<'tcx>), + FnDef(DefId, SubstsRef<'tcx>), /// The MIR represents some form of constant. The signature then /// is that it has no inputs and a single return value, which is /// the value of the constant. - Const(DefId, &'tcx Substs<'tcx>), + Const(DefId, SubstsRef<'tcx>), } impl<'tcx> DefiningTy<'tcx> { @@ -222,7 +222,7 @@ impl<'tcx> UniversalRegions<'tcx> { /// `V[1]: V[2]`. pub fn closure_mapping( tcx: TyCtxt<'_, '_, 'tcx>, - closure_substs: &'tcx Substs<'tcx>, + closure_substs: SubstsRef<'tcx>, expected_num_vars: usize, closure_base_def_id: DefId, ) -> IndexVec> { diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs index a9a16024302e9..19507c900da64 100644 --- a/src/librustc_mir/build/mod.rs +++ b/src/librustc_mir/build/mod.rs @@ -12,7 +12,7 @@ use rustc::middle::region; use rustc::mir::*; use rustc::mir::visit::{MutVisitor, TyContext}; use rustc::ty::{self, Ty, TyCtxt}; -use rustc::ty::subst::Substs; +use rustc::ty::subst::SubstsRef; use rustc::util::nodemap::NodeMap; use rustc_target::spec::PanicStrategy; use rustc_data_structures::indexed_vec::{IndexVec, Idx}; @@ -212,7 +212,7 @@ impl<'a, 'gcx: 'tcx, 'tcx> MutVisitor<'tcx> for GlobalizeMir<'a, 'gcx> { } } - fn visit_substs(&mut self, substs: &mut &'tcx Substs<'tcx>, _: Location) { + fn visit_substs(&mut self, substs: &mut SubstsRef<'tcx>, _: Location) { if let Some(lifted) = self.tcx.lift(substs) { *substs = lifted; } else { diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index 699ef7138cd93..c32a4fc3820fc 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -9,6 +9,7 @@ use rustc::mir::interpret::{GlobalId, ErrorHandled}; use rustc::ty::{self, AdtKind, Ty}; use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow, AutoBorrowMutability}; use rustc::ty::cast::CastKind as TyCastKind; +use rustc::ty::subst::{Substs, SubstsRef}; use rustc::hir; use rustc::hir::def_id::LocalDefId; use rustc::mir::BorrowKind; @@ -834,7 +835,7 @@ fn method_callee<'a, 'gcx, 'tcx>( cx: &mut Cx<'a, 'gcx, 'tcx>, expr: &hir::Expr, span: Span, - overloaded_callee: Option<(DefId, &'tcx Substs<'tcx>)>, + overloaded_callee: Option<(DefId, SubstsRef<'tcx>)>, ) -> Expr<'tcx> { let temp_lifetime = cx.region_scope_tree.temporary_scope(expr.hir_id.local_id); let (def_id, substs, user_ty) = match overloaded_callee { @@ -1133,7 +1134,7 @@ fn overloaded_place<'a, 'gcx, 'tcx>( cx: &mut Cx<'a, 'gcx, 'tcx>, expr: &'tcx hir::Expr, place_ty: Ty<'tcx>, - overloaded_callee: Option<(DefId, &'tcx Substs<'tcx>)>, + overloaded_callee: Option<(DefId, SubstsRef<'tcx>)>, args: Vec>, ) -> ExprKind<'tcx> { // For an overloaded *x or x[y] expression of type T, the method diff --git a/src/librustc_mir/hair/mod.rs b/src/librustc_mir/hair/mod.rs index fffa2ed3ec553..2efdacd7622c9 100644 --- a/src/librustc_mir/hair/mod.rs +++ b/src/librustc_mir/hair/mod.rs @@ -8,7 +8,7 @@ use rustc::mir::{BinOp, BorrowKind, Field, UnOp}; use rustc::hir::def_id::DefId; use rustc::infer::canonical::Canonical; use rustc::middle::region; -use rustc::ty::subst::Substs; +use rustc::ty::subst::SubstsRef; use rustc::ty::{AdtDef, UpvarSubsts, Ty, Const, LazyConst, UserType}; use rustc::ty::layout::VariantIdx; use rustc::hir; @@ -261,7 +261,7 @@ pub enum ExprKind<'tcx> { Adt { adt_def: &'tcx AdtDef, variant_index: VariantIdx, - substs: &'tcx Substs<'tcx>, + substs: SubstsRef<'tcx>, /// Optional user-given substs: for something like `let x = /// Bar:: { ... }`. diff --git a/src/librustc_mir/hair/pattern/check_match.rs b/src/librustc_mir/hair/pattern/check_match.rs index fff810b0e6f2c..085ac67cfb74a 100644 --- a/src/librustc_mir/hair/pattern/check_match.rs +++ b/src/librustc_mir/hair/pattern/check_match.rs @@ -11,7 +11,7 @@ use rustc::middle::mem_categorization::cmt_; use rustc::middle::region; use rustc::session::Session; use rustc::ty::{self, Ty, TyCtxt}; -use rustc::ty::subst::Substs; +use rustc::ty::subst::{Substs, SubstsRef}; use rustc::lint; use rustc_errors::{Applicability, DiagnosticBuilder}; use rustc::util::common::ErrorReported; @@ -64,7 +64,7 @@ struct MatchVisitor<'a, 'tcx: 'a> { tcx: TyCtxt<'a, 'tcx, 'tcx>, tables: &'a ty::TypeckTables<'tcx>, param_env: ty::ParamEnv<'tcx>, - identity_substs: &'tcx Substs<'tcx>, + identity_substs: SubstsRef<'tcx>, region_scope_tree: &'a region::ScopeTree, } diff --git a/src/librustc_mir/hair/pattern/mod.rs b/src/librustc_mir/hair/pattern/mod.rs index 9e5fdaa8afdf7..c234c2474ff1b 100644 --- a/src/librustc_mir/hair/pattern/mod.rs +++ b/src/librustc_mir/hair/pattern/mod.rs @@ -16,7 +16,7 @@ use rustc::mir::{UserTypeProjection}; use rustc::mir::interpret::{Scalar, GlobalId, ConstValue, sign_extend}; use rustc::ty::{self, Region, TyCtxt, AdtDef, Ty, Lift, UserType}; use rustc::ty::{CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations}; -use rustc::ty::subst::{Substs, Kind}; +use rustc::ty::subst::{SubstsRef, Kind}; use rustc::ty::layout::VariantIdx; use rustc::hir::{self, PatKind, RangeEnd}; use rustc::hir::def::{Def, CtorKind}; @@ -135,7 +135,7 @@ pub enum PatternKind<'tcx> { /// multiple variants. Variant { adt_def: &'tcx AdtDef, - substs: &'tcx Substs<'tcx>, + substs: SubstsRef<'tcx>, variant_index: VariantIdx, subpatterns: Vec>, }, @@ -330,13 +330,13 @@ pub struct PatternContext<'a, 'tcx: 'a> { pub tcx: TyCtxt<'a, 'tcx, 'tcx>, pub param_env: ty::ParamEnv<'tcx>, pub tables: &'a ty::TypeckTables<'tcx>, - pub substs: &'tcx Substs<'tcx>, + pub substs: SubstsRef<'tcx>, pub errors: Vec, } impl<'a, 'tcx> Pattern<'tcx> { pub fn from_hir(tcx: TyCtxt<'a, 'tcx, 'tcx>, - param_env_and_substs: ty::ParamEnvAnd<'tcx, &'tcx Substs<'tcx>>, + param_env_and_substs: ty::ParamEnvAnd<'tcx, SubstsRef<'tcx>>, tables: &'a ty::TypeckTables<'tcx>, pat: &'tcx hir::Pat) -> Self { let mut pcx = PatternContext::new(tcx, param_env_and_substs, tables); @@ -352,7 +352,7 @@ impl<'a, 'tcx> Pattern<'tcx> { impl<'a, 'tcx> PatternContext<'a, 'tcx> { pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>, - param_env_and_substs: ty::ParamEnvAnd<'tcx, &'tcx Substs<'tcx>>, + param_env_and_substs: ty::ParamEnvAnd<'tcx, SubstsRef<'tcx>>, tables: &'a ty::TypeckTables<'tcx>) -> Self { PatternContext { tcx, @@ -1093,7 +1093,7 @@ macro_rules! CloneImpls { CloneImpls!{ <'tcx> Span, Field, Mutability, ast::Name, ast::NodeId, usize, ty::Const<'tcx>, Region<'tcx>, Ty<'tcx>, BindingMode, &'tcx AdtDef, - &'tcx Substs<'tcx>, &'tcx Kind<'tcx>, UserType<'tcx>, + SubstsRef<'tcx>, &'tcx Kind<'tcx>, UserType<'tcx>, UserTypeProjection<'tcx>, PatternTypeProjection<'tcx> } diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index 0c1b5d65b8b68..8a32c3b636c71 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -9,7 +9,7 @@ use rustc::mir; use rustc::ty::layout::{ self, Size, Align, HasDataLayout, LayoutOf, TyLayout }; -use rustc::ty::subst::{Subst, Substs}; +use rustc::ty::subst::{Subst, SubstsRef}; use rustc::ty::{self, Ty, TyCtxt, TypeFoldable}; use rustc::ty::query::TyCtxtAt; use rustc_data_structures::indexed_vec::IndexVec; @@ -244,7 +244,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc pub(super) fn resolve( &self, def_id: DefId, - substs: &'tcx Substs<'tcx> + substs: SubstsRef<'tcx> ) -> EvalResult<'tcx, ty::Instance<'tcx>> { trace!("resolve: {:?}, {:#?}", def_id, substs); trace!("param_env: {:#?}", self.param_env); @@ -306,7 +306,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc fn monomorphize_with_substs + Subst<'tcx>>( &self, t: T, - substs: &'tcx Substs<'tcx> + substs: SubstsRef<'tcx> ) -> T { // miri doesn't care about lifetimes, and will choke on some crazy ones // let's simply get rid of them diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index dd7158897b889..2e4b8682437fe 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -180,7 +180,7 @@ use rustc::hir::itemlikevisit::ItemLikeVisitor; use rustc::hir::def_id::{DefId, LOCAL_CRATE}; use rustc::mir::interpret::{AllocId, ConstValue}; use rustc::middle::lang_items::{ExchangeMallocFnLangItem, StartFnLangItem}; -use rustc::ty::subst::Substs; +use rustc::ty::subst::{Substs, SubstsRef}; use rustc::ty::{self, TypeFoldable, Ty, TyCtxt, GenericParamDefKind}; use rustc::ty::adjustment::CustomCoerceUnsized; use rustc::session::config::EntryFnType; @@ -500,7 +500,7 @@ struct MirNeighborCollector<'a, 'tcx: 'a> { tcx: TyCtxt<'a, 'tcx, 'tcx>, mir: &'a mir::Mir<'tcx>, output: &'a mut Vec>, - param_substs: &'tcx Substs<'tcx>, + param_substs: SubstsRef<'tcx>, } impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> { @@ -748,7 +748,7 @@ fn should_monomorphize_locally<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: fn is_available_upstream_generic<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId, - substs: &'tcx Substs<'tcx>) + substs: SubstsRef<'tcx>) -> bool { debug_assert!(!def_id.is_local()); @@ -1218,7 +1218,7 @@ fn def_id_to_string<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn collect_lazy_const<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, constant: &ty::LazyConst<'tcx>, - param_substs: &'tcx Substs<'tcx>, + param_substs: SubstsRef<'tcx>, output: &mut Vec>, ) { let (def_id, substs) = match *constant { diff --git a/src/librustc_mir/transform/erase_regions.rs b/src/librustc_mir/transform/erase_regions.rs index 84f209f8776d9..9494d4b1f6c39 100644 --- a/src/librustc_mir/transform/erase_regions.rs +++ b/src/librustc_mir/transform/erase_regions.rs @@ -4,7 +4,7 @@ //! N.B., we do _not_ erase regions of statements that are relevant for //! "types-as-contracts"-validation, namely, `AcquireValid` and `ReleaseValid`. -use rustc::ty::subst::Substs; +use rustc::ty::subst::SubstsRef; use rustc::ty::{self, Ty, TyCtxt}; use rustc::mir::*; use rustc::mir::visit::{MutVisitor, TyContext}; @@ -36,7 +36,7 @@ impl<'a, 'tcx> MutVisitor<'tcx> for EraseRegionsVisitor<'a, 'tcx> { *constant = self.tcx.erase_regions(constant); } - fn visit_substs(&mut self, substs: &mut &'tcx Substs<'tcx>, _: Location) { + fn visit_substs(&mut self, substs: &mut SubstsRef<'tcx>, _: Location) { *substs = self.tcx.erase_regions(substs); } diff --git a/src/librustc_mir/transform/generator.rs b/src/librustc_mir/transform/generator.rs index 0866b87cf17e6..09142828f18af 100644 --- a/src/librustc_mir/transform/generator.rs +++ b/src/librustc_mir/transform/generator.rs @@ -55,7 +55,7 @@ use rustc::mir::*; use rustc::mir::visit::{PlaceContext, Visitor, MutVisitor}; use rustc::ty::{self, TyCtxt, AdtDef, Ty}; use rustc::ty::layout::VariantIdx; -use rustc::ty::subst::Substs; +use rustc::ty::subst::SubstsRef; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::indexed_vec::Idx; use rustc_data_structures::bit_set::BitSet; @@ -154,7 +154,7 @@ struct SuspensionPoint { struct TransformVisitor<'a, 'tcx: 'a> { tcx: TyCtxt<'a, 'tcx, 'tcx>, state_adt_ref: &'tcx AdtDef, - state_substs: &'tcx Substs<'tcx>, + state_substs: SubstsRef<'tcx>, // The index of the generator state in the generator struct state_field: usize, diff --git a/src/librustc_mir/transform/inline.rs b/src/librustc_mir/transform/inline.rs index 07ebbf6d0ebe3..56e4926090eac 100644 --- a/src/librustc_mir/transform/inline.rs +++ b/src/librustc_mir/transform/inline.rs @@ -9,7 +9,7 @@ use rustc_data_structures::indexed_vec::{Idx, IndexVec}; use rustc::mir::*; use rustc::mir::visit::*; use rustc::ty::{self, Instance, InstanceDef, ParamEnv, Ty, TyCtxt}; -use rustc::ty::subst::{Subst,Substs}; +use rustc::ty::subst::{Subst, SubstsRef}; use std::collections::VecDeque; use std::iter; @@ -32,7 +32,7 @@ pub struct Inline; #[derive(Copy, Clone, Debug)] struct CallSite<'tcx> { callee: DefId, - substs: &'tcx Substs<'tcx>, + substs: SubstsRef<'tcx>, bb: BasicBlock, location: SourceInfo, } diff --git a/src/librustc_mir/util/elaborate_drops.rs b/src/librustc_mir/util/elaborate_drops.rs index e86ece138301f..cf3ba1765406c 100644 --- a/src/librustc_mir/util/elaborate_drops.rs +++ b/src/librustc_mir/util/elaborate_drops.rs @@ -5,7 +5,7 @@ use rustc::middle::lang_items; use rustc::traits::Reveal; use rustc::ty::{self, Ty, TyCtxt}; use rustc::ty::layout::VariantIdx; -use rustc::ty::subst::Substs; +use rustc::ty::subst::SubstsRef; use rustc::ty::util::IntTypeExt; use rustc_data_structures::indexed_vec::Idx; use crate::util::patch::MirPatch; @@ -189,7 +189,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> base_place: &Place<'tcx>, variant_path: D::Path, variant: &'tcx ty::VariantDef, - substs: &'tcx Substs<'tcx>) + substs: SubstsRef<'tcx>) -> Vec<(Place<'tcx>, Option)> { variant.fields.iter().enumerate().map(|(i, f)| { @@ -328,7 +328,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> self.drop_ladder(fields, succ, unwind).0 } - fn open_drop_for_box<'a>(&mut self, adt: &'tcx ty::AdtDef, substs: &'tcx Substs<'tcx>) + fn open_drop_for_box<'a>(&mut self, adt: &'tcx ty::AdtDef, substs: SubstsRef<'tcx>) -> BasicBlock { debug!("open_drop_for_box({:?}, {:?}, {:?})", self, adt, substs); @@ -346,7 +346,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> self.drop_subpath(&interior, interior_path, succ, unwind_succ) } - fn open_drop_for_adt<'a>(&mut self, adt: &'tcx ty::AdtDef, substs: &'tcx Substs<'tcx>) + fn open_drop_for_adt<'a>(&mut self, adt: &'tcx ty::AdtDef, substs: SubstsRef<'tcx>) -> BasicBlock { debug!("open_drop_for_adt({:?}, {:?}, {:?})", self, adt, substs); if adt.variants.len() == 0 { @@ -376,7 +376,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> } fn open_drop_for_adt_contents(&mut self, adt: &'tcx ty::AdtDef, - substs: &'tcx Substs<'tcx>) + substs: SubstsRef<'tcx>) -> (BasicBlock, Unwind) { let (succ, unwind) = self.drop_ladder_bottom(); if !adt.is_enum() { @@ -393,7 +393,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> } fn open_drop_for_multivariant(&mut self, adt: &'tcx ty::AdtDef, - substs: &'tcx Substs<'tcx>, + substs: SubstsRef<'tcx>, succ: BasicBlock, unwind: Unwind) -> (BasicBlock, Unwind) { @@ -867,7 +867,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> fn box_free_block<'a>( &mut self, adt: &'tcx ty::AdtDef, - substs: &'tcx Substs<'tcx>, + substs: SubstsRef<'tcx>, target: BasicBlock, unwind: Unwind, ) -> BasicBlock { @@ -878,7 +878,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> fn unelaborated_free_block<'a>( &mut self, adt: &'tcx ty::AdtDef, - substs: &'tcx Substs<'tcx>, + substs: SubstsRef<'tcx>, target: BasicBlock, unwind: Unwind ) -> BasicBlock { diff --git a/src/librustc_passes/rvalue_promotion.rs b/src/librustc_passes/rvalue_promotion.rs index c25884df87ba1..105eb51874675 100644 --- a/src/librustc_passes/rvalue_promotion.rs +++ b/src/librustc_passes/rvalue_promotion.rs @@ -22,7 +22,7 @@ use rustc::middle::mem_categorization as mc; use rustc::middle::mem_categorization::Categorization; use rustc::ty::{self, Ty, TyCtxt}; use rustc::ty::query::Providers; -use rustc::ty::subst::Substs; +use rustc::ty::subst::{Substs, SubstsRef}; use rustc::util::nodemap::{ItemLocalSet, HirIdSet}; use rustc::hir; use rustc_data_structures::sync::Lrc; @@ -94,7 +94,7 @@ struct CheckCrateVisitor<'a, 'tcx: 'a> { in_static: bool, mut_rvalue_borrows: HirIdSet, param_env: ty::ParamEnv<'tcx>, - identity_substs: &'tcx Substs<'tcx>, + identity_substs: SubstsRef<'tcx>, tables: &'a ty::TypeckTables<'tcx>, result: ItemLocalSet, } diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index db63f2aafbc24..7e56c62c5f33a 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -14,7 +14,7 @@ use rustc::lint::builtin::AMBIGUOUS_ASSOCIATED_ITEMS; use rustc::traits; use rustc::ty::{self, Ty, TyCtxt, ToPredicate, TypeFoldable}; use rustc::ty::{GenericParamDef, GenericParamDefKind}; -use rustc::ty::subst::{Kind, Subst, Substs}; +use rustc::ty::subst::{Kind, Subst, Substs, SubstsRef}; use rustc::ty::wf::object_region_bounds; use rustc_data_structures::sync::Lrc; use rustc_target::spec::abi; @@ -177,7 +177,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { span: Span, def_id: DefId, item_segment: &hir::PathSegment) - -> &'tcx Substs<'tcx> + -> SubstsRef<'tcx> { let (substs, assoc_bindings, _) = item_segment.with_generic_args(|generic_args| { self.create_substs_for_ast_path( @@ -436,7 +436,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { 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>, - ) -> &'tcx Substs<'tcx> { + ) -> SubstsRef<'tcx> { // Collect the segments of the path; we need to substitute arguments // for parameters throughout the entire path (wherever there are // generic parameters). @@ -548,7 +548,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { generic_args: &hir::GenericArgs, infer_types: bool, self_ty: Option>) - -> (&'tcx Substs<'tcx>, Vec>, Option>) + -> (SubstsRef<'tcx>, Vec>, Option>) { // If the type is parameterized by this region, then replace this // region with the current anon region binding (in other words, @@ -760,7 +760,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { trait_def_id: DefId, self_ty: Ty<'tcx>, trait_segment: &hir::PathSegment, - ) -> (&'tcx Substs<'tcx>, Vec>, Option>) { + ) -> (SubstsRef<'tcx>, Vec>, Option>) { debug!("create_substs_for_ast_trait_ref(trait_segment={:?})", trait_segment); diff --git a/src/librustc_typeck/check/cast.rs b/src/librustc_typeck/check/cast.rs index 97ee973938ccb..87276b8c66ca4 100644 --- a/src/librustc_typeck/check/cast.rs +++ b/src/librustc_typeck/check/cast.rs @@ -37,9 +37,9 @@ use rustc::hir; use rustc::session::Session; use rustc::traits; use rustc::ty::{self, Ty, TypeFoldable, TypeAndMut}; +use rustc::ty::subst::SubstsRef; use rustc::ty::adjustment::AllowTwoPhase; use rustc::ty::cast::{CastKind, CastTy}; -use rustc::ty::subst::Substs; use rustc::middle::lang_items; use syntax::ast; use syntax_pos::Span; @@ -69,7 +69,7 @@ enum PointerKind<'tcx> { /// The unsize info of this projection OfProjection(&'tcx ty::ProjectionTy<'tcx>), /// The unsize info of this opaque ty - OfOpaque(DefId, &'tcx Substs<'tcx>), + OfOpaque(DefId, SubstsRef<'tcx>), /// The unsize info of this parameter OfParam(&'tcx ty::ParamTy), } diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index 1eaa8b17d09f7..996d6cfd56830 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -4,10 +4,9 @@ use crate::astconv::AstConv; use crate::check::{FnCtxt, PlaceOp, callee, Needs}; use crate::hir::GenericArg; use crate::hir::def_id::DefId; -use rustc::ty::subst::Substs; +use rustc::ty::subst::{Subst, SubstsRef}; use rustc::traits; use rustc::ty::{self, Ty, GenericParamDefKind}; -use rustc::ty::subst::Subst; use rustc::ty::adjustment::{Adjustment, Adjust, OverloadedDeref}; use rustc::ty::adjustment::{AllowTwoPhase, AutoBorrow, AutoBorrowMutability}; use rustc::ty::fold::TypeFoldable; @@ -209,7 +208,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> { fn fresh_receiver_substs(&mut self, self_ty: Ty<'tcx>, pick: &probe::Pick<'tcx>) - -> &'tcx Substs<'tcx> { + -> SubstsRef<'tcx> { match pick.kind { probe::InherentImplPick => { let impl_def_id = pick.item.container.id(); @@ -300,8 +299,8 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> { &mut self, pick: &probe::Pick<'tcx>, seg: &hir::PathSegment, - parent_substs: &Substs<'tcx>, - ) -> &'tcx Substs<'tcx> { + parent_substs: SubstsRef<'tcx>, + ) -> SubstsRef<'tcx> { // Determine the values for the generic parameters of the method. // If they were not explicitly supplied, just construct fresh // variables. @@ -369,7 +368,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> { // until we unify the `Self` type. fn instantiate_method_sig(&mut self, pick: &probe::Pick<'tcx>, - all_substs: &'tcx Substs<'tcx>) + all_substs: SubstsRef<'tcx>) -> (ty::FnSig<'tcx>, ty::InstantiatedPredicates<'tcx>) { debug!("instantiate_method_sig(pick={:?}, all_substs={:?})", pick, @@ -404,7 +403,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> { fn add_obligations(&mut self, fty: Ty<'tcx>, - all_substs: &Substs<'tcx>, + all_substs: SubstsRef<'tcx>, method_predicates: &ty::InstantiatedPredicates<'tcx>) { debug!("add_obligations: fty={:?} all_substs={:?} method_predicates={:?}", fty, diff --git a/src/librustc_typeck/check/method/mod.rs b/src/librustc_typeck/check/method/mod.rs index b14c56ddad008..cb6a862f06eee 100644 --- a/src/librustc_typeck/check/method/mod.rs +++ b/src/librustc_typeck/check/method/mod.rs @@ -18,7 +18,7 @@ use rustc::hir; use rustc::hir::def::Def; use rustc::hir::def_id::DefId; use rustc::traits; -use rustc::ty::subst::Substs; +use rustc::ty::subst::{Substs, SubstsRef}; use rustc::ty::{self, Ty, ToPredicate, ToPolyTraitRef, TraitRef, TypeFoldable}; use rustc::ty::GenericParamDefKind; use rustc::ty::subst::Subst; @@ -38,7 +38,7 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) { pub struct MethodCallee<'tcx> { /// Impl method ID, for inherent methods, or trait method ID, otherwise. pub def_id: DefId, - pub substs: &'tcx Substs<'tcx>, + pub substs: SubstsRef<'tcx>, /// Instantiated method signature, i.e., it has been /// substituted, normalized, and has had late-bound diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index 312d83cebbab3..0db9e3ed85fd6 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -13,7 +13,7 @@ use rustc_data_structures::sync::Lrc; use rustc::hir; use rustc::lint; use rustc::session::config::nightly_options; -use rustc::ty::subst::{Subst, Substs}; +use rustc::ty::subst::{Subst, Substs, SubstsRef}; use rustc::traits::{self, ObligationCause}; use rustc::traits::query::{CanonicalTyGoal}; use rustc::traits::query::method_autoderef::{CandidateStep, MethodAutoderefStepsResult}; @@ -125,7 +125,7 @@ struct Candidate<'tcx> { #[derive(Debug)] enum CandidateKind<'tcx> { - InherentImplCandidate(&'tcx Substs<'tcx>, + InherentImplCandidate(SubstsRef<'tcx>, // Normalize obligations Vec>), ObjectCandidate, @@ -1537,11 +1537,11 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { } /// Gets the type of an impl and generate substitutions with placeholders. - fn impl_ty_and_substs(&self, impl_def_id: DefId) -> (Ty<'tcx>, &'tcx Substs<'tcx>) { + fn impl_ty_and_substs(&self, impl_def_id: DefId) -> (Ty<'tcx>, SubstsRef<'tcx>) { (self.tcx.type_of(impl_def_id), self.fresh_item_substs(impl_def_id)) } - fn fresh_item_substs(&self, def_id: DefId) -> &'tcx Substs<'tcx> { + fn fresh_item_substs(&self, def_id: DefId) -> SubstsRef<'tcx> { Substs::for_item(self.tcx, def_id, |param, _| { match param.kind { GenericParamDefKind::Lifetime => self.tcx.types.re_erased.into(), diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index d77aabcda2d8d..fbbc65feb7377 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -109,7 +109,7 @@ use rustc::ty::{ use rustc::ty::adjustment::{Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability}; use rustc::ty::fold::TypeFoldable; use rustc::ty::query::Providers; -use rustc::ty::subst::{UnpackedKind, Subst, Substs, UserSelfTy, UserSubsts}; +use rustc::ty::subst::{UnpackedKind, Subst, Substs, SubstsRef, UserSelfTy, UserSubsts}; use rustc::ty::util::{Representability, IntTypeExt, Discr}; use rustc::ty::layout::VariantIdx; use syntax_pos::{self, BytePos, Span, MultiSpan}; @@ -1318,7 +1318,7 @@ fn check_union<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn check_opaque<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId, - substs: &'tcx Substs<'tcx>, + substs: SubstsRef<'tcx>, span: Span, ) { if let Err(partially_expanded_type) = tcx.try_expand_impl_trait_type(def_id, substs) { @@ -2200,7 +2200,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } - pub fn write_substs(&self, node_id: hir::HirId, substs: &'tcx Substs<'tcx>) { + pub fn write_substs(&self, node_id: hir::HirId, substs: SubstsRef<'tcx>) { if !substs.is_noop() { debug!("write_substs({:?}, {:?}) in fcx {}", node_id, @@ -2222,7 +2222,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { &self, hir_id: hir::HirId, def_id: DefId, - substs: &'tcx Substs<'tcx>, + substs: SubstsRef<'tcx>, user_self_ty: Option>, ) { debug!( diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index bd9b4fecbecc1..419796a2014e0 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -105,7 +105,7 @@ use rustc::session; use rustc::session::CompileIncomplete; use rustc::session::config::{EntryFnType, nightly_options}; use rustc::traits::{ObligationCause, ObligationCauseCode, TraitEngine, TraitEngineExt}; -use rustc::ty::subst::Substs; +use rustc::ty::subst::SubstsRef; use rustc::ty::{self, Ty, TyCtxt}; use rustc::ty::query::Providers; use rustc::util; @@ -116,7 +116,7 @@ use util::common::time; use std::iter; pub struct TypeAndSubsts<'tcx> { - substs: &'tcx Substs<'tcx>, + substs: SubstsRef<'tcx>, ty: Ty<'tcx>, } From cf1172978729ecaf62492622498f4ca75137c390 Mon Sep 17 00:00:00 2001 From: csmoe Date: Tue, 26 Feb 2019 09:30:34 +0800 Subject: [PATCH 2/2] rename Substs to InternalSubsts Change-Id: I3fa00e999a2ee4eb72db1fdf53a8633b49176a18 --- src/librustc/infer/error_reporting/mod.rs | 10 +++---- src/librustc/infer/mod.rs | 4 +-- src/librustc/infer/opaque_types/mod.rs | 4 +-- src/librustc/infer/outlives/verify.rs | 4 +-- src/librustc/traits/auto_trait.rs | 2 +- src/librustc/traits/codegen/mod.rs | 4 +-- src/librustc/traits/mod.rs | 6 ++-- src/librustc/traits/object_safety.rs | 22 +++++++++------ src/librustc/traits/project.rs | 6 ++-- src/librustc/traits/query/normalize.rs | 4 +-- src/librustc/traits/select.rs | 4 +-- src/librustc/traits/specialize/mod.rs | 4 +-- src/librustc/traits/util.rs | 4 +-- src/librustc/ty/context.rs | 14 +++++----- src/librustc/ty/flags.rs | 4 +-- src/librustc/ty/mod.rs | 12 ++++---- src/librustc/ty/sty.rs | 10 +++---- src/librustc/ty/subst.rs | 28 +++++++++---------- src/librustc/ty/util.rs | 4 +-- src/librustc/ty/walk.rs | 2 +- src/librustc/ty/wf.rs | 4 +-- src/librustc/util/ppaux.rs | 8 +++--- src/librustc_codegen_llvm/debuginfo/mod.rs | 4 +-- .../debuginfo/type_names.rs | 6 ++-- .../borrow_check/nll/region_infer/mod.rs | 6 ++-- .../borrow_check/nll/universal_regions.rs | 8 +++--- src/librustc_mir/hair/cx/expr.rs | 6 ++-- src/librustc_mir/hair/cx/mod.rs | 8 +++--- src/librustc_mir/hair/pattern/_match.rs | 4 +-- src/librustc_mir/hair/pattern/check_match.rs | 4 +-- src/librustc_mir/lints.rs | 4 +-- src/librustc_mir/monomorphize/collector.rs | 6 ++-- src/librustc_mir/monomorphize/item.rs | 6 ++-- src/librustc_mir/shim.rs | 6 ++-- src/librustc_mir/transform/const_prop.rs | 4 +-- src/librustc_passes/rvalue_promotion.rs | 6 ++-- src/librustc_privacy/lib.rs | 6 ++-- src/librustc_resolve/lib.rs | 2 +- .../chalk_context/program_clauses.rs | 4 +-- src/librustc_traits/dropck_outlives.rs | 4 +-- src/librustc_traits/generic_types.rs | 8 +++--- src/librustc_traits/lowering/mod.rs | 12 ++++---- src/librustc_typeck/astconv.rs | 6 ++-- src/librustc_typeck/check/closure.rs | 4 +-- src/librustc_typeck/check/coercion.rs | 2 +- src/librustc_typeck/check/compare_method.rs | 6 ++-- src/librustc_typeck/check/dropck.rs | 4 +-- src/librustc_typeck/check/method/mod.rs | 4 +-- src/librustc_typeck/check/method/probe.rs | 10 +++---- src/librustc_typeck/check/mod.rs | 18 ++++++------ src/librustc_typeck/check/regionck.rs | 4 +-- src/librustc_typeck/check/wfcheck.rs | 4 +-- src/librustc_typeck/collect.rs | 20 ++++++------- src/librustc_typeck/variance/constraints.rs | 6 ++-- src/librustdoc/clean/mod.rs | 12 ++++---- 55 files changed, 191 insertions(+), 187 deletions(-) diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index 705d9c4cf93ea..3dace2f2e89b0 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -56,7 +56,7 @@ use crate::hir::Node; use crate::middle::region; use crate::traits::{ObligationCause, ObligationCauseCode}; use crate::ty::error::TypeError; -use crate::ty::{self, subst::Subst, Region, Ty, TyCtxt, TyKind, TypeFoldable}; +use crate::ty::{self, subst::{Subst, SubstsRef}, Region, Ty, TyCtxt, TyKind, TypeFoldable}; use errors::{Applicability, DiagnosticBuilder, DiagnosticStyledString}; use std::{cmp, fmt}; use syntax_pos::{Pos, Span}; @@ -570,7 +570,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { value: &mut DiagnosticStyledString, other_value: &mut DiagnosticStyledString, name: String, - sub: &ty::subst::Substs<'tcx>, + sub: ty::subst::SubstsRef<'tcx>, pos: usize, other_ty: &Ty<'tcx>, ) { @@ -648,7 +648,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { mut t1_out: &mut DiagnosticStyledString, mut t2_out: &mut DiagnosticStyledString, path: String, - sub: &ty::subst::Substs<'tcx>, + sub: ty::subst::SubstsRef<'tcx>, other_path: String, other_ty: &Ty<'tcx>, ) -> Option<()> { @@ -687,8 +687,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { fn strip_generic_default_params( &self, def_id: DefId, - substs: &ty::subst::Substs<'tcx>, - ) -> &'tcx ty::subst::Substs<'tcx> { + substs: ty::subst::SubstsRef<'tcx>, + ) -> SubstsRef<'tcx> { let generics = self.tcx.generics_of(def_id); let mut num_supplied_defaults = 0; let mut type_params = generics diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index a02918a493948..84ad742d3c972 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -18,7 +18,7 @@ use crate::traits::{self, ObligationCause, PredicateObligations, TraitEngine}; use crate::ty::error::{ExpectedFound, TypeError, UnconstrainedNumeric}; use crate::ty::fold::TypeFoldable; use crate::ty::relate::RelateResult; -use crate::ty::subst::{Kind, Substs, SubstsRef}; +use crate::ty::subst::{Kind, InternalSubsts, SubstsRef}; use crate::ty::{self, GenericParamDefKind, Ty, TyCtxt, CtxtInterners}; use crate::ty::{FloatVid, IntVid, TyVid}; use crate::util::nodemap::FxHashMap; @@ -1089,7 +1089,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { /// Given a set of generics defined on a type or impl, returns a substitution mapping each /// type/region parameter to a fresh inference variable. pub fn fresh_substs_for_item(&self, span: Span, def_id: DefId) -> SubstsRef<'tcx> { - Substs::for_item(self.tcx, def_id, |param, _| self.var_for_def(span, param)) + InternalSubsts::for_item(self.tcx, def_id, |param, _| self.var_for_def(span, param)) } /// Returns `true` if errors have been reported since this infcx was diff --git a/src/librustc/infer/opaque_types/mod.rs b/src/librustc/infer/opaque_types/mod.rs index 079c2a12a8475..159bc1ceae26c 100644 --- a/src/librustc/infer/opaque_types/mod.rs +++ b/src/librustc/infer/opaque_types/mod.rs @@ -9,7 +9,7 @@ use crate::traits::{self, PredicateObligation}; use crate::ty::{self, Ty, TyCtxt, GenericParamDefKind}; use crate::ty::fold::{BottomUpFolder, TypeFoldable, TypeFolder}; use crate::ty::outlives::Component; -use crate::ty::subst::{Kind, Substs, SubstsRef, UnpackedKind}; +use crate::ty::subst::{Kind, InternalSubsts, SubstsRef, UnpackedKind}; use crate::util::nodemap::DefIdMap; pub type OpaqueTypeMap<'tcx> = DefIdMap>; @@ -437,7 +437,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { // lifetimes with 'static and remapping only those used in the // `impl Trait` return type, resulting in the parameters // shifting. - let id_substs = Substs::identity_for_item(gcx, def_id); + let id_substs = InternalSubsts::identity_for_item(gcx, def_id); let map: FxHashMap, Kind<'gcx>> = opaque_defn .substs .iter() diff --git a/src/librustc/infer/outlives/verify.rs b/src/librustc/infer/outlives/verify.rs index 494f708c6a7b7..e1ad5aeea19fc 100644 --- a/src/librustc/infer/outlives/verify.rs +++ b/src/librustc/infer/outlives/verify.rs @@ -2,7 +2,7 @@ use crate::hir::def_id::DefId; use crate::infer::outlives::env::RegionBoundPairs; use crate::infer::{GenericKind, VerifyBound}; use crate::traits; -use crate::ty::subst::{Subst, Substs}; +use crate::ty::subst::{Subst, InternalSubsts}; use crate::ty::{self, Ty, TyCtxt}; use crate::util::captures::Captures; @@ -292,7 +292,7 @@ impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> { .iter() .map(|(p, _)| *p) .collect(); - let identity_substs = Substs::identity_for_item(tcx, assoc_item_def_id); + let identity_substs = InternalSubsts::identity_for_item(tcx, assoc_item_def_id); let identity_proj = tcx.mk_projection(assoc_item_def_id, identity_substs); self.collect_outlives_from_predicate_list( move |ty| ty == identity_proj, diff --git a/src/librustc/traits/auto_trait.rs b/src/librustc/traits/auto_trait.rs index 60a3777abf844..e93351197fe47 100644 --- a/src/librustc/traits/auto_trait.rs +++ b/src/librustc/traits/auto_trait.rs @@ -631,7 +631,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { finished_map } - fn is_param_no_infer(&self, substs: &Substs<'_>) -> bool { + fn is_param_no_infer(&self, substs: SubstsRef<'_>) -> bool { return self.is_of_param(substs.type_at(0)) && !substs.types().any(|t| t.has_infer_types()); } diff --git a/src/librustc/traits/codegen/mod.rs b/src/librustc/traits/codegen/mod.rs index d6b7b3b99cacd..9b0a3820c859c 100644 --- a/src/librustc/traits/codegen/mod.rs +++ b/src/librustc/traits/codegen/mod.rs @@ -11,7 +11,7 @@ use syntax_pos::Span; use crate::traits::{FulfillmentContext, Obligation, ObligationCause, SelectionContext, TraitEngine, Vtable}; use crate::ty::{self, Ty, TyCtxt}; -use crate::ty::subst::{Subst, Substs}; +use crate::ty::subst::{Subst, SubstsRef}; use crate::ty::fold::TypeFoldable; /// Attempts to resolve an obligation to a vtable. The result is @@ -82,7 +82,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { /// types. pub fn subst_and_normalize_erasing_regions( self, - param_substs: &Substs<'tcx>, + param_substs: SubstsRef<'tcx>, param_env: ty::ParamEnv<'tcx>, value: &T ) -> T diff --git a/src/librustc/traits/mod.rs b/src/librustc/traits/mod.rs index 64ac874e8f1de..ee7893a27de7d 100644 --- a/src/librustc/traits/mod.rs +++ b/src/librustc/traits/mod.rs @@ -29,7 +29,7 @@ use crate::mir::interpret::ErrorHandled; use rustc_data_structures::sync::Lrc; use syntax::ast; use syntax_pos::{Span, DUMMY_SP}; -use crate::ty::subst::{Substs, SubstsRef}; +use crate::ty::subst::{InternalSubsts, SubstsRef}; use crate::ty::{self, AdtKind, List, Ty, TyCtxt, GenericParamDefKind, ToPredicate}; use crate::ty::error::{ExpectedFound, TypeError}; use crate::ty::fold::{TypeFolder, TypeFoldable, TypeVisitor}; @@ -992,7 +992,7 @@ fn vtable_methods<'a, 'tcx>( let trait_methods = tcx.associated_items(trait_ref.def_id()) .filter(|item| item.kind == ty::AssociatedKind::Method); - // Now list each method's DefId and Substs (for within its trait). + // Now list each method's DefId and InternalSubsts (for within its trait). // If the method can never be called from this object, produce None. trait_methods.map(move |trait_method| { debug!("vtable_methods: trait_method={:?}", trait_method); @@ -1007,7 +1007,7 @@ fn vtable_methods<'a, 'tcx>( // the method may have some early-bound lifetimes, add // regions for those let substs = trait_ref.map_bound(|trait_ref| - Substs::for_item(tcx, def_id, |param, _| + InternalSubsts::for_item(tcx, def_id, |param, _| match param.kind { GenericParamDefKind::Lifetime => tcx.types.re_erased.into(), GenericParamDefKind::Type {..} => { diff --git a/src/librustc/traits/object_safety.rs b/src/librustc/traits/object_safety.rs index 5c24b0ebfe05e..b2079c2516935 100644 --- a/src/librustc/traits/object_safety.rs +++ b/src/librustc/traits/object_safety.rs @@ -15,7 +15,7 @@ use crate::hir::def_id::DefId; use crate::lint; use crate::traits::{self, Obligation, ObligationCause}; use crate::ty::{self, Ty, TyCtxt, TypeFoldable, Predicate, ToPredicate}; -use crate::ty::subst::{Subst, Substs}; +use crate::ty::subst::{Subst, InternalSubsts}; use std::borrow::Cow; use std::iter::{self}; use syntax::ast::{self, Name}; @@ -406,7 +406,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { self, receiver_ty: Ty<'tcx>, self_ty: Ty<'tcx>, method_def_id: DefId ) -> Ty<'tcx> { debug!("receiver_for_self_ty({:?}, {:?}, {:?})", receiver_ty, self_ty, method_def_id); - let substs = Substs::for_item(self, method_def_id, |param, _| { + let substs = InternalSubsts::for_item(self, method_def_id, |param, _| { if param.index == 0 { self_ty.into() } else { @@ -559,13 +559,17 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { // U: Trait let trait_predicate = { - let substs = Substs::for_item(self, method.container.assert_trait(), |param, _| { - if param.index == 0 { - unsized_self_ty.into() - } else { - self.mk_param_from_def(param) - } - }); + let substs = InternalSubsts::for_item( + self, + method.container.assert_trait(), + |param, _| { + if param.index == 0 { + unsized_self_ty.into() + } else { + self.mk_param_from_def(param) + } + }, + ); ty::TraitRef { def_id: unsize_did, diff --git a/src/librustc/traits/project.rs b/src/librustc/traits/project.rs index 05141c9daf1d4..72df12bc535a6 100644 --- a/src/librustc/traits/project.rs +++ b/src/librustc/traits/project.rs @@ -18,7 +18,7 @@ use crate::infer::type_variable::TypeVariableOrigin; use crate::mir::interpret::{GlobalId}; use rustc_data_structures::snapshot_map::{Snapshot, SnapshotMap}; use syntax::ast::Ident; -use crate::ty::subst::{Subst, Substs}; +use crate::ty::subst::{Subst, InternalSubsts}; use crate::ty::{self, ToPredicate, ToPolyTraitRef, Ty, TyCtxt}; use crate::ty::fold::{TypeFoldable, TypeFolder}; use crate::util::common::FN_OUTPUT_NAME; @@ -401,7 +401,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for AssociatedTypeNormalizer<'a, let tcx = self.selcx.tcx().global_tcx(); if let Some(param_env) = self.tcx().lift_to_global(&self.param_env) { if substs.needs_infer() || substs.has_placeholders() { - let identity_substs = Substs::identity_for_item(tcx, def_id); + let identity_substs = InternalSubsts::identity_for_item(tcx, def_id); let instance = ty::Instance::resolve(tcx, param_env, def_id, identity_substs); if let Some(instance) = instance { let cid = GlobalId { @@ -1490,7 +1490,7 @@ fn confirm_impl_candidate<'cx, 'gcx, 'tcx>( } let substs = translate_substs(selcx.infcx(), param_env, impl_def_id, substs, assoc_ty.node); let ty = if let ty::AssociatedKind::Existential = assoc_ty.item.kind { - let item_substs = Substs::identity_for_item(tcx, assoc_ty.item.def_id); + let item_substs = InternalSubsts::identity_for_item(tcx, assoc_ty.item.def_id); tcx.mk_opaque(assoc_ty.item.def_id, item_substs) } else { tcx.type_of(assoc_ty.item.def_id) diff --git a/src/librustc/traits/query/normalize.rs b/src/librustc/traits/query/normalize.rs index 224076ce17e72..8a30c18d6e5f7 100644 --- a/src/librustc/traits/query/normalize.rs +++ b/src/librustc/traits/query/normalize.rs @@ -9,7 +9,7 @@ use crate::mir::interpret::GlobalId; use crate::traits::project::Normalized; use crate::traits::{Obligation, ObligationCause, PredicateObligation, Reveal}; use crate::ty::fold::{TypeFoldable, TypeFolder}; -use crate::ty::subst::{Subst, Substs}; +use crate::ty::subst::{Subst, InternalSubsts}; use crate::ty::{self, Ty, TyCtxt}; use super::NoSolution; @@ -193,7 +193,7 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for QueryNormalizer<'cx, 'gcx, 'tcx let tcx = self.infcx.tcx.global_tcx(); if let Some(param_env) = self.tcx().lift_to_global(&self.param_env) { if substs.needs_infer() || substs.has_placeholders() { - let identity_substs = Substs::identity_for_item(tcx, def_id); + let identity_substs = InternalSubsts::identity_for_item(tcx, def_id); let instance = ty::Instance::resolve(tcx, param_env, def_id, identity_substs); if let Some(instance) = instance { let cid = GlobalId { diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index 320b591ddcf7b..e85b84bce4321 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -34,7 +34,7 @@ use crate::middle::lang_items; use crate::mir::interpret::GlobalId; use crate::ty::fast_reject; use crate::ty::relate::TypeRelation; -use crate::ty::subst::{Subst, Substs, SubstsRef}; +use crate::ty::subst::{Subst, SubstsRef}; use crate::ty::{self, ToPolyTraitRef, ToPredicate, Ty, TyCtxt, TypeFoldable}; use crate::hir; @@ -3761,7 +3761,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { recursion_depth: usize, param_env: ty::ParamEnv<'tcx>, def_id: DefId, // of impl or trait - substs: &Substs<'tcx>, // for impl or trait + substs: SubstsRef<'tcx>, // for impl or trait ) -> Vec> { debug!("impl_or_trait_obligations(def_id={:?})", def_id); let tcx = self.tcx(); diff --git a/src/librustc/traits/specialize/mod.rs b/src/librustc/traits/specialize/mod.rs index 9a760065cb1fc..1d84f22acd9f8 100644 --- a/src/librustc/traits/specialize/mod.rs +++ b/src/librustc/traits/specialize/mod.rs @@ -20,7 +20,7 @@ use rustc_data_structures::sync::Lrc; use syntax_pos::DUMMY_SP; use crate::traits::select::IntercrateAmbiguityCause; use crate::ty::{self, TyCtxt, TypeFoldable}; -use crate::ty::subst::{Subst, Substs, SubstsRef}; +use crate::ty::subst::{Subst, InternalSubsts, SubstsRef}; use super::{SelectionContext, FulfillmentContext}; use super::util::impl_trait_ref_and_oblig; @@ -399,7 +399,7 @@ fn to_pretty_impl_header(tcx: TyCtxt<'_, '_, '_>, impl_def_id: DefId) -> Option< let mut w = "impl".to_owned(); - let substs = Substs::identity_for_item(tcx, impl_def_id); + let substs = InternalSubsts::identity_for_item(tcx, impl_def_id); // FIXME: Currently only handles ?Sized. // Needs to support ?Move and ?DynSized when they are implemented. diff --git a/src/librustc/traits/util.rs b/src/librustc/traits/util.rs index 754cc94073b10..c3223f0cd6331 100644 --- a/src/librustc/traits/util.rs +++ b/src/librustc/traits/util.rs @@ -3,7 +3,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, Substs}; +use crate::ty::subst::{Kind, Subst, SubstsRef}; use crate::util::nodemap::FxHashSet; use super::{Obligation, ObligationCause, PredicateObligation, SelectionContext, Normalized}; @@ -358,7 +358,7 @@ impl<'tcx, I: Iterator>> Iterator for FilterToTraits< pub fn impl_trait_ref_and_oblig<'a, 'gcx, 'tcx>(selcx: &mut SelectionContext<'a, 'gcx, 'tcx>, param_env: ty::ParamEnv<'tcx>, impl_def_id: DefId, - impl_substs: &Substs<'tcx>) + impl_substs: SubstsRef<'tcx>,) -> (ty::TraitRef<'tcx>, Vec>) { diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 68f21ce10788b..b37b632f4beec 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -22,7 +22,7 @@ use crate::middle::resolve_lifetime::{self, ObjectLifetimeDefault}; use crate::middle::stability; use crate::mir::{self, Mir, interpret, ProjectionKind}; use crate::mir::interpret::Allocation; -use crate::ty::subst::{Kind, Substs, Subst, SubstsRef}; +use crate::ty::subst::{Kind, InternalSubsts, Subst, SubstsRef}; use crate::ty::ReprOptions; use crate::traits; use crate::traits::{Clause, Clauses, GoalKind, Goal, Goals}; @@ -118,7 +118,7 @@ pub struct CtxtInterners<'tcx> { /// they're accessed quite often. type_: InternedSet<'tcx, TyS<'tcx>>, type_list: InternedSet<'tcx, List>>, - substs: InternedSet<'tcx, Substs<'tcx>>, + substs: InternedSet<'tcx, InternalSubsts<'tcx>>, canonical_var_infos: InternedSet<'tcx, List>, region: InternedSet<'tcx, RegionKind>, existential_predicates: InternedSet<'tcx, List>>, @@ -557,7 +557,7 @@ impl<'tcx> TypeckTables<'tcx> { pub fn node_substs(&self, id: hir::HirId) -> SubstsRef<'tcx> { validate_hir_id_for_typeck_tables(self.local_id_root, id, false); - self.node_substs.get(&id.local_id).cloned().unwrap_or_else(|| Substs::empty()) + self.node_substs.get(&id.local_id).cloned().unwrap_or_else(|| InternalSubsts::empty()) } pub fn node_substs_opt(&self, id: hir::HirId) -> Option> { @@ -1807,7 +1807,7 @@ nop_list_lift!{Predicate<'a> => Predicate<'tcx>} nop_list_lift!{CanonicalVarInfo => CanonicalVarInfo} nop_list_lift!{ProjectionKind<'a> => ProjectionKind<'tcx>} -// this is the impl for `&'a Substs<'a>` +// this is the impl for `&'a InternalSubsts<'a>` nop_list_lift!{Kind<'a> => Kind<'tcx>} impl<'a, 'tcx> Lift<'tcx> for &'a mir::interpret::Allocation { @@ -2183,7 +2183,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { Generator, GeneratorWitness, Dynamic, Closure, Tuple, Bound, Param, Infer, UnnormalizedProjection, Projection, Opaque, Foreign); - println!("Substs interner: #{}", self.interners.substs.borrow().len()); + println!("InternalSubsts interner: #{}", self.interners.substs.borrow().len()); println!("Region interner: #{}", self.interners.region.borrow().len()); println!("Stability interner: #{}", self.stability_interner.borrow().len()); println!("Allocation interner: #{}", self.allocation_interner.borrow().len()); @@ -2250,7 +2250,7 @@ impl<'tcx: 'lcx, 'lcx> Borrow<[CanonicalVarInfo]> for Interned<'tcx, List Borrow<[Kind<'lcx>]> for Interned<'tcx, Substs<'tcx>> { +impl<'tcx: 'lcx, 'lcx> Borrow<[Kind<'lcx>]> for Interned<'tcx, InternalSubsts<'tcx>> { fn borrow<'a>(&'a self) -> &'a [Kind<'lcx>] { &self.0[..] } @@ -2520,7 +2520,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn mk_box(self, ty: Ty<'tcx>) -> Ty<'tcx> { let def_id = self.require_lang_item(lang_items::OwnedBoxLangItem); let adt_def = self.adt_def(def_id); - let substs = Substs::for_item(self, def_id, |param, substs| { + let substs = InternalSubsts::for_item(self, def_id, |param, substs| { match param.kind { GenericParamDefKind::Lifetime => bug!(), GenericParamDefKind::Type { has_default, .. } => { diff --git a/src/librustc/ty/flags.rs b/src/librustc/ty/flags.rs index 25ec3e49cdf67..2b12dcca93ad7 100644 --- a/src/librustc/ty/flags.rs +++ b/src/librustc/ty/flags.rs @@ -1,4 +1,4 @@ -use crate::ty::subst::Substs; +use crate::ty::subst::SubstsRef; use crate::ty::{self, Ty, TypeFlags, TypeFoldable}; #[derive(Debug)] @@ -241,7 +241,7 @@ impl FlagComputation { self.add_substs(projection_ty.substs); } - fn add_substs(&mut self, substs: &Substs<'_>) { + fn add_substs(&mut self, substs: SubstsRef<'_>) { for ty in substs.types() { self.add_ty(ty); } diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index e098488824f36..5243c4dbfd209 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -22,7 +22,7 @@ use crate::session::CrateDisambiguator; use crate::traits::{self, Reveal}; use crate::ty; use crate::ty::layout::VariantIdx; -use crate::ty::subst::{Subst, Substs, SubstsRef}; +use crate::ty::subst::{Subst, InternalSubsts, SubstsRef}; use crate::ty::util::{IntTypeExt, Discr}; use crate::ty::walk::TypeWalker; use crate::util::captures::Captures; @@ -982,14 +982,14 @@ impl<'tcx> serialize::UseSpecializedEncodable for GenericPredicates<'tcx> {} impl<'tcx> serialize::UseSpecializedDecodable for GenericPredicates<'tcx> {} impl<'a, 'gcx, 'tcx> GenericPredicates<'tcx> { - pub fn instantiate(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, substs: &Substs<'tcx>) + pub fn instantiate(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, substs: SubstsRef<'tcx>) -> InstantiatedPredicates<'tcx> { let mut instantiated = InstantiatedPredicates::empty(); self.instantiate_into(tcx, &mut instantiated, substs); instantiated } - pub fn instantiate_own(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, substs: &Substs<'tcx>) + pub fn instantiate_own(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, substs: SubstsRef<'tcx>) -> InstantiatedPredicates<'tcx> { InstantiatedPredicates { predicates: self.predicates.iter().map(|(p, _)| p.subst(tcx, substs)).collect(), @@ -998,7 +998,7 @@ impl<'a, 'gcx, 'tcx> GenericPredicates<'tcx> { fn instantiate_into(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, instantiated: &mut InstantiatedPredicates<'tcx>, - substs: &Substs<'tcx>) { + substs: SubstsRef<'tcx>) { if let Some(def_id) = self.parent { tcx.predicates_of(def_id).instantiate_into(tcx, instantiated, substs); } @@ -2261,7 +2261,7 @@ impl<'a, 'gcx, 'tcx> AdtDef { ) -> Option> { let param_env = ParamEnv::empty(); let repr_type = self.repr.discr_type(); - let substs = Substs::identity_for_item(tcx.global_tcx(), expr_did); + let substs = InternalSubsts::identity_for_item(tcx.global_tcx(), expr_did); let instance = ty::Instance::new(expr_did, substs); let cid = GlobalId { instance, @@ -2463,7 +2463,7 @@ impl<'a, 'gcx, 'tcx> AdtDef { } impl<'a, 'gcx, 'tcx> FieldDef { - pub fn ty(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, subst: &Substs<'tcx>) -> Ty<'tcx> { + pub fn ty(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, subst: SubstsRef<'tcx>) -> Ty<'tcx> { tcx.type_of(self.did).subst(tcx, subst) } } diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index 31399fbab0a37..df8b14b1f10c7 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -7,7 +7,7 @@ use crate::mir::interpret::{ConstValue, truncate}; use crate::middle::region; use polonius_engine::Atom; use rustc_data_structures::indexed_vec::Idx; -use crate::ty::subst::{Substs, Subst, SubstsRef, Kind, UnpackedKind}; +use crate::ty::subst::{InternalSubsts, Subst, SubstsRef, Kind, UnpackedKind}; use crate::ty::{self, AdtDef, TypeFlags, Ty, TyCtxt, TypeFoldable}; use crate::ty::{List, TyS, ParamEnvAnd, ParamEnv}; use crate::util::captures::Captures; @@ -101,7 +101,7 @@ pub enum TyKind<'tcx> { /// Structures, enumerations and unions. /// - /// Substs here, possibly against intuition, *may* contain `Param`s. + /// InternalSubsts here, possibly against intuition, *may* contain `Param`s. /// That is, even after substitution it is possible that there are type /// variables. This happens when the `Adt` corresponds to an ADT /// definition and not a concrete use of it. @@ -685,7 +685,7 @@ impl<'tcx> TraitRef<'tcx> { pub fn identity<'a, 'gcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>, def_id: DefId) -> TraitRef<'tcx> { TraitRef { def_id, - substs: Substs::identity_for_item(tcx, def_id), + substs: InternalSubsts::identity_for_item(tcx, def_id), } } @@ -704,7 +704,7 @@ impl<'tcx> TraitRef<'tcx> { pub fn from_method(tcx: TyCtxt<'_, '_, 'tcx>, trait_id: DefId, - substs: &Substs<'tcx>) + substs: SubstsRef<'tcx>) -> ty::TraitRef<'tcx> { let defs = tcx.generics_of(trait_id); @@ -1120,7 +1120,7 @@ pub type Region<'tcx> = &'tcx RegionKind; /// These are regions that are stored behind a binder and must be substituted /// with some concrete region before being used. There are two kind of /// bound regions: early-bound, which are bound in an item's `Generics`, -/// and are substituted by a `Substs`, and late-bound, which are part of +/// and are substituted by a `InternalSubsts`, and late-bound, which are part of /// higher-ranked types (e.g., `for<'a> fn(&'a ())`), and are substituted by /// the likes of `liberate_late_bound_regions`. The distinction exists /// because higher-ranked lifetimes aren't supported in all places. See [1][2]. diff --git a/src/librustc/ty/subst.rs b/src/librustc/ty/subst.rs index 0e033b116a2ac..450fab81661fc 100644 --- a/src/librustc/ty/subst.rs +++ b/src/librustc/ty/subst.rs @@ -157,20 +157,20 @@ impl<'tcx> Decodable for Kind<'tcx> { } /// A substitution mapping generic parameters to new values. -pub type Substs<'tcx> = List>; +pub type InternalSubsts<'tcx> = List>; -pub type SubstsRef<'tcx> = &'tcx Substs<'tcx>; +pub type SubstsRef<'tcx> = &'tcx InternalSubsts<'tcx>; -impl<'a, 'gcx, 'tcx> Substs<'tcx> { - /// Creates a `Substs` that maps each generic parameter to itself. +impl<'a, 'gcx, 'tcx> InternalSubsts<'tcx> { + /// Creates a `InternalSubsts` that maps each generic parameter to itself. pub fn identity_for_item(tcx: TyCtxt<'a, 'gcx, 'tcx>, def_id: DefId) -> SubstsRef<'tcx> { - Substs::for_item(tcx, def_id, |param, _| { + Self::for_item(tcx, def_id, |param, _| { tcx.mk_param_from_def(param) }) } - /// Creates a `Substs` that maps each generic parameter to a higher-ranked + /// Creates a `InternalSubsts` that maps each generic parameter to a higher-ranked /// var bound at index `0`. For types, we use a `BoundVar` index equal to /// the type parameter index. For regions, we use the `BoundRegion::BrNamed` /// variant (which has a `DefId`). @@ -178,7 +178,7 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> { tcx: TyCtxt<'a, 'gcx, 'tcx>, def_id: DefId ) -> SubstsRef<'tcx> { - Substs::for_item(tcx, def_id, |param, _| { + Self::for_item(tcx, def_id, |param, _| { match param.kind { ty::GenericParamDefKind::Type { .. } => { tcx.mk_ty( @@ -199,9 +199,9 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> { }) } - /// Creates a `Substs` for generic parameter definitions, + /// Creates a `InternalSubsts` for generic parameter definitions, /// by calling closures to obtain each kind. - /// The closures get to observe the `Substs` as they're + /// The closures get to observe the `InternalSubsts` as they're /// being built, which can be used to correctly /// substitute defaults of generic parameters. pub fn for_item(tcx: TyCtxt<'a, 'gcx, 'tcx>, @@ -213,7 +213,7 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> { let defs = tcx.generics_of(def_id); let count = defs.count(); let mut substs = SmallVec::with_capacity(count); - Substs::fill_item(&mut substs, tcx, defs, &mut mk_kind); + Self::fill_item(&mut substs, tcx, defs, &mut mk_kind); tcx.intern_substs(&substs) } @@ -224,7 +224,7 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> { -> SubstsRef<'tcx> where F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Kind<'tcx> { - Substs::for_item(tcx, def_id, |param, substs| { + Self::for_item(tcx, def_id, |param, substs| { self.get(param.index as usize) .cloned() .unwrap_or_else(|| mk_kind(param, substs)) @@ -239,9 +239,9 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> { { if let Some(def_id) = defs.parent { let parent_defs = tcx.generics_of(def_id); - Substs::fill_item(substs, tcx, parent_defs, mk_kind); + Self::fill_item(substs, tcx, parent_defs, mk_kind); } - Substs::fill_single(substs, defs, mk_kind) + Self::fill_single(substs, defs, mk_kind) } fn fill_single(substs: &mut SmallVec<[Kind<'tcx>; 8]>, @@ -313,7 +313,7 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> { /// parameters (e.g., method parameters) on top of that base. pub fn rebase_onto(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, source_ancestor: DefId, - target_substs: &Substs<'tcx>) + target_substs: SubstsRef<'tcx>) -> SubstsRef<'tcx> { let defs = tcx.generics_of(source_ancestor); tcx.mk_substs(target_substs.iter().chain(&self[defs.params.len()..]).cloned()) diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index a7b0807249252..7374eba2e317b 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -7,7 +7,7 @@ use crate::hir::{self, Node}; use crate::ich::NodeIdHashingMode; use crate::traits::{self, ObligationCause}; use crate::ty::{self, Ty, TyCtxt, GenericParamDefKind, TypeFoldable}; -use crate::ty::subst::{Subst, Substs, SubstsRef, UnpackedKind}; +use crate::ty::subst::{Subst, InternalSubsts, SubstsRef, UnpackedKind}; use crate::ty::query::TyCtxtAt; use crate::ty::TyKind::*; use crate::ty::layout::{Integer, IntegerExt}; @@ -589,7 +589,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { /// Given the `DefId` of some item that has no type parameters, make /// a suitable "empty substs" for it. pub fn empty_substs_for_def_id(self, item_def_id: DefId) -> SubstsRef<'tcx> { - Substs::for_item(self, item_def_id, |param, _| { + InternalSubsts::for_item(self, item_def_id, |param, _| { match param.kind { GenericParamDefKind::Lifetime => self.types.re_erased.into(), GenericParamDefKind::Type {..} => { diff --git a/src/librustc/ty/walk.rs b/src/librustc/ty/walk.rs index 126f5290af513..d9f309ae58e03 100644 --- a/src/librustc/ty/walk.rs +++ b/src/librustc/ty/walk.rs @@ -99,7 +99,7 @@ fn push_subtypes<'tcx>(stack: &mut TypeWalkerStack<'tcx>, parent_ty: Ty<'tcx>) { (p.substs, Some(p.ty)), ty::ExistentialPredicate::AutoTrait(_) => // Empty iterator - (ty::Substs::empty(), None), + (ty::InternalSubsts::empty(), None), }; substs.types().rev().chain(opt_ty) diff --git a/src/librustc/ty/wf.rs b/src/librustc/ty/wf.rs index 282bf1219fa5c..599d38bc4ab6e 100644 --- a/src/librustc/ty/wf.rs +++ b/src/librustc/ty/wf.rs @@ -1,7 +1,7 @@ use crate::hir; use crate::hir::def_id::DefId; use crate::infer::InferCtxt; -use crate::ty::subst::Substs; +use crate::ty::subst::SubstsRef; use crate::traits; use crate::ty::{self, ToPredicate, Ty, TyCtxt, TypeFoldable}; use std::iter::once; @@ -432,7 +432,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> { fn nominal_obligations(&mut self, def_id: DefId, - substs: &Substs<'tcx>) + substs: SubstsRef<'tcx>) -> Vec> { let predicates = diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 768fd02e8238a..fbe9e3359bfeb 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -1,7 +1,7 @@ use crate::hir::def_id::DefId; use crate::hir::map::definitions::DefPathData; use crate::middle::region; -use crate::ty::subst::{self, Subst}; +use crate::ty::subst::{self, Subst, SubstsRef}; use crate::ty::{BrAnon, BrEnv, BrFresh, BrNamed}; use crate::ty::{Bool, Char, Adt}; use crate::ty::{Error, Str, Array, Slice, Float, FnDef, FnPtr}; @@ -384,7 +384,7 @@ impl PrintContext { fn parameterized(&mut self, f: &mut F, - substs: &subst::Substs<'_>, + substs: SubstsRef<'_>, did: DefId, projections: &[ty::ProjectionPredicate<'_>]) -> fmt::Result { @@ -692,7 +692,7 @@ pub fn identify_regions() -> bool { } pub fn parameterized(f: &mut F, - substs: &subst::Substs<'_>, + substs: SubstsRef<'_>, did: DefId, projections: &[ty::ProjectionPredicate<'_>]) -> fmt::Result { @@ -1290,7 +1290,7 @@ define_print! { Ok(()) } } - Foreign(def_id) => parameterized(f, subst::Substs::empty(), def_id, &[]), + Foreign(def_id) => parameterized(f, subst::InternalSubsts::empty(), def_id, &[]), Projection(ref data) => data.print(f, cx), UnnormalizedProjection(ref data) => { write!(f, "Unnormalized(")?; diff --git a/src/librustc_codegen_llvm/debuginfo/mod.rs b/src/librustc_codegen_llvm/debuginfo/mod.rs index ae6e16b31e7aa..c0869bb889afa 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::{Substs, UnpackedKind}; +use rustc::ty::subst::{SubstsRef, UnpackedKind}; use crate::abi::Abi; use crate::common::CodegenCx; @@ -399,7 +399,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { fn get_template_parameters<'ll, 'tcx>( cx: &CodegenCx<'ll, 'tcx>, generics: &ty::Generics, - substs: &Substs<'tcx>, + substs: SubstsRef<'tcx>, file_metadata: &'ll DIFile, name_to_append_suffix_to: &mut String, ) -> &'ll DIArray { diff --git a/src/librustc_codegen_llvm/debuginfo/type_names.rs b/src/librustc_codegen_llvm/debuginfo/type_names.rs index 32e930ac44c85..176c9b8c542b1 100644 --- a/src/librustc_codegen_llvm/debuginfo/type_names.rs +++ b/src/librustc_codegen_llvm/debuginfo/type_names.rs @@ -2,7 +2,7 @@ use crate::common::CodegenCx; use rustc::hir::def_id::DefId; -use rustc::ty::subst::Substs; +use rustc::ty::subst::SubstsRef; use rustc::ty::{self, Ty}; use rustc_codegen_ssa::traits::*; @@ -193,13 +193,13 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, } } - // Pushes the type parameters in the given `Substs` to the output string. + // Pushes the type parameters in the given `InternalSubsts` to the output string. // This ignores region parameters, since they can't reliably be // reconstructed for items from non-local crates. For local crates, this // would be possible but with inlining and LTO we have to use the least // common denominator - otherwise we would run into conflicts. fn push_type_params<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, - substs: &Substs<'tcx>, + substs: SubstsRef<'tcx>, output: &mut String) { if substs.types().next().is_none() { return; diff --git a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs index cbeb5dc206ee6..785f810d94159 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs @@ -14,7 +14,7 @@ use rustc::mir::{ ClosureOutlivesRequirement, ClosureOutlivesSubject, ClosureRegionRequirements, ConstraintCategory, Local, Location, Mir, }; -use rustc::ty::{self, RegionVid, Ty, TyCtxt, TypeFoldable}; +use rustc::ty::{self, subst::SubstsRef, RegionVid, Ty, TyCtxt, TypeFoldable}; use rustc::util::common::{self, ErrorReported}; use rustc_data_structures::bit_set::BitSet; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; @@ -1359,7 +1359,7 @@ pub trait ClosureRegionRequirementsExt<'gcx, 'tcx> { tcx: TyCtxt<'_, 'gcx, 'tcx>, location: Location, closure_def_id: DefId, - closure_substs: &'tcx ty::subst::Substs<'tcx>, + closure_substs: SubstsRef<'tcx>, ) -> Vec>; fn subst_closure_mapping( @@ -1390,7 +1390,7 @@ impl<'gcx, 'tcx> ClosureRegionRequirementsExt<'gcx, 'tcx> for ClosureRegionRequi tcx: TyCtxt<'_, 'gcx, 'tcx>, location: Location, closure_def_id: DefId, - closure_substs: &'tcx ty::subst::Substs<'tcx>, + closure_substs: SubstsRef<'tcx>, ) -> Vec> { debug!( "apply_requirements(location={:?}, closure_def_id={:?}, closure_substs={:?})", diff --git a/src/librustc_mir/borrow_check/nll/universal_regions.rs b/src/librustc_mir/borrow_check/nll/universal_regions.rs index b418d608f080b..4d9a3775b3123 100644 --- a/src/librustc_mir/borrow_check/nll/universal_regions.rs +++ b/src/librustc_mir/borrow_check/nll/universal_regions.rs @@ -17,7 +17,7 @@ use rustc::hir::def_id::DefId; use rustc::hir::{self, BodyOwnerKind, HirId}; use rustc::infer::{InferCtxt, NLLRegionVariableOrigin}; use rustc::ty::fold::TypeFoldable; -use rustc::ty::subst::{Substs, SubstsRef}; +use rustc::ty::subst::{InternalSubsts, SubstsRef}; use rustc::ty::{self, ClosureSubsts, GeneratorSubsts, RegionVid, Ty, TyCtxt}; use rustc::util::nodemap::FxHashMap; use rustc_data_structures::indexed_vec::{Idx, IndexVec}; @@ -138,7 +138,7 @@ struct UniversalRegionIndices<'tcx> { /// used because trait matching and type-checking will feed us /// region constraints that reference those regions and we need to /// be able to map them our internal `RegionVid`. This is - /// basically equivalent to a `Substs`, except that it also + /// basically equivalent to a `InternalSubsts`, except that it also /// contains an entry for `ReStatic` -- it might be nice to just /// use a substs, and then handle `ReStatic` another way. indices: FxHashMap, RegionVid>, @@ -507,7 +507,7 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> { BodyOwnerKind::Const | BodyOwnerKind::Static(..) => { assert_eq!(closure_base_def_id, self.mir_def_id); - let identity_substs = Substs::identity_for_item(tcx, closure_base_def_id); + let identity_substs = InternalSubsts::identity_for_item(tcx, closure_base_def_id); let substs = self.infcx .replace_free_regions_with_nll_infer_vars(FR, &identity_substs); DefiningTy::Const(self.mir_def_id, substs) @@ -527,7 +527,7 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> { let tcx = self.infcx.tcx; let gcx = tcx.global_tcx(); let closure_base_def_id = tcx.closure_base_def_id(self.mir_def_id); - let identity_substs = Substs::identity_for_item(gcx, closure_base_def_id); + let identity_substs = InternalSubsts::identity_for_item(gcx, closure_base_def_id); let fr_substs = match defining_ty { DefiningTy::Closure(_, ClosureSubsts { ref substs }) | DefiningTy::Generator(_, GeneratorSubsts { ref substs }, _) => { diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index c32a4fc3820fc..5548366db66ec 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -9,7 +9,7 @@ use rustc::mir::interpret::{GlobalId, ErrorHandled}; use rustc::ty::{self, AdtKind, Ty}; use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow, AutoBorrowMutability}; use rustc::ty::cast::CastKind as TyCastKind; -use rustc::ty::subst::{Substs, SubstsRef}; +use rustc::ty::subst::{InternalSubsts, SubstsRef}; use rustc::hir; use rustc::hir::def_id::LocalDefId; use rustc::mir::BorrowKind; @@ -561,7 +561,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, // Now comes the rote stuff: hir::ExprKind::Repeat(ref v, ref count) => { let def_id = cx.tcx.hir().local_def_id(count.id); - let substs = Substs::identity_for_item(cx.tcx.global_tcx(), def_id); + let substs = InternalSubsts::identity_for_item(cx.tcx.global_tcx(), def_id); let instance = ty::Instance::resolve( cx.tcx.global_tcx(), cx.param_env, @@ -717,7 +717,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, Some(did) => { // in case we are offsetting from a computed discriminant // and not the beginning of discriminants (which is always `0`) - let substs = Substs::identity_for_item(cx.tcx(), did); + let substs = InternalSubsts::identity_for_item(cx.tcx(), did); let lhs = mk_const(ty::LazyConst::Unevaluated(did, substs)); let bin = ExprKind::Binary { op: BinOp::Add, diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs index 9e19badf49db0..70f04fb892866 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, Substs}; +use rustc::ty::subst::{Kind, InternalSubsts}; use rustc::ty::layout::VariantIdx; use syntax::ast; use syntax::attr; @@ -29,8 +29,8 @@ pub struct Cx<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { pub root_lint_level: hir::HirId, pub param_env: ty::ParamEnv<'gcx>, - /// Identity `Substs` for use with const-evaluation. - pub identity_substs: &'gcx Substs<'gcx>, + /// Identity `InternalSubsts` for use with const-evaluation. + pub identity_substs: &'gcx InternalSubsts<'gcx>, pub region_scope_tree: Lrc, pub tables: &'a ty::TypeckTables<'gcx>, @@ -82,7 +82,7 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> { infcx, root_lint_level: lint_level, param_env: tcx.param_env(src_def_id), - identity_substs: Substs::identity_for_item(tcx.global_tcx(), src_def_id), + identity_substs: InternalSubsts::identity_for_item(tcx.global_tcx(), src_def_id), region_scope_tree: tcx.region_scope_tree(src_def_id), tables: tcx.typeck_tables_of(src_def_id), constness, diff --git a/src/librustc_mir/hair/pattern/_match.rs b/src/librustc_mir/hair/pattern/_match.rs index 10bef53e249c4..9e9a5d0f82ada 100644 --- a/src/librustc_mir/hair/pattern/_match.rs +++ b/src/librustc_mir/hair/pattern/_match.rs @@ -168,7 +168,7 @@ use super::{PatternFoldable, PatternFolder, compare_const_vals}; use rustc::hir::def_id::DefId; use rustc::hir::RangeEnd; -use rustc::ty::{self, Ty, TyCtxt, TypeFoldable, Const}; +use rustc::ty::{self, subst::SubstsRef, Ty, TyCtxt, TypeFoldable, Const}; use rustc::ty::layout::{Integer, IntegerExt, VariantIdx, Size}; use rustc::mir::Field; @@ -402,7 +402,7 @@ impl<'a, 'tcx> MatchCheckCtxt<'a, 'tcx> { fn is_variant_uninhabited(&self, variant: &'tcx ty::VariantDef, - substs: &'tcx ty::subst::Substs<'tcx>) + substs: SubstsRef<'tcx>) -> bool { if self.tcx.features().exhaustive_patterns { diff --git a/src/librustc_mir/hair/pattern/check_match.rs b/src/librustc_mir/hair/pattern/check_match.rs index 085ac67cfb74a..9cecf4af7d44a 100644 --- a/src/librustc_mir/hair/pattern/check_match.rs +++ b/src/librustc_mir/hair/pattern/check_match.rs @@ -11,7 +11,7 @@ use rustc::middle::mem_categorization::cmt_; use rustc::middle::region; use rustc::session::Session; use rustc::ty::{self, Ty, TyCtxt}; -use rustc::ty::subst::{Substs, SubstsRef}; +use rustc::ty::subst::{InternalSubsts, SubstsRef}; use rustc::lint; use rustc_errors::{Applicability, DiagnosticBuilder}; use rustc::util::common::ErrorReported; @@ -51,7 +51,7 @@ pub(crate) fn check_match<'a, 'tcx>( tables: tcx.body_tables(body_id), region_scope_tree: &tcx.region_scope_tree(def_id), param_env: tcx.param_env(def_id), - identity_substs: Substs::identity_for_item(tcx, def_id), + identity_substs: InternalSubsts::identity_for_item(tcx, def_id), }.visit_body(tcx.hir().body(body_id)); }) } diff --git a/src/librustc_mir/lints.rs b/src/librustc_mir/lints.rs index 6b6e8fcdc82cf..c795b412bfa93 100644 --- a/src/librustc_mir/lints.rs +++ b/src/librustc_mir/lints.rs @@ -5,7 +5,7 @@ use rustc::hir::map::blocks::FnLikeNode; use rustc::lint::builtin::UNCONDITIONAL_RECURSION; use rustc::mir::{self, Mir, TerminatorKind}; use rustc::ty::{AssociatedItem, AssociatedItemContainer, Instance, TyCtxt, TyKind}; -use rustc::ty::subst::Substs; +use rustc::ty::subst::InternalSubsts; pub fn check(tcx: TyCtxt<'a, 'tcx, 'tcx>, mir: &Mir<'tcx>, @@ -69,7 +69,7 @@ fn check_fn_for_unconditional_recursion(tcx: TyCtxt<'a, 'tcx, 'tcx>, }) => tcx.generics_of(trait_def_id).count(), _ => 0 }; - let caller_substs = &Substs::identity_for_item(tcx, def_id)[..trait_substs_count]; + let caller_substs = &InternalSubsts::identity_for_item(tcx, def_id)[..trait_substs_count]; while let Some(bb) = reachable_without_self_call_queue.pop() { if visited.contains(bb) { diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index 2e4b8682437fe..4cec306412e8b 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -180,7 +180,7 @@ use rustc::hir::itemlikevisit::ItemLikeVisitor; use rustc::hir::def_id::{DefId, LOCAL_CRATE}; use rustc::mir::interpret::{AllocId, ConstValue}; use rustc::middle::lang_items::{ExchangeMallocFnLangItem, StartFnLangItem}; -use rustc::ty::subst::{Substs, SubstsRef}; +use rustc::ty::subst::{InternalSubsts, SubstsRef}; use rustc::ty::{self, TypeFoldable, Ty, TyCtxt, GenericParamDefKind}; use rustc::ty::adjustment::CustomCoerceUnsized; use rustc::session::config::EntryFnType; @@ -956,7 +956,7 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> { debug!("RootCollector: ADT drop-glue for {}", def_id_to_string(self.tcx, def_id)); - let ty = Instance::new(def_id, Substs::empty()).ty(self.tcx); + let ty = Instance::new(def_id, InternalSubsts::empty()).ty(self.tcx); visit_drop_use(self.tcx, ty, true, self.output); } } @@ -1116,7 +1116,7 @@ fn create_mono_items_for_default_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, continue; } - let substs = Substs::for_item(tcx, method.def_id, |param, _| { + let substs = InternalSubsts::for_item(tcx, method.def_id, |param, _| { match param.kind { GenericParamDefKind::Lifetime => tcx.types.re_erased.into(), GenericParamDefKind::Type {..} => { diff --git a/src/librustc_mir/monomorphize/item.rs b/src/librustc_mir/monomorphize/item.rs index 6e639c3a1179a..a26a1a7861eb0 100644 --- a/src/librustc_mir/monomorphize/item.rs +++ b/src/librustc_mir/monomorphize/item.rs @@ -3,7 +3,7 @@ use rustc::hir; use rustc::hir::def_id::{DefId, LOCAL_CRATE}; use rustc::session::config::OptLevel; use rustc::ty::{self, Ty, TyCtxt, ClosureSubsts, GeneratorSubsts}; -use rustc::ty::subst::Substs; +use rustc::ty::subst::{SubstsRef, InternalSubsts}; use syntax::ast; use syntax::attr::InlineAttr; use std::fmt::{self, Write}; @@ -151,7 +151,7 @@ pub trait MonoItemExt<'a, 'tcx>: fmt::Debug { debug!("is_instantiable({:?})", self); let (def_id, substs) = match *self.as_mono_item() { MonoItem::Fn(ref instance) => (instance.def_id(), instance.substs), - MonoItem::Static(def_id) => (def_id, Substs::empty()), + MonoItem::Static(def_id) => (def_id, InternalSubsts::empty()), // global asm never has predicates MonoItem::GlobalAsm(..) => return true }; @@ -422,7 +422,7 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> { } fn push_type_params(&self, - substs: &Substs<'tcx>, + substs: SubstsRef<'tcx>, projections: I, output: &mut String, debug: bool) diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index d4145b8e47ea2..ce7c9af81cb07 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -4,7 +4,7 @@ use rustc::infer; use rustc::mir::*; use rustc::ty::{self, Ty, TyCtxt, GenericParamDefKind}; use rustc::ty::layout::VariantIdx; -use rustc::ty::subst::{Subst, Substs}; +use rustc::ty::subst::{Subst, InternalSubsts}; use rustc::ty::query::Providers; use rustc_data_structures::indexed_vec::{IndexVec, Idx}; @@ -183,7 +183,7 @@ fn build_drop_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let substs = if let Some(ty) = ty { tcx.intern_substs(&[ty.into()]) } else { - Substs::identity_for_item(tcx, def_id) + InternalSubsts::identity_for_item(tcx, def_id) }; let sig = tcx.fn_sig(def_id).subst(tcx, substs); let sig = tcx.erase_late_bound_regions(&sig); @@ -451,7 +451,7 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { ) { let tcx = self.tcx; - let substs = Substs::for_item(tcx, self.def_id, |param, _| { + let substs = InternalSubsts::for_item(tcx, self.def_id, |param, _| { match param.kind { GenericParamDefKind::Lifetime => tcx.types.re_erased.into(), GenericParamDefKind::Type {..} => ty.into(), diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index 8b17904c7b5b0..5ed0055e7c4f4 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -10,7 +10,7 @@ use rustc::mir::visit::{Visitor, PlaceContext, MutatingUseContext, NonMutatingUs use rustc::mir::interpret::{EvalErrorKind, Scalar, GlobalId, EvalResult}; use rustc::ty::{TyCtxt, self, Instance}; use syntax::source_map::{Span, DUMMY_SP}; -use rustc::ty::subst::Substs; +use rustc::ty::subst::InternalSubsts; use rustc_data_structures::indexed_vec::IndexVec; use rustc::ty::ParamEnv; use rustc::ty::layout::{ @@ -288,7 +288,7 @@ impl<'a, 'mir, 'tcx> ConstPropagator<'a, 'mir, 'tcx> { // FIXME: can't handle code with generics return None; } - let substs = Substs::identity_for_item(self.tcx, self.source.def_id()); + let substs = InternalSubsts::identity_for_item(self.tcx, self.source.def_id()); let instance = Instance::new(self.source.def_id(), substs); let cid = GlobalId { instance, diff --git a/src/librustc_passes/rvalue_promotion.rs b/src/librustc_passes/rvalue_promotion.rs index 105eb51874675..6b8e37b3b3133 100644 --- a/src/librustc_passes/rvalue_promotion.rs +++ b/src/librustc_passes/rvalue_promotion.rs @@ -22,7 +22,7 @@ use rustc::middle::mem_categorization as mc; use rustc::middle::mem_categorization::Categorization; use rustc::ty::{self, Ty, TyCtxt}; use rustc::ty::query::Providers; -use rustc::ty::subst::{Substs, SubstsRef}; +use rustc::ty::subst::{InternalSubsts, SubstsRef}; use rustc::util::nodemap::{ItemLocalSet, HirIdSet}; use rustc::hir; use rustc_data_structures::sync::Lrc; @@ -75,7 +75,7 @@ fn rvalue_promotable_map<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, in_static: false, mut_rvalue_borrows: Default::default(), param_env: ty::ParamEnv::empty(), - identity_substs: Substs::empty(), + identity_substs: InternalSubsts::empty(), result: ItemLocalSet::default(), }; @@ -199,7 +199,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> { self.tables = self.tcx.typeck_tables_of(item_def_id); self.param_env = self.tcx.param_env(item_def_id); - self.identity_substs = Substs::identity_for_item(self.tcx, item_def_id); + self.identity_substs = InternalSubsts::identity_for_item(self.tcx, item_def_id); let body = self.tcx.hir().body(body_id); diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 568e622bd34c2..27103ab99651b 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -20,7 +20,7 @@ use rustc::middle::privacy::{AccessLevel, AccessLevels}; use rustc::ty::{self, TyCtxt, Ty, TraitRef, TypeFoldable, GenericParamDefKind}; use rustc::ty::fold::TypeVisitor; use rustc::ty::query::Providers; -use rustc::ty::subst::Substs; +use rustc::ty::subst::InternalSubsts; use rustc::util::nodemap::HirIdSet; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::sync::Lrc; @@ -127,7 +127,7 @@ impl<'a, 'tcx, V> TypeVisitor<'tcx> for DefIdVisitorSkeleton<'_, 'a, 'tcx, V> { fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool { let tcx = self.def_id_visitor.tcx(); - // Substs are not visited here because they are visited below in `super_visit_with`. + // InternalSubsts are not visited here because they are visited below in `super_visit_with`. match ty.sty { ty::Adt(&ty::AdtDef { did: def_id, .. }, ..) | ty::Foreign(def_id) | @@ -180,7 +180,7 @@ impl<'a, 'tcx, V> TypeVisitor<'tcx> for DefIdVisitorSkeleton<'_, 'a, 'tcx, V> ty::ExistentialPredicate::Trait(trait_ref) => trait_ref, ty::ExistentialPredicate::Projection(proj) => proj.trait_ref(tcx), ty::ExistentialPredicate::AutoTrait(def_id) => - ty::ExistentialTraitRef { def_id, substs: Substs::empty() }, + ty::ExistentialTraitRef { def_id, substs: InternalSubsts::empty() }, }; let ty::ExistentialTraitRef { def_id, substs: _ } = trait_ref; if self.def_id_visitor.visit_def_id(def_id, "trait", &trait_ref) { diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 1a7744786d80e..ac572b652130c 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -863,7 +863,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Resolver<'a> { fn visit_generics(&mut self, generics: &'tcx Generics) { // For type parameter defaults, we have to ban access - // to following type parameters, as the Substs can only + // to following type parameters, as the InternalSubsts can only // provide previous type parameters as they're built. We // put all the parameters on the ban list and then remove // them one by one as they are processed and become available. diff --git a/src/librustc_traits/chalk_context/program_clauses.rs b/src/librustc_traits/chalk_context/program_clauses.rs index adfd26814db1e..4d8a67ca63863 100644 --- a/src/librustc_traits/chalk_context/program_clauses.rs +++ b/src/librustc_traits/chalk_context/program_clauses.rs @@ -10,7 +10,7 @@ use rustc::traits::{ Environment, }; use rustc::ty; -use rustc::ty::subst::{Substs, Subst}; +use rustc::ty::subst::{InternalSubsts, Subst}; use rustc::hir; use rustc::hir::def_id::DefId; use rustc_target::spec::abi; @@ -129,7 +129,7 @@ fn assemble_builtin_sized_impls<'tcx>( // Struct def ty::Adt(adt_def, _) => { - let substs = Substs::bound_vars_for_item(tcx, adt_def.did); + let substs = InternalSubsts::bound_vars_for_item(tcx, adt_def.did); let adt = tcx.mk_ty(ty::Adt(adt_def, substs)); let sized_constraint = adt_def.sized_constraint(tcx) .iter() diff --git a/src/librustc_traits/dropck_outlives.rs b/src/librustc_traits/dropck_outlives.rs index 7185c4ce44640..49fcb7cd83355 100644 --- a/src/librustc_traits/dropck_outlives.rs +++ b/src/librustc_traits/dropck_outlives.rs @@ -4,7 +4,7 @@ use rustc::traits::query::dropck_outlives::{DropckOutlivesResult, DtorckConstrai use rustc::traits::query::{CanonicalTyGoal, NoSolution}; use rustc::traits::{TraitEngine, Normalized, ObligationCause, TraitEngineExt}; use rustc::ty::query::Providers; -use rustc::ty::subst::{Subst, Substs}; +use rustc::ty::subst::{Subst, InternalSubsts}; use rustc::ty::{self, ParamEnvAnd, Ty, TyCtxt}; use rustc::util::nodemap::FxHashSet; use rustc_data_structures::sync::Lrc; @@ -291,7 +291,7 @@ crate fn adt_dtorck_constraint<'a, 'tcx>( if def.is_phantom_data() { // The first generic parameter here is guaranteed to be a type because it's // `PhantomData`. - let substs = Substs::identity_for_item(tcx, def_id); + let substs = InternalSubsts::identity_for_item(tcx, def_id); assert_eq!(substs.len(), 1); let result = DtorckConstraint { outlives: vec![], diff --git a/src/librustc_traits/generic_types.rs b/src/librustc_traits/generic_types.rs index 03511e1d76d05..634c024b06466 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::Substs; +use rustc::ty::subst::InternalSubsts; use rustc::hir; use rustc::hir::def_id::DefId; use rustc_target::spec::abi; @@ -64,17 +64,17 @@ crate fn ref_ty(tcx: ty::TyCtxt<'_, '_, 'tcx>, mutbl: hir::Mutability) -> Ty<'tc } crate fn fn_def(tcx: ty::TyCtxt<'_, '_, 'tcx>, def_id: DefId) -> Ty<'tcx> { - tcx.mk_ty(ty::FnDef(def_id, Substs::bound_vars_for_item(tcx, def_id))) + tcx.mk_ty(ty::FnDef(def_id, InternalSubsts::bound_vars_for_item(tcx, def_id))) } crate fn closure(tcx: ty::TyCtxt<'_, '_, 'tcx>, def_id: DefId) -> Ty<'tcx> { tcx.mk_closure(def_id, ty::ClosureSubsts { - substs: Substs::bound_vars_for_item(tcx, def_id), + substs: InternalSubsts::bound_vars_for_item(tcx, def_id), }) } crate fn generator(tcx: ty::TyCtxt<'_, '_, 'tcx>, def_id: DefId) -> Ty<'tcx> { tcx.mk_generator(def_id, ty::GeneratorSubsts { - substs: Substs::bound_vars_for_item(tcx, def_id), + substs: InternalSubsts::bound_vars_for_item(tcx, def_id), }, hir::GeneratorMovability::Movable) } diff --git a/src/librustc_traits/lowering/mod.rs b/src/librustc_traits/lowering/mod.rs index 908fdcfe7430f..d261b2382e7a6 100644 --- a/src/librustc_traits/lowering/mod.rs +++ b/src/librustc_traits/lowering/mod.rs @@ -18,7 +18,7 @@ use rustc::traits::{ }; use rustc::ty::query::Providers; use rustc::ty::{self, List, TyCtxt}; -use rustc::ty::subst::{Subst, Substs}; +use rustc::ty::subst::{Subst, InternalSubsts}; use syntax::ast; use std::iter; @@ -182,7 +182,7 @@ fn program_clauses_for_trait<'a, 'tcx>( // } // ``` - let bound_vars = Substs::bound_vars_for_item(tcx, def_id); + let bound_vars = InternalSubsts::bound_vars_for_item(tcx, def_id); // `Self: Trait` let trait_pred = ty::TraitPredicate { @@ -294,7 +294,7 @@ fn program_clauses_for_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId // } // ``` - let bound_vars = Substs::bound_vars_for_item(tcx, def_id); + let bound_vars = InternalSubsts::bound_vars_for_item(tcx, def_id); let trait_ref = tcx.impl_trait_ref(def_id) .expect("not an impl") @@ -336,7 +336,7 @@ pub fn program_clauses_for_type_def<'a, 'tcx>( // } // ``` - let bound_vars = Substs::bound_vars_for_item(tcx, def_id); + let bound_vars = InternalSubsts::bound_vars_for_item(tcx, def_id); // `Ty<...>` let ty = tcx.type_of(def_id).subst(tcx, bound_vars); @@ -426,7 +426,7 @@ pub fn program_clauses_for_associated_type_def<'a, 'tcx>( _ => bug!("not an trait container"), }; - let trait_bound_vars = Substs::bound_vars_for_item(tcx, trait_id); + let trait_bound_vars = InternalSubsts::bound_vars_for_item(tcx, trait_id); let trait_ref = ty::TraitRef { def_id: trait_id, substs: trait_bound_vars, @@ -564,7 +564,7 @@ pub fn program_clauses_for_associated_type_value<'a, 'tcx>( _ => bug!("not an impl container"), }; - let impl_bound_vars = Substs::bound_vars_for_item(tcx, impl_id); + let impl_bound_vars = InternalSubsts::bound_vars_for_item(tcx, impl_id); // `A0 as Trait` let trait_ref = tcx.impl_trait_ref(impl_id) diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 7e56c62c5f33a..6f3dc8b969cf4 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -14,7 +14,7 @@ use rustc::lint::builtin::AMBIGUOUS_ASSOCIATED_ITEMS; use rustc::traits; use rustc::ty::{self, Ty, TyCtxt, ToPredicate, TypeFoldable}; use rustc::ty::{GenericParamDef, GenericParamDefKind}; -use rustc::ty::subst::{Kind, Subst, Substs, SubstsRef}; +use rustc::ty::subst::{Kind, Subst, InternalSubsts, SubstsRef}; use rustc::ty::wf::object_region_bounds; use rustc_data_structures::sync::Lrc; use rustc_target::spec::abi; @@ -1798,7 +1798,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { } hir::TyKind::Array(ref ty, ref length) => { let length_def_id = tcx.hir().local_def_id(length.id); - let substs = Substs::identity_for_item(tcx, length_def_id); + let substs = InternalSubsts::identity_for_item(tcx, length_def_id); let length = ty::LazyConst::Unevaluated(length_def_id, substs); let length = tcx.mk_lazy_const(length); let array_ty = tcx.mk_ty(ty::Array(self.ast_ty_to_ty(&ty), length)); @@ -1839,7 +1839,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { let generics = tcx.generics_of(def_id); debug!("impl_trait_ty_to_ty: generics={:?}", generics); - let substs = Substs::for_item(tcx, def_id, |param, _| { + let substs = InternalSubsts::for_item(tcx, def_id, |param, _| { if let Some(i) = (param.index as usize).checked_sub(generics.parent_count) { // Our own parameters are the resolved lifetimes. match param.kind { diff --git a/src/librustc_typeck/check/closure.rs b/src/librustc_typeck/check/closure.rs index 220adc2de7b61..2a4b17a639956 100644 --- a/src/librustc_typeck/check/closure.rs +++ b/src/librustc_typeck/check/closure.rs @@ -12,7 +12,7 @@ use rustc::traits::Obligation; use rustc::traits::error_reporting::ArgKind; use rustc::ty::{self, Ty, GenericParamDefKind}; use rustc::ty::fold::TypeFoldable; -use rustc::ty::subst::Substs; +use rustc::ty::subst::InternalSubsts; use std::cmp; use std::iter; use rustc_target::spec::abi::Abi; @@ -95,7 +95,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // types of upvars. These will be unified during the upvar // inference phase (`upvar.rs`). let base_substs = - Substs::identity_for_item(self.tcx, self.tcx.closure_base_def_id(expr_def_id)); + InternalSubsts::identity_for_item(self.tcx, self.tcx.closure_base_def_id(expr_def_id)); let substs = base_substs.extend_to(self.tcx,expr_def_id, |param, _| { match param.kind { GenericParamDefKind::Lifetime => { diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index ebd7dad58fd03..64f61d5e5232e 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -823,7 +823,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { debug!("coercion::try_find_coercion_lub({:?}, {:?})", prev_ty, new_ty); // Special-case that coercion alone cannot handle: - // Two function item types of differing IDs or Substs. + // Two function item types of differing IDs or InternalSubsts. if let (&ty::FnDef(..), &ty::FnDef(..)) = (&prev_ty.sty, &new_ty.sty) { // Don't reify if the function types have a LUB, i.e., they // are the same function and their parameters have a LUB. diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index c6b34672e6b4c..e061a5304eb28 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -4,7 +4,7 @@ use rustc::ty::{self, TyCtxt, GenericParamDefKind}; use rustc::ty::util::ExplicitSelf; use rustc::traits::{self, ObligationCause, ObligationCauseCode, Reveal}; use rustc::ty::error::{ExpectedFound, TypeError}; -use rustc::ty::subst::{Subst, Substs}; +use rustc::ty::subst::{Subst, InternalSubsts, SubstsRef}; use rustc::util::common::ErrorReported; use errors::Applicability; @@ -160,7 +160,7 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // a fresh FulfillmentCtxt, and invoke select_all_or_error. // Create mapping from impl to placeholder. - let impl_to_skol_substs = Substs::identity_for_item(tcx, impl_m.def_id); + let impl_to_skol_substs = InternalSubsts::identity_for_item(tcx, impl_m.def_id); // Create mapping from trait to placeholder. let trait_to_skol_substs = impl_to_skol_substs.rebase_onto(tcx, @@ -361,7 +361,7 @@ fn check_region_bounds_on_impl_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, trait_m: &ty::AssociatedItem, trait_generics: &ty::Generics, impl_generics: &ty::Generics, - trait_to_skol_substs: &Substs<'tcx>) + trait_to_skol_substs: SubstsRef<'tcx>) -> Result<(), ErrorReported> { let trait_params = trait_generics.own_counts().lifetimes; let impl_params = impl_generics.own_counts().lifetimes; diff --git a/src/librustc_typeck/check/dropck.rs b/src/librustc_typeck/check/dropck.rs index ad74e78fecdcd..12c7484f0f921 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, Substs, UnpackedKind}; +use rustc::ty::subst::{Subst, SubstsRef, UnpackedKind}; use rustc::ty::{self, Ty, TyCtxt}; use crate::util::common::ErrorReported; @@ -145,7 +145,7 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'a, 'tcx>( drop_impl_did: DefId, dtor_predicates: &ty::GenericPredicates<'tcx>, self_type_did: DefId, - self_to_impl_substs: &Substs<'tcx>, + self_to_impl_substs: SubstsRef<'tcx>, ) -> Result<(), ErrorReported> { let mut result = Ok(()); diff --git a/src/librustc_typeck/check/method/mod.rs b/src/librustc_typeck/check/method/mod.rs index cb6a862f06eee..d81d24e6d2b03 100644 --- a/src/librustc_typeck/check/method/mod.rs +++ b/src/librustc_typeck/check/method/mod.rs @@ -18,7 +18,7 @@ use rustc::hir; use rustc::hir::def::Def; use rustc::hir::def_id::DefId; use rustc::traits; -use rustc::ty::subst::{Substs, SubstsRef}; +use rustc::ty::subst::{InternalSubsts, SubstsRef}; use rustc::ty::{self, Ty, ToPredicate, ToPolyTraitRef, TraitRef, TypeFoldable}; use rustc::ty::GenericParamDefKind; use rustc::ty::subst::Subst; @@ -281,7 +281,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { trait_def_id); // Construct a trait-reference `self_ty : Trait` - let substs = Substs::for_item(self.tcx, trait_def_id, |param, _| { + let substs = InternalSubsts::for_item(self.tcx, trait_def_id, |param, _| { match param.kind { GenericParamDefKind::Lifetime => {} GenericParamDefKind::Type {..} => { diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index 0db9e3ed85fd6..a4624eebcba83 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -13,7 +13,7 @@ use rustc_data_structures::sync::Lrc; use rustc::hir; use rustc::lint; use rustc::session::config::nightly_options; -use rustc::ty::subst::{Subst, Substs, SubstsRef}; +use rustc::ty::subst::{Subst, InternalSubsts, SubstsRef}; use rustc::traits::{self, ObligationCause}; use rustc::traits::query::{CanonicalTyGoal}; use rustc::traits::query::method_autoderef::{CandidateStep, MethodAutoderefStepsResult}; @@ -1480,7 +1480,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { fn xform_self_ty(&self, item: &ty::AssociatedItem, impl_ty: Ty<'tcx>, - substs: &Substs<'tcx>) + substs: SubstsRef<'tcx>) -> (Ty<'tcx>, Option>) { if item.kind == ty::AssociatedKind::Method && self.mode == Mode::MethodCall { let sig = self.xform_method_sig(item.def_id, substs); @@ -1492,7 +1492,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { fn xform_method_sig(&self, method: DefId, - substs: &Substs<'tcx>) + substs: SubstsRef<'tcx>) -> ty::FnSig<'tcx> { let fn_sig = self.tcx.fn_sig(method); @@ -1517,7 +1517,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { if generics.params.is_empty() { xform_fn_sig.subst(self.tcx, substs) } else { - let substs = Substs::for_item(self.tcx, method, |param, _| { + let substs = InternalSubsts::for_item(self.tcx, method, |param, _| { let i = param.index as usize; if i < substs.len() { substs[i] @@ -1542,7 +1542,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { } fn fresh_item_substs(&self, def_id: DefId) -> SubstsRef<'tcx> { - Substs::for_item(self.tcx, def_id, |param, _| { + InternalSubsts::for_item(self.tcx, def_id, |param, _| { match param.kind { GenericParamDefKind::Lifetime => self.tcx.types.re_erased.into(), GenericParamDefKind::Type {..} => { diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index fbbc65feb7377..202d8bec4e957 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -109,7 +109,7 @@ use rustc::ty::{ use rustc::ty::adjustment::{Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability}; use rustc::ty::fold::TypeFoldable; use rustc::ty::query::Providers; -use rustc::ty::subst::{UnpackedKind, Subst, Substs, SubstsRef, UserSelfTy, UserSubsts}; +use rustc::ty::subst::{UnpackedKind, Subst, InternalSubsts, SubstsRef, UserSelfTy, UserSubsts}; use rustc::ty::util::{Representability, IntTypeExt, Discr}; use rustc::ty::layout::VariantIdx; use syntax_pos::{self, BytePos, Span, MultiSpan}; @@ -1385,7 +1385,7 @@ pub fn check_item_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Ite hir::ItemKind::Existential(..) => { let def_id = tcx.hir().local_def_id(it.id); - let substs = Substs::identity_for_item(tcx, def_id); + let substs = InternalSubsts::identity_for_item(tcx, def_id); check_opaque(tcx, def_id, substs, it.span); } hir::ItemKind::Ty(..) => { @@ -1809,7 +1809,7 @@ fn check_transparent<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sp: Span, def_id: De // For each field, figure out if it's known to be a ZST and align(1) let field_infos = adt.non_enum_variant().fields.iter().map(|field| { - let ty = field.ty(tcx, Substs::identity_for_item(tcx, field.did)); + let ty = field.ty(tcx, InternalSubsts::identity_for_item(tcx, field.did)); let param_env = tcx.param_env(field.did); let layout = tcx.layout_of(param_env.and(ty)); // We are currently checking the type this field came from, so it must be local @@ -2177,7 +2177,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if !method_generics.params.is_empty() { let user_type_annotation = self.infcx.probe(|_| { let user_substs = UserSubsts { - substs: Substs::for_item(self.tcx, method.def_id, |param, _| { + substs: InternalSubsts::for_item(self.tcx, method.def_id, |param, _| { let i = param.index as usize; if i < method_generics.parent_count { self.infcx.var_for_def(DUMMY_SP, param) @@ -2303,7 +2303,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { /// types as well. This function combines the two. fn instantiate_type_scheme(&self, span: Span, - substs: &Substs<'tcx>, + substs: SubstsRef<'tcx>, value: &T) -> T where T : TypeFoldable<'tcx> @@ -2319,7 +2319,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { /// As `instantiate_type_scheme`, but for the bounds found in a /// generic type scheme. - fn instantiate_bounds(&self, span: Span, def_id: DefId, substs: &Substs<'tcx>) + fn instantiate_bounds(&self, span: Span, def_id: DefId, substs: SubstsRef<'tcx>) -> ty::InstantiatedPredicates<'tcx> { let bounds = self.tcx.predicates_of(def_id); let result = bounds.instantiate(self.tcx, substs); @@ -2477,7 +2477,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } /// Registers obligations that all types appearing in `substs` are well-formed. - pub fn add_wf_bounds(&self, substs: &Substs<'tcx>, expr: &hir::Expr) { + pub fn add_wf_bounds(&self, substs: SubstsRef<'tcx>, expr: &hir::Expr) { for ty in substs.types() { self.register_wf_obligation(ty, expr.span, traits::MiscObligation); } @@ -2521,7 +2521,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { pub fn field_ty(&self, span: Span, field: &'tcx ty::FieldDef, - substs: &Substs<'tcx>) + substs: SubstsRef<'tcx>) -> Ty<'tcx> { self.normalize_associated_types_in(span, &field.ty(self.tcx, substs)) @@ -4554,7 +4554,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { ExprKind::Repeat(ref element, ref count) => { let count_def_id = tcx.hir().local_def_id(count.id); let param_env = ty::ParamEnv::empty(); - let substs = Substs::identity_for_item(tcx.global_tcx(), count_def_id); + let substs = InternalSubsts::identity_for_item(tcx.global_tcx(), count_def_id); let instance = ty::Instance::resolve( tcx.global_tcx(), param_env, diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index bf4df19556d02..b549986777c84 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::Substs; +use rustc::ty::subst::SubstsRef; use rustc::ty::{self, Ty}; use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; @@ -1393,7 +1393,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> { fn substs_wf_in_scope( &mut self, origin: infer::ParameterOrigin, - substs: &Substs<'tcx>, + substs: SubstsRef<'tcx>, expr_span: Span, expr_region: ty::Region<'tcx>, ) { diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 9217484f3a7af..69f2a17fdf11c 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -4,7 +4,7 @@ use crate::constrained_type_params::{identify_constrained_type_params, Parameter use crate::hir::def_id::DefId; use rustc::traits::{self, ObligationCauseCode}; use rustc::ty::{self, Lift, Ty, TyCtxt, TyKind, GenericParamDefKind, TypeFoldable, ToPredicate}; -use rustc::ty::subst::{Subst, Substs}; +use rustc::ty::subst::{Subst, InternalSubsts}; use rustc::util::nodemap::{FxHashSet, FxHashMap}; use rustc::middle::lang_items; use rustc::infer::opaque_types::may_define_existential_type; @@ -459,7 +459,7 @@ fn check_where_clauses<'a, 'gcx, 'fcx, 'tcx>( // For more examples see tests `defaults-well-formedness.rs` and `type-check-defaults.rs`. // // First we build the defaulted substitution. - let substs = Substs::for_item(fcx.tcx, def_id, |param, _| { + let substs = InternalSubsts::for_item(fcx.tcx, def_id, |param, _| { match param.kind { GenericParamDefKind::Lifetime => { // All regions are identity. diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 2153582819c6f..167fb109567d5 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -23,7 +23,7 @@ use crate::middle::resolve_lifetime as rl; use crate::middle::weak_lang_items; use rustc::mir::mono::Linkage; use rustc::ty::query::Providers; -use rustc::ty::subst::{Subst, Substs}; +use rustc::ty::subst::{Subst, InternalSubsts}; use rustc::ty::util::Discr; use rustc::ty::util::IntTypeExt; use rustc::ty::subst::UnpackedKind; @@ -1149,7 +1149,7 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> { match tcx.hir().get(node_id) { Node::TraitItem(item) => match item.node { TraitItemKind::Method(..) => { - let substs = Substs::identity_for_item(tcx, def_id); + let substs = InternalSubsts::identity_for_item(tcx, def_id); tcx.mk_fn_def(def_id, substs) } TraitItemKind::Const(ref ty, _) | TraitItemKind::Type(_, Some(ref ty)) => icx.to_ty(ty), @@ -1160,7 +1160,7 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> { Node::ImplItem(item) => match item.node { ImplItemKind::Method(..) => { - let substs = Substs::identity_for_item(tcx, def_id); + let substs = InternalSubsts::identity_for_item(tcx, def_id); tcx.mk_fn_def(def_id, substs) } ImplItemKind::Const(ref ty, _) => icx.to_ty(ty), @@ -1193,12 +1193,12 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> { | ItemKind::Ty(ref t, _) | ItemKind::Impl(.., ref t, _) => icx.to_ty(t), ItemKind::Fn(..) => { - let substs = Substs::identity_for_item(tcx, def_id); + let substs = InternalSubsts::identity_for_item(tcx, def_id); tcx.mk_fn_def(def_id, substs) } ItemKind::Enum(..) | ItemKind::Struct(..) | ItemKind::Union(..) => { let def = tcx.adt_def(def_id); - let substs = Substs::identity_for_item(tcx, def_id); + let substs = InternalSubsts::identity_for_item(tcx, def_id); tcx.mk_adt(def, substs) } ItemKind::Existential(hir::ExistTy { @@ -1246,7 +1246,7 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> { Node::ForeignItem(foreign_item) => match foreign_item.node { ForeignItemKind::Fn(..) => { - let substs = Substs::identity_for_item(tcx, def_id); + let substs = InternalSubsts::identity_for_item(tcx, def_id); tcx.mk_fn_def(def_id, substs) } ForeignItemKind::Static(ref t, _) => icx.to_ty(t), @@ -1262,7 +1262,7 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> { tcx.type_of(tcx.hir().get_parent_did(node_id)) } VariantData::Tuple(..) => { - let substs = Substs::identity_for_item(tcx, def_id); + let substs = InternalSubsts::identity_for_item(tcx, def_id); tcx.mk_fn_def(def_id, substs) } }, @@ -1279,7 +1279,7 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> { } let substs = ty::ClosureSubsts { - substs: Substs::identity_for_item(tcx, def_id), + substs: InternalSubsts::identity_for_item(tcx, def_id), }; tcx.mk_closure(def_id, substs) @@ -1829,7 +1829,7 @@ fn explicit_predicates_of<'a, 'tcx>( Node::ImplItem(item) => match item.node { ImplItemKind::Existential(ref bounds) => { - let substs = Substs::identity_for_item(tcx, def_id); + let substs = InternalSubsts::identity_for_item(tcx, def_id); let opaque_ty = tcx.mk_opaque(def_id, substs); // Collect the bounds, i.e., the `A+B+'c` in `impl A+B+'c`. @@ -1874,7 +1874,7 @@ fn explicit_predicates_of<'a, 'tcx>( impl_trait_fn, ref generics, }) => { - let substs = Substs::identity_for_item(tcx, def_id); + let substs = InternalSubsts::identity_for_item(tcx, def_id); let opaque_ty = tcx.mk_opaque(def_id, substs); // Collect the bounds, i.e., the `A+B+'c` in `impl A+B+'c`. diff --git a/src/librustc_typeck/variance/constraints.rs b/src/librustc_typeck/variance/constraints.rs index 1d407870ee73a..7b94b047c92e2 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::{Substs, UnpackedKind}; +use rustc::ty::subst::{UnpackedKind, SubstsRef}; use rustc::ty::{self, Ty, TyCtxt}; use syntax::ast; use rustc::hir; @@ -222,7 +222,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { fn add_constraints_from_invariant_substs(&mut self, current: &CurrentItem, - substs: &Substs<'tcx>, + substs: SubstsRef<'tcx>, variance: VarianceTermPtr<'a>) { debug!("add_constraints_from_invariant_substs: substs={:?} variance={:?}", substs, @@ -344,7 +344,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { fn add_constraints_from_substs(&mut self, current: &CurrentItem, def_id: DefId, - substs: &Substs<'tcx>, + substs: SubstsRef<'tcx>, variance: VarianceTermPtr<'a>) { debug!("add_constraints_from_substs(def_id={:?}, substs={:?}, variance={:?})", def_id, diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 2c2959aec9fcf..72abbae231aa6 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -20,7 +20,7 @@ use rustc::mir::interpret::GlobalId; use rustc::hir::{self, GenericArg, HirVec}; use rustc::hir::def::{self, Def, CtorKind}; use rustc::hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE}; -use rustc::ty::subst::Substs; +use rustc::ty::subst::{InternalSubsts, SubstsRef}; use rustc::ty::{self, TyCtxt, Region, RegionVid, Ty, AdtKind}; use rustc::ty::fold::TypeFolder; use rustc::ty::layout::VariantIdx; @@ -1089,7 +1089,7 @@ impl Clean for hir::GenericBound { } fn external_generic_args(cx: &DocContext<'_, '_, '_>, trait_did: Option, has_self: bool, - bindings: Vec, substs: &Substs<'_>) -> GenericArgs { + bindings: Vec, substs: SubstsRef<'_>) -> GenericArgs { let lifetimes = substs.regions().filter_map(|v| v.clean(cx)).collect(); let types = substs.types().skip(has_self as usize).collect::>(); @@ -1131,7 +1131,7 @@ fn external_generic_args(cx: &DocContext<'_, '_, '_>, trait_did: Option, // trait_did should be set to a trait's DefId if called on a TraitRef, in order to sugar // from Fn<(A, B,), C> to Fn(A, B) -> C fn external_path(cx: &DocContext<'_, '_, '_>, name: &str, trait_did: Option, has_self: bool, - bindings: Vec, substs: &Substs<'_>) -> Path { + bindings: Vec, substs: SubstsRef<'_>) -> Path { Path { global: false, def: Def::Err, @@ -1192,7 +1192,7 @@ impl<'tcx> Clean for ty::TraitRef<'tcx> { } } -impl<'tcx> Clean>> for Substs<'tcx> { +impl<'tcx> Clean>> for InternalSubsts<'tcx> { fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Option> { let mut v = Vec::new(); v.extend(self.regions().filter_map(|r| r.clean(cx)).map(GenericBound::Outlives)); @@ -2532,7 +2532,7 @@ impl Clean for hir::Ty { TyKind::Array(ref ty, ref length) => { let def_id = cx.tcx.hir().local_def_id(length.id); let param_env = cx.tcx.param_env(def_id); - let substs = Substs::identity_for_item(cx.tcx, def_id); + let substs = InternalSubsts::identity_for_item(cx.tcx, def_id); let cid = GlobalId { instance: ty::Instance::new(def_id, substs), promoted: None @@ -2776,7 +2776,7 @@ impl<'tcx> Clean for Ty<'tcx> { ty::Foreign(did) => { inline::record_extern_fqn(cx, did, TypeKind::Foreign); let path = external_path(cx, &cx.tcx.item_name(did).as_str(), - None, false, vec![], Substs::empty()); + None, false, vec![], InternalSubsts::empty()); ResolvedPath { path: path, typarams: None,