Skip to content

Commit ccfa5d6

Browse files
csmoecsmoe
authored and
csmoe
committed
replace &'tcx Substs with SubstsRef
1 parent ea43c3c commit ccfa5d6

File tree

55 files changed

+213
-211
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

+213
-211
lines changed

src/librustc/dep_graph/dep_node.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ use crate::traits::query::{
6767
};
6868
use crate::ty::{TyCtxt, FnSig, Instance, InstanceDef,
6969
ParamEnv, ParamEnvAnd, Predicate, PolyFnSig, PolyTraitRef, Ty};
70-
use crate::ty::subst::Substs;
70+
use crate::ty::subst::SubstsRef;
7171

7272
// erase!() just makes tokens go away. It's used to specify which macro argument
7373
// 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>
661661
[] TypeOpNormalizePolyFnSig(CanonicalTypeOpNormalizeGoal<'tcx, PolyFnSig<'tcx>>),
662662
[] TypeOpNormalizeFnSig(CanonicalTypeOpNormalizeGoal<'tcx, FnSig<'tcx>>),
663663

664-
[] SubstituteNormalizeAndTestPredicates { key: (DefId, &'tcx Substs<'tcx>) },
664+
[] SubstituteNormalizeAndTestPredicates { key: (DefId, SubstsRef<'tcx>) },
665665
[] MethodAutoderefSteps(CanonicalTyGoal<'tcx>),
666666

667667
[input] TargetFeaturesWhitelist,

src/librustc/infer/combine.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use crate::ty::{IntType, UintType};
3434
use crate::ty::{self, Ty, TyCtxt};
3535
use crate::ty::error::TypeError;
3636
use crate::ty::relate::{self, Relate, RelateResult, TypeRelation};
37-
use crate::ty::subst::Substs;
37+
use crate::ty::subst::SubstsRef;
3838
use crate::traits::{Obligation, PredicateObligations};
3939

4040
use syntax::ast;
@@ -373,9 +373,9 @@ impl<'cx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx> for Generalizer<'cx, 'gcx, '
373373

374374
fn relate_item_substs(&mut self,
375375
item_def_id: DefId,
376-
a_subst: &'tcx Substs<'tcx>,
377-
b_subst: &'tcx Substs<'tcx>)
378-
-> RelateResult<'tcx, &'tcx Substs<'tcx>>
376+
a_subst: SubstsRef<'tcx>,
377+
b_subst: SubstsRef<'tcx>)
378+
-> RelateResult<'tcx, SubstsRef<'tcx>>
379379
{
380380
if self.ambient_variance == ty::Variance::Invariant {
381381
// Avoid fetching the variance if we are in an invariant

src/librustc/infer/equate.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::hir::def_id::DefId;
55

66
use crate::ty::{self, Ty, TyCtxt};
77
use crate::ty::TyVar;
8-
use crate::ty::subst::Substs;
8+
use crate::ty::subst::SubstsRef;
99
use crate::ty::relate::{self, Relate, RelateResult, TypeRelation};
1010

1111
/// Ensures `a` is made equal to `b`. Returns `a` on success.
@@ -33,9 +33,9 @@ impl<'combine, 'infcx, 'gcx, 'tcx> TypeRelation<'infcx, 'gcx, 'tcx>
3333

3434
fn relate_item_substs(&mut self,
3535
_item_def_id: DefId,
36-
a_subst: &'tcx Substs<'tcx>,
37-
b_subst: &'tcx Substs<'tcx>)
38-
-> RelateResult<'tcx, &'tcx Substs<'tcx>>
36+
a_subst: SubstsRef<'tcx>,
37+
b_subst: SubstsRef<'tcx>)
38+
-> RelateResult<'tcx, SubstsRef<'tcx>>
3939
{
4040
// N.B., once we are equating types, we don't care about
4141
// variance, so don't try to lookup the variance here. This

src/librustc/infer/error_reporting/nice_region_error/placeholder_error.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::infer::{SubregionOrigin, TypeTrace};
77
use crate::traits::{ObligationCause, ObligationCauseCode};
88
use crate::ty;
99
use crate::ty::error::ExpectedFound;
10-
use crate::ty::subst::Substs;
10+
use crate::ty::subst::SubstsRef;
1111
use crate::util::ppaux::RegionHighlightMode;
1212

1313
impl NiceRegionError<'me, 'gcx, 'tcx> {
@@ -175,8 +175,8 @@ impl NiceRegionError<'me, 'gcx, 'tcx> {
175175
sub_placeholder: Option<ty::Region<'tcx>>,
176176
sup_placeholder: Option<ty::Region<'tcx>>,
177177
trait_def_id: DefId,
178-
expected_substs: &'tcx Substs<'tcx>,
179-
actual_substs: &'tcx Substs<'tcx>,
178+
expected_substs: SubstsRef<'tcx>,
179+
actual_substs: SubstsRef<'tcx>,
180180
) -> DiagnosticBuilder<'me> {
181181
debug!(
182182
"try_report_placeholders_trait(\

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};
21+
use crate::ty::subst::{Kind, Substs, SubstsRef};
2222
use crate::ty::{self, GenericParamDefKind, Ty, TyCtxt, CtxtInterners};
2323
use crate::ty::{FloatVid, IntVid, TyVid};
2424
use crate::util::nodemap::FxHashMap;
@@ -1088,7 +1088,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
10881088

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.
1091-
pub fn fresh_substs_for_item(&self, span: Span, def_id: DefId) -> &'tcx Substs<'tcx> {
1091+
pub fn fresh_substs_for_item(&self, span: Span, def_id: DefId) -> SubstsRef<'tcx> {
10921092
Substs::for_item(self.tcx, def_id, |param, _| self.var_for_def(span, param))
10931093
}
10941094

src/librustc/infer/opaque_types/mod.rs

+3-3
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, UnpackedKind};
12+
use crate::ty::subst::{Kind, Substs, SubstsRef, UnpackedKind};
1313
use crate::util::nodemap::DefIdMap;
1414

1515
pub type OpaqueTypeMap<'tcx> = DefIdMap<OpaqueTypeDecl<'tcx>>;
@@ -30,7 +30,7 @@ pub struct OpaqueTypeDecl<'tcx> {
3030
/// fn foo<'a, 'b, T>() -> Foo<'a, T>
3131
///
3232
/// then `substs` would be `['a, T]`.
33-
pub substs: &'tcx Substs<'tcx>,
33+
pub substs: SubstsRef<'tcx>,
3434

3535
/// The type variable that represents the value of the abstract type
3636
/// that we require. In other words, after we compile this function,
@@ -740,7 +740,7 @@ impl<'a, 'gcx, 'tcx> Instantiator<'a, 'gcx, 'tcx> {
740740
&mut self,
741741
ty: Ty<'tcx>,
742742
def_id: DefId,
743-
substs: &'tcx Substs<'tcx>,
743+
substs: SubstsRef<'tcx>,
744744
) -> Ty<'tcx> {
745745
let infcx = self.infcx;
746746
let tcx = infcx.tcx;

src/librustc/middle/exported_symbols.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_data_structures::stable_hasher::{StableHasher, HashStable,
55
use std::cmp;
66
use std::mem;
77
use crate::ty;
8-
use crate::ty::subst::Substs;
8+
use crate::ty::subst::SubstsRef;
99

1010
/// The SymbolExportLevel of a symbols specifies from which kinds of crates
1111
/// the symbol will be exported. `C` symbols will be exported from any
@@ -33,7 +33,7 @@ impl SymbolExportLevel {
3333
#[derive(Eq, PartialEq, Debug, Copy, Clone, RustcEncodable, RustcDecodable)]
3434
pub enum ExportedSymbol<'tcx> {
3535
NonGeneric(DefId),
36-
Generic(DefId, &'tcx Substs<'tcx>),
36+
Generic(DefId, SubstsRef<'tcx>),
3737
NoDefId(ty::SymbolName),
3838
}
3939

src/librustc/mir/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use syntax::ast::{self, Name};
2727
use syntax::symbol::InternedString;
2828
use syntax_pos::{Span, DUMMY_SP};
2929
use crate::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
30-
use crate::ty::subst::{Subst, Substs};
30+
use crate::ty::subst::{Subst, SubstsRef};
3131
use crate::ty::layout::VariantIdx;
3232
use crate::ty::{
3333
self, AdtDef, CanonicalUserTypeAnnotations, ClosureSubsts, GeneratorSubsts, Region, Ty, TyCtxt,
@@ -2151,7 +2151,7 @@ impl<'tcx> Operand<'tcx> {
21512151
pub fn function_handle<'a>(
21522152
tcx: TyCtxt<'a, 'tcx, 'tcx>,
21532153
def_id: DefId,
2154-
substs: &'tcx Substs<'tcx>,
2154+
substs: SubstsRef<'tcx>,
21552155
span: Span,
21562156
) -> Self {
21572157
let ty = tcx.type_of(def_id).subst(tcx, substs);
@@ -2247,7 +2247,7 @@ pub enum AggregateKind<'tcx> {
22472247
Adt(
22482248
&'tcx AdtDef,
22492249
VariantIdx,
2250-
&'tcx Substs<'tcx>,
2250+
SubstsRef<'tcx>,
22512251
Option<UserTypeAnnotationIndex>,
22522252
Option<usize>,
22532253
),

src/librustc/mir/tcx.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
use crate::mir::*;
7-
use crate::ty::subst::{Subst, Substs};
7+
use crate::ty::subst::{Subst, SubstsRef};
88
use crate::ty::{self, AdtDef, Ty, TyCtxt};
99
use crate::ty::layout::VariantIdx;
1010
use crate::hir;
@@ -17,7 +17,7 @@ pub enum PlaceTy<'tcx> {
1717

1818
/// Downcast to a particular variant of an enum.
1919
Downcast { adt_def: &'tcx AdtDef,
20-
substs: &'tcx Substs<'tcx>,
20+
substs: SubstsRef<'tcx>,
2121
variant_index: VariantIdx },
2222
}
2323

src/librustc/mir/visit.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::hir::def_id::DefId;
2-
use crate::ty::subst::Substs;
2+
use crate::ty::subst::SubstsRef;
33
use crate::ty::{CanonicalUserTypeAnnotation, ClosureSubsts, GeneratorSubsts, Region, Ty};
44
use crate::mir::*;
55
use syntax_pos::Span;
@@ -238,7 +238,7 @@ macro_rules! make_mir_visitor {
238238
}
239239

240240
fn visit_substs(&mut self,
241-
substs: & $($mutability)? &'tcx Substs<'tcx>,
241+
substs: & $($mutability)? SubstsRef<'tcx>,
242242
_: Location) {
243243
self.super_substs(substs);
244244
}
@@ -889,7 +889,7 @@ macro_rules! make_mir_visitor {
889889
fn super_const(&mut self, _const: & $($mutability)? &'tcx ty::LazyConst<'tcx>) {
890890
}
891891

892-
fn super_substs(&mut self, _substs: & $($mutability)? &'tcx Substs<'tcx>) {
892+
fn super_substs(&mut self, _substs: & $($mutability)? SubstsRef<'tcx>) {
893893
}
894894

895895
fn super_generator_substs(&mut self,

src/librustc/traits/mod.rs

+5-5
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;
32+
use crate::ty::subst::{Substs, 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};
@@ -565,7 +565,7 @@ pub enum Vtable<'tcx, N> {
565565
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable)]
566566
pub struct VtableImplData<'tcx, N> {
567567
pub impl_def_id: DefId,
568-
pub substs: &'tcx Substs<'tcx>,
568+
pub substs: SubstsRef<'tcx>,
569569
pub nested: Vec<N>
570570
}
571571

@@ -622,7 +622,7 @@ pub struct VtableFnPointerData<'tcx, N> {
622622
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable)]
623623
pub struct VtableTraitAliasData<'tcx, N> {
624624
pub alias_def_id: DefId,
625-
pub substs: &'tcx Substs<'tcx>,
625+
pub substs: SubstsRef<'tcx>,
626626
pub nested: Vec<N>,
627627
}
628628

@@ -963,7 +963,7 @@ fn normalize_and_test_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
963963
}
964964

965965
fn substitute_normalize_and_test_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
966-
key: (DefId, &'tcx Substs<'tcx>))
966+
key: (DefId, SubstsRef<'tcx>))
967967
-> bool
968968
{
969969
debug!("substitute_normalize_and_test_predicates(key={:?})",
@@ -983,7 +983,7 @@ fn substitute_normalize_and_test_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx
983983
fn vtable_methods<'a, 'tcx>(
984984
tcx: TyCtxt<'a, 'tcx, 'tcx>,
985985
trait_ref: ty::PolyTraitRef<'tcx>)
986-
-> Lrc<Vec<Option<(DefId, &'tcx Substs<'tcx>)>>>
986+
-> Lrc<Vec<Option<(DefId, SubstsRef<'tcx>)>>>
987987
{
988988
debug!("vtable_methods({:?})", trait_ref);
989989

src/librustc/traits/select.rs

+4-4
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};
37+
use crate::ty::subst::{Subst, Substs, SubstsRef};
3838
use crate::ty::{self, ToPolyTraitRef, ToPredicate, Ty, TyCtxt, TypeFoldable};
3939

4040
use crate::hir;
@@ -2944,7 +2944,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
29442944
fn vtable_impl(
29452945
&mut self,
29462946
impl_def_id: DefId,
2947-
mut substs: Normalized<'tcx, &'tcx Substs<'tcx>>,
2947+
mut substs: Normalized<'tcx, SubstsRef<'tcx>>,
29482948
cause: ObligationCause<'tcx>,
29492949
recursion_depth: usize,
29502950
param_env: ty::ParamEnv<'tcx>,
@@ -3538,7 +3538,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
35383538
impl_def_id: DefId,
35393539
obligation: &TraitObligation<'tcx>,
35403540
snapshot: &CombinedSnapshot<'_, 'tcx>,
3541-
) -> Normalized<'tcx, &'tcx Substs<'tcx>> {
3541+
) -> Normalized<'tcx, SubstsRef<'tcx>> {
35423542
match self.match_impl(impl_def_id, obligation, snapshot) {
35433543
Ok(substs) => substs,
35443544
Err(()) => {
@@ -3556,7 +3556,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
35563556
impl_def_id: DefId,
35573557
obligation: &TraitObligation<'tcx>,
35583558
snapshot: &CombinedSnapshot<'_, 'tcx>,
3559-
) -> Result<Normalized<'tcx, &'tcx Substs<'tcx>>, ()> {
3559+
) -> Result<Normalized<'tcx, SubstsRef<'tcx>>, ()> {
35603560
let impl_trait_ref = self.tcx().impl_trait_ref(impl_def_id).unwrap();
35613561

35623562
// Before we create the substitutions and everything, first

src/librustc/traits/specialize/mod.rs

+6-6
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};
23+
use crate::ty::subst::{Subst, Substs, SubstsRef};
2424

2525
use super::{SelectionContext, FulfillmentContext};
2626
use super::util::impl_trait_ref_and_oblig;
@@ -73,9 +73,9 @@ pub struct OverlapError {
7373
pub fn translate_substs<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
7474
param_env: ty::ParamEnv<'tcx>,
7575
source_impl: DefId,
76-
source_substs: &'tcx Substs<'tcx>,
76+
source_substs: SubstsRef<'tcx>,
7777
target_node: specialization_graph::Node)
78-
-> &'tcx Substs<'tcx> {
78+
-> SubstsRef<'tcx> {
7979
debug!("translate_substs({:?}, {:?}, {:?}, {:?})",
8080
param_env, source_impl, source_substs, target_node);
8181
let source_trait_ref = infcx.tcx
@@ -114,9 +114,9 @@ pub fn find_associated_item<'a, 'tcx>(
114114
tcx: TyCtxt<'a, 'tcx, 'tcx>,
115115
param_env: ty::ParamEnv<'tcx>,
116116
item: &ty::AssociatedItem,
117-
substs: &'tcx Substs<'tcx>,
117+
substs: SubstsRef<'tcx>,
118118
impl_data: &super::VtableImplData<'tcx, ()>,
119-
) -> (DefId, &'tcx Substs<'tcx>) {
119+
) -> (DefId, SubstsRef<'tcx>) {
120120
debug!("find_associated_item({:?}, {:?}, {:?}, {:?})",
121121
param_env, item, substs, impl_data);
122122
assert!(!substs.needs_infer());
@@ -214,7 +214,7 @@ fn fulfill_implication<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
214214
param_env: ty::ParamEnv<'tcx>,
215215
source_trait_ref: ty::TraitRef<'tcx>,
216216
target_impl: DefId)
217-
-> Result<&'tcx Substs<'tcx>, ()> {
217+
-> Result<SubstsRef<'tcx>, ()> {
218218
debug!("fulfill_implication({:?}, trait_ref={:?} |- {:?} applies)",
219219
param_env, source_trait_ref, target_impl);
220220

src/librustc/ty/adjustment.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::hir;
22
use crate::hir::def_id::DefId;
33
use crate::ty::{self, Ty, TyCtxt};
4-
use crate::ty::subst::Substs;
4+
use crate::ty::subst::SubstsRef;
55

66

77
/// Represents coercing a value to a different type of value.
@@ -98,7 +98,7 @@ pub struct OverloadedDeref<'tcx> {
9898

9999
impl<'a, 'gcx, 'tcx> OverloadedDeref<'tcx> {
100100
pub fn method_call(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, source: Ty<'tcx>)
101-
-> (DefId, &'tcx Substs<'tcx>) {
101+
-> (DefId, SubstsRef<'tcx>) {
102102
let trait_def_id = match self.mutbl {
103103
hir::MutImmutable => tcx.lang_items().deref_trait(),
104104
hir::MutMutable => tcx.lang_items().deref_mut_trait()

src/librustc/ty/codec.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::rustc_serialize::{Decodable, Decoder, Encoder, Encodable, opaque};
1313
use std::hash::Hash;
1414
use std::intrinsics;
1515
use crate::ty::{self, Ty, TyCtxt};
16-
use crate::ty::subst::Substs;
16+
use crate::ty::subst::SubstsRef;
1717
use crate::mir::interpret::Allocation;
1818

1919
/// The shorthand encoding uses an enum's variant index `usize`
@@ -185,7 +185,7 @@ pub fn decode_predicates<'a, 'tcx, D>(decoder: &mut D)
185185
}
186186

187187
#[inline]
188-
pub fn decode_substs<'a, 'tcx, D>(decoder: &mut D) -> Result<&'tcx Substs<'tcx>, D::Error>
188+
pub fn decode_substs<'a, 'tcx, D>(decoder: &mut D) -> Result<SubstsRef<'tcx>, D::Error>
189189
where D: TyDecoder<'a, 'tcx>,
190190
'tcx: 'a,
191191
{
@@ -281,7 +281,7 @@ macro_rules! implement_ty_decoder {
281281
use $crate::infer::canonical::CanonicalVarInfos;
282282
use $crate::ty;
283283
use $crate::ty::codec::*;
284-
use $crate::ty::subst::Substs;
284+
use $crate::ty::subst::SubstsRef;
285285
use $crate::hir::def_id::{CrateNum};
286286
use crate::rustc_serialize::{Decoder, SpecializedDecoder};
287287
use std::borrow::Cow;
@@ -344,9 +344,9 @@ macro_rules! implement_ty_decoder {
344344
}
345345
}
346346

347-
impl<$($typaram),*> SpecializedDecoder<&'tcx Substs<'tcx>>
347+
impl<$($typaram),*> SpecializedDecoder<SubstsRef<'tcx>>
348348
for $DecoderName<$($typaram),*> {
349-
fn specialized_decode(&mut self) -> Result<&'tcx Substs<'tcx>, Self::Error> {
349+
fn specialized_decode(&mut self) -> Result<SubstsRef<'tcx>, Self::Error> {
350350
decode_substs(self)
351351
}
352352
}

0 commit comments

Comments
 (0)