Skip to content

Commit cf11729

Browse files
committed
rename Substs to InternalSubsts
Change-Id: I3fa00e999a2ee4eb72db1fdf53a8633b49176a18
1 parent ccfa5d6 commit cf11729

File tree

55 files changed

+191
-187
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+191
-187
lines changed

src/librustc/infer/error_reporting/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ use crate::hir::Node;
5656
use crate::middle::region;
5757
use crate::traits::{ObligationCause, ObligationCauseCode};
5858
use crate::ty::error::TypeError;
59-
use crate::ty::{self, subst::Subst, Region, Ty, TyCtxt, TyKind, TypeFoldable};
59+
use crate::ty::{self, subst::{Subst, SubstsRef}, Region, Ty, TyCtxt, TyKind, TypeFoldable};
6060
use errors::{Applicability, DiagnosticBuilder, DiagnosticStyledString};
6161
use std::{cmp, fmt};
6262
use syntax_pos::{Pos, Span};
@@ -570,7 +570,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
570570
value: &mut DiagnosticStyledString,
571571
other_value: &mut DiagnosticStyledString,
572572
name: String,
573-
sub: &ty::subst::Substs<'tcx>,
573+
sub: ty::subst::SubstsRef<'tcx>,
574574
pos: usize,
575575
other_ty: &Ty<'tcx>,
576576
) {
@@ -648,7 +648,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
648648
mut t1_out: &mut DiagnosticStyledString,
649649
mut t2_out: &mut DiagnosticStyledString,
650650
path: String,
651-
sub: &ty::subst::Substs<'tcx>,
651+
sub: ty::subst::SubstsRef<'tcx>,
652652
other_path: String,
653653
other_ty: &Ty<'tcx>,
654654
) -> Option<()> {
@@ -687,8 +687,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
687687
fn strip_generic_default_params(
688688
&self,
689689
def_id: DefId,
690-
substs: &ty::subst::Substs<'tcx>,
691-
) -> &'tcx ty::subst::Substs<'tcx> {
690+
substs: ty::subst::SubstsRef<'tcx>,
691+
) -> SubstsRef<'tcx> {
692692
let generics = self.tcx.generics_of(def_id);
693693
let mut num_supplied_defaults = 0;
694694
let mut type_params = generics

src/librustc/infer/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::traits::{self, ObligationCause, PredicateObligations, TraitEngine};
1818
use crate::ty::error::{ExpectedFound, TypeError, UnconstrainedNumeric};
1919
use crate::ty::fold::TypeFoldable;
2020
use crate::ty::relate::RelateResult;
21-
use crate::ty::subst::{Kind, Substs, SubstsRef};
21+
use crate::ty::subst::{Kind, InternalSubsts, SubstsRef};
2222
use crate::ty::{self, GenericParamDefKind, Ty, TyCtxt, CtxtInterners};
2323
use crate::ty::{FloatVid, IntVid, TyVid};
2424
use crate::util::nodemap::FxHashMap;
@@ -1089,7 +1089,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
10891089
/// Given a set of generics defined on a type or impl, returns a substitution mapping each
10901090
/// type/region parameter to a fresh inference variable.
10911091
pub fn fresh_substs_for_item(&self, span: Span, def_id: DefId) -> SubstsRef<'tcx> {
1092-
Substs::for_item(self.tcx, def_id, |param, _| self.var_for_def(span, param))
1092+
InternalSubsts::for_item(self.tcx, def_id, |param, _| self.var_for_def(span, param))
10931093
}
10941094

10951095
/// Returns `true` if errors have been reported since this infcx was

src/librustc/infer/opaque_types/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::traits::{self, PredicateObligation};
99
use crate::ty::{self, Ty, TyCtxt, GenericParamDefKind};
1010
use crate::ty::fold::{BottomUpFolder, TypeFoldable, TypeFolder};
1111
use crate::ty::outlives::Component;
12-
use crate::ty::subst::{Kind, Substs, SubstsRef, UnpackedKind};
12+
use crate::ty::subst::{Kind, InternalSubsts, SubstsRef, UnpackedKind};
1313
use crate::util::nodemap::DefIdMap;
1414

1515
pub type OpaqueTypeMap<'tcx> = DefIdMap<OpaqueTypeDecl<'tcx>>;
@@ -437,7 +437,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
437437
// lifetimes with 'static and remapping only those used in the
438438
// `impl Trait` return type, resulting in the parameters
439439
// shifting.
440-
let id_substs = Substs::identity_for_item(gcx, def_id);
440+
let id_substs = InternalSubsts::identity_for_item(gcx, def_id);
441441
let map: FxHashMap<Kind<'tcx>, Kind<'gcx>> = opaque_defn
442442
.substs
443443
.iter()

src/librustc/infer/outlives/verify.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::hir::def_id::DefId;
22
use crate::infer::outlives::env::RegionBoundPairs;
33
use crate::infer::{GenericKind, VerifyBound};
44
use crate::traits;
5-
use crate::ty::subst::{Subst, Substs};
5+
use crate::ty::subst::{Subst, InternalSubsts};
66
use crate::ty::{self, Ty, TyCtxt};
77
use crate::util::captures::Captures;
88

@@ -292,7 +292,7 @@ impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> {
292292
.iter()
293293
.map(|(p, _)| *p)
294294
.collect();
295-
let identity_substs = Substs::identity_for_item(tcx, assoc_item_def_id);
295+
let identity_substs = InternalSubsts::identity_for_item(tcx, assoc_item_def_id);
296296
let identity_proj = tcx.mk_projection(assoc_item_def_id, identity_substs);
297297
self.collect_outlives_from_predicate_list(
298298
move |ty| ty == identity_proj,

src/librustc/traits/auto_trait.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
631631
finished_map
632632
}
633633

634-
fn is_param_no_infer(&self, substs: &Substs<'_>) -> bool {
634+
fn is_param_no_infer(&self, substs: SubstsRef<'_>) -> bool {
635635
return self.is_of_param(substs.type_at(0)) &&
636636
!substs.types().any(|t| t.has_infer_types());
637637
}

src/librustc/traits/codegen/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use syntax_pos::Span;
1111
use crate::traits::{FulfillmentContext, Obligation, ObligationCause, SelectionContext,
1212
TraitEngine, Vtable};
1313
use crate::ty::{self, Ty, TyCtxt};
14-
use crate::ty::subst::{Subst, Substs};
14+
use crate::ty::subst::{Subst, SubstsRef};
1515
use crate::ty::fold::TypeFoldable;
1616

1717
/// Attempts to resolve an obligation to a vtable. The result is
@@ -82,7 +82,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
8282
/// types.
8383
pub fn subst_and_normalize_erasing_regions<T>(
8484
self,
85-
param_substs: &Substs<'tcx>,
85+
param_substs: SubstsRef<'tcx>,
8686
param_env: ty::ParamEnv<'tcx>,
8787
value: &T
8888
) -> T

src/librustc/traits/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use crate::mir::interpret::ErrorHandled;
2929
use rustc_data_structures::sync::Lrc;
3030
use syntax::ast;
3131
use syntax_pos::{Span, DUMMY_SP};
32-
use crate::ty::subst::{Substs, SubstsRef};
32+
use crate::ty::subst::{InternalSubsts, SubstsRef};
3333
use crate::ty::{self, AdtKind, List, Ty, TyCtxt, GenericParamDefKind, ToPredicate};
3434
use crate::ty::error::{ExpectedFound, TypeError};
3535
use crate::ty::fold::{TypeFolder, TypeFoldable, TypeVisitor};
@@ -992,7 +992,7 @@ fn vtable_methods<'a, 'tcx>(
992992
let trait_methods = tcx.associated_items(trait_ref.def_id())
993993
.filter(|item| item.kind == ty::AssociatedKind::Method);
994994

995-
// Now list each method's DefId and Substs (for within its trait).
995+
// Now list each method's DefId and InternalSubsts (for within its trait).
996996
// If the method can never be called from this object, produce None.
997997
trait_methods.map(move |trait_method| {
998998
debug!("vtable_methods: trait_method={:?}", trait_method);
@@ -1007,7 +1007,7 @@ fn vtable_methods<'a, 'tcx>(
10071007
// the method may have some early-bound lifetimes, add
10081008
// regions for those
10091009
let substs = trait_ref.map_bound(|trait_ref|
1010-
Substs::for_item(tcx, def_id, |param, _|
1010+
InternalSubsts::for_item(tcx, def_id, |param, _|
10111011
match param.kind {
10121012
GenericParamDefKind::Lifetime => tcx.types.re_erased.into(),
10131013
GenericParamDefKind::Type {..} => {

src/librustc/traits/object_safety.rs

+13-9
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::hir::def_id::DefId;
1515
use crate::lint;
1616
use crate::traits::{self, Obligation, ObligationCause};
1717
use crate::ty::{self, Ty, TyCtxt, TypeFoldable, Predicate, ToPredicate};
18-
use crate::ty::subst::{Subst, Substs};
18+
use crate::ty::subst::{Subst, InternalSubsts};
1919
use std::borrow::Cow;
2020
use std::iter::{self};
2121
use syntax::ast::{self, Name};
@@ -406,7 +406,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
406406
self, receiver_ty: Ty<'tcx>, self_ty: Ty<'tcx>, method_def_id: DefId
407407
) -> Ty<'tcx> {
408408
debug!("receiver_for_self_ty({:?}, {:?}, {:?})", receiver_ty, self_ty, method_def_id);
409-
let substs = Substs::for_item(self, method_def_id, |param, _| {
409+
let substs = InternalSubsts::for_item(self, method_def_id, |param, _| {
410410
if param.index == 0 {
411411
self_ty.into()
412412
} else {
@@ -559,13 +559,17 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
559559

560560
// U: Trait<Arg1, ..., ArgN>
561561
let trait_predicate = {
562-
let substs = Substs::for_item(self, method.container.assert_trait(), |param, _| {
563-
if param.index == 0 {
564-
unsized_self_ty.into()
565-
} else {
566-
self.mk_param_from_def(param)
567-
}
568-
});
562+
let substs = InternalSubsts::for_item(
563+
self,
564+
method.container.assert_trait(),
565+
|param, _| {
566+
if param.index == 0 {
567+
unsized_self_ty.into()
568+
} else {
569+
self.mk_param_from_def(param)
570+
}
571+
},
572+
);
569573

570574
ty::TraitRef {
571575
def_id: unsize_did,

src/librustc/traits/project.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::infer::type_variable::TypeVariableOrigin;
1818
use crate::mir::interpret::{GlobalId};
1919
use rustc_data_structures::snapshot_map::{Snapshot, SnapshotMap};
2020
use syntax::ast::Ident;
21-
use crate::ty::subst::{Subst, Substs};
21+
use crate::ty::subst::{Subst, InternalSubsts};
2222
use crate::ty::{self, ToPredicate, ToPolyTraitRef, Ty, TyCtxt};
2323
use crate::ty::fold::{TypeFoldable, TypeFolder};
2424
use crate::util::common::FN_OUTPUT_NAME;
@@ -401,7 +401,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for AssociatedTypeNormalizer<'a,
401401
let tcx = self.selcx.tcx().global_tcx();
402402
if let Some(param_env) = self.tcx().lift_to_global(&self.param_env) {
403403
if substs.needs_infer() || substs.has_placeholders() {
404-
let identity_substs = Substs::identity_for_item(tcx, def_id);
404+
let identity_substs = InternalSubsts::identity_for_item(tcx, def_id);
405405
let instance = ty::Instance::resolve(tcx, param_env, def_id, identity_substs);
406406
if let Some(instance) = instance {
407407
let cid = GlobalId {
@@ -1490,7 +1490,7 @@ fn confirm_impl_candidate<'cx, 'gcx, 'tcx>(
14901490
}
14911491
let substs = translate_substs(selcx.infcx(), param_env, impl_def_id, substs, assoc_ty.node);
14921492
let ty = if let ty::AssociatedKind::Existential = assoc_ty.item.kind {
1493-
let item_substs = Substs::identity_for_item(tcx, assoc_ty.item.def_id);
1493+
let item_substs = InternalSubsts::identity_for_item(tcx, assoc_ty.item.def_id);
14941494
tcx.mk_opaque(assoc_ty.item.def_id, item_substs)
14951495
} else {
14961496
tcx.type_of(assoc_ty.item.def_id)

src/librustc/traits/query/normalize.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::mir::interpret::GlobalId;
99
use crate::traits::project::Normalized;
1010
use crate::traits::{Obligation, ObligationCause, PredicateObligation, Reveal};
1111
use crate::ty::fold::{TypeFoldable, TypeFolder};
12-
use crate::ty::subst::{Subst, Substs};
12+
use crate::ty::subst::{Subst, InternalSubsts};
1313
use crate::ty::{self, Ty, TyCtxt};
1414

1515
use super::NoSolution;
@@ -193,7 +193,7 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for QueryNormalizer<'cx, 'gcx, 'tcx
193193
let tcx = self.infcx.tcx.global_tcx();
194194
if let Some(param_env) = self.tcx().lift_to_global(&self.param_env) {
195195
if substs.needs_infer() || substs.has_placeholders() {
196-
let identity_substs = Substs::identity_for_item(tcx, def_id);
196+
let identity_substs = InternalSubsts::identity_for_item(tcx, def_id);
197197
let instance = ty::Instance::resolve(tcx, param_env, def_id, identity_substs);
198198
if let Some(instance) = instance {
199199
let cid = GlobalId {

src/librustc/traits/select.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use crate::middle::lang_items;
3434
use crate::mir::interpret::GlobalId;
3535
use crate::ty::fast_reject;
3636
use crate::ty::relate::TypeRelation;
37-
use crate::ty::subst::{Subst, Substs, SubstsRef};
37+
use crate::ty::subst::{Subst, SubstsRef};
3838
use crate::ty::{self, ToPolyTraitRef, ToPredicate, Ty, TyCtxt, TypeFoldable};
3939

4040
use crate::hir;
@@ -3761,7 +3761,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
37613761
recursion_depth: usize,
37623762
param_env: ty::ParamEnv<'tcx>,
37633763
def_id: DefId, // of impl or trait
3764-
substs: &Substs<'tcx>, // for impl or trait
3764+
substs: SubstsRef<'tcx>, // for impl or trait
37653765
) -> Vec<PredicateObligation<'tcx>> {
37663766
debug!("impl_or_trait_obligations(def_id={:?})", def_id);
37673767
let tcx = self.tcx();

src/librustc/traits/specialize/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use rustc_data_structures::sync::Lrc;
2020
use syntax_pos::DUMMY_SP;
2121
use crate::traits::select::IntercrateAmbiguityCause;
2222
use crate::ty::{self, TyCtxt, TypeFoldable};
23-
use crate::ty::subst::{Subst, Substs, SubstsRef};
23+
use crate::ty::subst::{Subst, InternalSubsts, SubstsRef};
2424

2525
use super::{SelectionContext, FulfillmentContext};
2626
use super::util::impl_trait_ref_and_oblig;
@@ -399,7 +399,7 @@ fn to_pretty_impl_header(tcx: TyCtxt<'_, '_, '_>, impl_def_id: DefId) -> Option<
399399

400400
let mut w = "impl".to_owned();
401401

402-
let substs = Substs::identity_for_item(tcx, impl_def_id);
402+
let substs = InternalSubsts::identity_for_item(tcx, impl_def_id);
403403

404404
// FIXME: Currently only handles ?Sized.
405405
// Needs to support ?Move and ?DynSized when they are implemented.

src/librustc/traits/util.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::hir::def_id::DefId;
33
use crate::traits::specialize::specialization_graph::NodeItem;
44
use crate::ty::{self, Ty, TyCtxt, ToPredicate, ToPolyTraitRef};
55
use crate::ty::outlives::Component;
6-
use crate::ty::subst::{Kind, Subst, Substs};
6+
use crate::ty::subst::{Kind, Subst, SubstsRef};
77
use crate::util::nodemap::FxHashSet;
88

99
use super::{Obligation, ObligationCause, PredicateObligation, SelectionContext, Normalized};
@@ -358,7 +358,7 @@ impl<'tcx, I: Iterator<Item = ty::Predicate<'tcx>>> Iterator for FilterToTraits<
358358
pub fn impl_trait_ref_and_oblig<'a, 'gcx, 'tcx>(selcx: &mut SelectionContext<'a, 'gcx, 'tcx>,
359359
param_env: ty::ParamEnv<'tcx>,
360360
impl_def_id: DefId,
361-
impl_substs: &Substs<'tcx>)
361+
impl_substs: SubstsRef<'tcx>,)
362362
-> (ty::TraitRef<'tcx>,
363363
Vec<PredicateObligation<'tcx>>)
364364
{

src/librustc/ty/context.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use crate::middle::resolve_lifetime::{self, ObjectLifetimeDefault};
2222
use crate::middle::stability;
2323
use crate::mir::{self, Mir, interpret, ProjectionKind};
2424
use crate::mir::interpret::Allocation;
25-
use crate::ty::subst::{Kind, Substs, Subst, SubstsRef};
25+
use crate::ty::subst::{Kind, InternalSubsts, Subst, SubstsRef};
2626
use crate::ty::ReprOptions;
2727
use crate::traits;
2828
use crate::traits::{Clause, Clauses, GoalKind, Goal, Goals};
@@ -118,7 +118,7 @@ pub struct CtxtInterners<'tcx> {
118118
/// they're accessed quite often.
119119
type_: InternedSet<'tcx, TyS<'tcx>>,
120120
type_list: InternedSet<'tcx, List<Ty<'tcx>>>,
121-
substs: InternedSet<'tcx, Substs<'tcx>>,
121+
substs: InternedSet<'tcx, InternalSubsts<'tcx>>,
122122
canonical_var_infos: InternedSet<'tcx, List<CanonicalVarInfo>>,
123123
region: InternedSet<'tcx, RegionKind>,
124124
existential_predicates: InternedSet<'tcx, List<ExistentialPredicate<'tcx>>>,
@@ -557,7 +557,7 @@ impl<'tcx> TypeckTables<'tcx> {
557557

558558
pub fn node_substs(&self, id: hir::HirId) -> SubstsRef<'tcx> {
559559
validate_hir_id_for_typeck_tables(self.local_id_root, id, false);
560-
self.node_substs.get(&id.local_id).cloned().unwrap_or_else(|| Substs::empty())
560+
self.node_substs.get(&id.local_id).cloned().unwrap_or_else(|| InternalSubsts::empty())
561561
}
562562

563563
pub fn node_substs_opt(&self, id: hir::HirId) -> Option<SubstsRef<'tcx>> {
@@ -1807,7 +1807,7 @@ nop_list_lift!{Predicate<'a> => Predicate<'tcx>}
18071807
nop_list_lift!{CanonicalVarInfo => CanonicalVarInfo}
18081808
nop_list_lift!{ProjectionKind<'a> => ProjectionKind<'tcx>}
18091809

1810-
// this is the impl for `&'a Substs<'a>`
1810+
// this is the impl for `&'a InternalSubsts<'a>`
18111811
nop_list_lift!{Kind<'a> => Kind<'tcx>}
18121812

18131813
impl<'a, 'tcx> Lift<'tcx> for &'a mir::interpret::Allocation {
@@ -2183,7 +2183,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
21832183
Generator, GeneratorWitness, Dynamic, Closure, Tuple, Bound,
21842184
Param, Infer, UnnormalizedProjection, Projection, Opaque, Foreign);
21852185

2186-
println!("Substs interner: #{}", self.interners.substs.borrow().len());
2186+
println!("InternalSubsts interner: #{}", self.interners.substs.borrow().len());
21872187
println!("Region interner: #{}", self.interners.region.borrow().len());
21882188
println!("Stability interner: #{}", self.stability_interner.borrow().len());
21892189
println!("Allocation interner: #{}", self.allocation_interner.borrow().len());
@@ -2250,7 +2250,7 @@ impl<'tcx: 'lcx, 'lcx> Borrow<[CanonicalVarInfo]> for Interned<'tcx, List<Canoni
22502250
}
22512251
}
22522252

2253-
impl<'tcx: 'lcx, 'lcx> Borrow<[Kind<'lcx>]> for Interned<'tcx, Substs<'tcx>> {
2253+
impl<'tcx: 'lcx, 'lcx> Borrow<[Kind<'lcx>]> for Interned<'tcx, InternalSubsts<'tcx>> {
22542254
fn borrow<'a>(&'a self) -> &'a [Kind<'lcx>] {
22552255
&self.0[..]
22562256
}
@@ -2520,7 +2520,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
25202520
pub fn mk_box(self, ty: Ty<'tcx>) -> Ty<'tcx> {
25212521
let def_id = self.require_lang_item(lang_items::OwnedBoxLangItem);
25222522
let adt_def = self.adt_def(def_id);
2523-
let substs = Substs::for_item(self, def_id, |param, substs| {
2523+
let substs = InternalSubsts::for_item(self, def_id, |param, substs| {
25242524
match param.kind {
25252525
GenericParamDefKind::Lifetime => bug!(),
25262526
GenericParamDefKind::Type { has_default, .. } => {

src/librustc/ty/flags.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::ty::subst::Substs;
1+
use crate::ty::subst::SubstsRef;
22
use crate::ty::{self, Ty, TypeFlags, TypeFoldable};
33

44
#[derive(Debug)]
@@ -241,7 +241,7 @@ impl FlagComputation {
241241
self.add_substs(projection_ty.substs);
242242
}
243243

244-
fn add_substs(&mut self, substs: &Substs<'_>) {
244+
fn add_substs(&mut self, substs: SubstsRef<'_>) {
245245
for ty in substs.types() {
246246
self.add_ty(ty);
247247
}

0 commit comments

Comments
 (0)