Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,6 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
use hir::def_id::CrateNum;
use hir::map::DisambiguatedDefPathData;
use ty::print::Printer;
use ty::subst::Kind;

struct AbsolutePathPrinter<'a, 'gcx, 'tcx> {
tcx: TyCtxt<'a, 'gcx, 'tcx>,
Expand Down Expand Up @@ -523,7 +522,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
fn path_generic_args(
self,
print_prefix: impl FnOnce(Self) -> Result<Self::Path, Self::Error>,
_args: &[Kind<'tcx>],
_args: SubstsRef<'tcx>,
) -> Result<Self::Path, Self::Error> {
print_prefix(self)
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, InternalSubsts, SubstsRef};
use crate::ty::subst::{Kind, SubstsRef};
use crate::ty::{self, GenericParamDefKind, Ty, TyCtxt, CtxtInterners};
use crate::ty::{FloatVid, IntVid, TyVid};
use crate::util::nodemap::FxHashMap;
Expand Down Expand Up @@ -1100,7 +1100,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> {
InternalSubsts::for_item(self.tcx, def_id, |param, _| self.var_for_def(span, param))
SubstsRef::for_item(self.tcx, def_id, |param, _| self.var_for_def(span, param))
}

/// Returns `true` if errors have been reported since this infcx was
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/infer/opaque_types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,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, InternalSubsts, SubstsRef, UnpackedKind};
use crate::ty::subst::{Kind, SubstsRef, UnpackedKind};
use crate::util::nodemap::DefIdMap;

pub type OpaqueTypeMap<'tcx> = DefIdMap<OpaqueTypeDecl<'tcx>>;
Expand Down Expand Up @@ -469,7 +469,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 = InternalSubsts::identity_for_item(gcx, def_id);
let id_substs = SubstsRef::identity_for_item(gcx, def_id);
let map: FxHashMap<Kind<'tcx>, Kind<'gcx>> = opaque_defn
.substs
.iter()
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/infer/outlives/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, InternalSubsts};
use crate::ty::subst::{Subst, SubstsRef};
use crate::ty::{self, Ty, TyCtxt};
use crate::util::captures::Captures;

Expand Down Expand Up @@ -292,7 +292,7 @@ impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> {
.iter()
.map(|(p, _)| *p)
.collect();
let identity_substs = InternalSubsts::identity_for_item(tcx, assoc_item_def_id);
let identity_substs = SubstsRef::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,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/lint/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::lint::levels::{LintLevelSets, LintLevelsBuilder};
use crate::middle::privacy::AccessLevels;
use crate::rustc_serialize::{Decoder, Decodable, Encoder, Encodable};
use crate::session::{config, early_error, Session};
use crate::ty::{self, print::Printer, subst::{Kind, SubstsRef}, TyCtxt, Ty};
use crate::ty::{self, print::Printer, subst::SubstsRef, TyCtxt, Ty};
use crate::ty::layout::{LayoutError, LayoutOf, TyLayout};
use crate::util::nodemap::FxHashMap;
use crate::util::common::time;
Expand Down Expand Up @@ -873,7 +873,7 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
fn path_generic_args(
self,
print_prefix: impl FnOnce(Self) -> Result<Self::Path, Self::Error>,
_args: &[Kind<'tcx>],
_args: SubstsRef<'tcx>,
) -> Result<Self::Path, Self::Error> {
print_prefix(self)
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use crate::mir::interpret::ErrorHandled;
use rustc_macros::HashStable;
use syntax::ast;
use syntax_pos::{Span, DUMMY_SP};
use crate::ty::subst::{InternalSubsts, SubstsRef};
use crate::ty::subst::SubstsRef;
use crate::ty::{self, AdtKind, List, Ty, TyCtxt, GenericParamDefKind, ToPredicate};
use crate::ty::error::{ExpectedFound, TypeError};
use crate::ty::fold::{TypeFolder, TypeFoldable, TypeVisitor};
Expand Down Expand Up @@ -1008,7 +1008,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|
InternalSubsts::for_item(tcx, def_id, |param, _|
SubstsRef::for_item(tcx, def_id, |param, _|
match param.kind {
GenericParamDefKind::Lifetime => tcx.types.re_erased.into(),
GenericParamDefKind::Type { .. } |
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/traits/object_safety.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, InternalSubsts, SubstsRef};
use crate::ty::subst::{Subst, SubstsRef};
use std::borrow::Cow;
use std::iter::{self};
use syntax::ast::{self, Name};
Expand Down Expand Up @@ -407,7 +407,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 = InternalSubsts::for_item(self, method_def_id, |param, _| {
let substs = SubstsRef::for_item(self, method_def_id, |param, _| {
if param.index == 0 {
self_ty.into()
} else {
Expand Down Expand Up @@ -563,7 +563,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {

// U: Trait<Arg1, ..., ArgN>
let trait_predicate = {
let substs = InternalSubsts::for_item(
let substs = SubstsRef::for_item(
self,
method.container.assert_trait(),
|param, _| {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/traits/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::mir::interpret::{GlobalId, ConstValue};
use rustc_data_structures::snapshot_map::{Snapshot, SnapshotMap};
use rustc_macros::HashStable;
use syntax::ast::Ident;
use crate::ty::subst::{Subst, InternalSubsts};
use crate::ty::subst::{Subst, SubstsRef};
use crate::ty::{self, ToPredicate, ToPolyTraitRef, Ty, TyCtxt};
use crate::ty::fold::{TypeFoldable, TypeFolder};
use crate::util::common::FN_OUTPUT_NAME;
Expand Down Expand Up @@ -402,7 +402,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 = InternalSubsts::identity_for_item(tcx, def_id);
let identity_substs = SubstsRef::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 {
Expand Down Expand Up @@ -1492,7 +1492,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 = InternalSubsts::identity_for_item(tcx, assoc_ty.item.def_id);
let item_substs = SubstsRef::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)
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/traits/query/normalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::mir::interpret::{GlobalId, ConstValue};
use crate::traits::project::Normalized;
use crate::traits::{Obligation, ObligationCause, PredicateObligation, Reveal};
use crate::ty::fold::{TypeFoldable, TypeFolder};
use crate::ty::subst::{Subst, InternalSubsts};
use crate::ty::subst::{Subst, SubstsRef};
use crate::ty::{self, Ty, TyCtxt};

use super::NoSolution;
Expand Down Expand Up @@ -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 = InternalSubsts::identity_for_item(tcx, def_id);
let identity_substs = SubstsRef::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 {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/traits/specialize/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use rustc_data_structures::fx::FxHashSet;
use syntax_pos::DUMMY_SP;
use crate::traits::select::IntercrateAmbiguityCause;
use crate::ty::{self, TyCtxt, TypeFoldable};
use crate::ty::subst::{Subst, InternalSubsts, SubstsRef};
use crate::ty::subst::{Subst, SubstsRef};

use super::{SelectionContext, FulfillmentContext};
use super::util::impl_trait_ref_and_oblig;
Expand Down Expand Up @@ -398,7 +398,7 @@ fn to_pretty_impl_header(tcx: TyCtxt<'_, '_, '_>, impl_def_id: DefId) -> Option<

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

let substs = InternalSubsts::identity_for_item(tcx, impl_def_id);
let substs = SubstsRef::identity_for_item(tcx, impl_def_id);

// FIXME: Currently only handles ?Sized.
// Needs to support ?Move and ?DynSized when they are implemented.
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use crate::middle::resolve_lifetime::{self, ObjectLifetimeDefault};
use crate::middle::stability;
use crate::mir::{self, Mir, interpret, ProjectionKind};
use crate::mir::interpret::{ConstValue, Allocation};
use crate::ty::subst::{Kind, InternalSubsts, SubstsRef, Subst};
use crate::ty::ReprOptions;
use crate::traits;
use crate::traits::{Clause, Clauses, GoalKind, Goal, Goals};
Expand All @@ -41,7 +40,8 @@ use crate::ty::GenericParamDefKind;
use crate::ty::layout::{LayoutDetails, TargetDataLayout, VariantIdx};
use crate::ty::query;
use crate::ty::steal::Steal;
use crate::ty::subst::{UserSubsts, UnpackedKind};
use crate::ty::subst::{UserSubsts, UnpackedKind, SubstsRef, InternalSubsts};
use crate::ty::subst::{Kind, Subst};
use crate::ty::{BoundVar, BindingMode};
use crate::ty::CanonicalPolyFnSig;
use crate::util::nodemap::{DefIdMap, DefIdSet, ItemLocalMap, ItemLocalSet};
Expand Down Expand Up @@ -573,7 +573,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(
|| InternalSubsts::empty().into()
|| SubstsRef::empty().into()
)
}

Expand Down Expand Up @@ -2507,7 +2507,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 = InternalSubsts::for_item(self, def_id, |param, substs| {
let substs = SubstsRef::for_item(self, def_id, |param, substs| {
match param.kind {
GenericParamDefKind::Lifetime |
GenericParamDefKind::Const => {
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use crate::session::CrateDisambiguator;
use crate::traits::{self, Reveal};
use crate::ty;
use crate::ty::layout::VariantIdx;
use crate::ty::subst::{Subst, InternalSubsts, SubstsRef};
use crate::ty::subst::{Subst, SubstsRef};
use crate::ty::util::{IntTypeExt, Discr};
use crate::ty::walk::TypeWalker;
use crate::util::captures::Captures;
Expand Down Expand Up @@ -1422,8 +1422,8 @@ impl<'tcx> Predicate<'tcx> {
/// cases this is skipping over a binder, so late-bound regions
/// with depth 0 are bound by the predicate.
pub fn walk_tys(&'a self) -> impl Iterator<Item = Ty<'tcx>> + 'a {
match *self {
ty::Predicate::Trait(ref data) => {
match self {
ty::Predicate::Trait(data) => {
WalkTysIter::InputTypes(data.skip_binder().input_types())
}
ty::Predicate::Subtype(binder) => {
Expand All @@ -1436,7 +1436,7 @@ impl<'tcx> Predicate<'tcx> {
ty::Predicate::RegionOutlives(..) => {
WalkTysIter::None
}
ty::Predicate::Projection(ref data) => {
ty::Predicate::Projection(data) => {
let inner = data.skip_binder();
WalkTysIter::ProjectionTypes(
inner.projection_ty.substs.types().chain(Some(inner.ty)))
Expand Down Expand Up @@ -2356,7 +2356,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
) -> Option<Discr<'tcx>> {
let param_env = ParamEnv::empty();
let repr_type = self.repr.discr_type();
let substs = InternalSubsts::identity_for_item(tcx.global_tcx(), expr_did);
let substs = SubstsRef::identity_for_item(tcx.global_tcx(), expr_did);
let instance = ty::Instance::new(expr_did, substs);
let cid = GlobalId {
instance,
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/ty/print/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub trait Printer<'gcx: 'tcx, 'tcx>: Sized {
fn path_generic_args(
self,
print_prefix: impl FnOnce(Self) -> Result<Self::Path, Self::Error>,
args: &[Kind<'tcx>],
args: SubstsRef<'tcx>,
) -> Result<Self::Path, Self::Error>;

// Defaults (should not be overriden):
Expand Down Expand Up @@ -178,7 +178,7 @@ pub trait Printer<'gcx: 'tcx, 'tcx>: Sized {
&self,
generics: &'tcx ty::Generics,
substs: SubstsRef<'tcx>,
) -> &'tcx [Kind<'tcx>] {
) -> SubstsRef<'tcx> {
let mut own_params = generics.parent_count..generics.count();

// Don't print args for `Self` parameters (of traits).
Expand All @@ -199,7 +199,7 @@ pub trait Printer<'gcx: 'tcx, 'tcx>: Sized {
}
}).count();

&substs[own_params]
SubstsRef::from_slice(self.tcx(), &substs[own_params])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does this take TyCtxt as an argument? Is there a method that will just pass through the reference if it already has the appropriate lifetime?

}

fn default_print_impl_path(
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@ impl<F: fmt::Write> Printer<'gcx, 'tcx> for FmtPrinter<'_, 'gcx, 'tcx, F> {
fn path_generic_args(
mut self,
print_prefix: impl FnOnce(Self) -> Result<Self::Path, Self::Error>,
args: &[Kind<'tcx>],
args: SubstsRef<'tcx>,
) -> Result<Self::Path, Self::Error> {
self = print_prefix(self)?;

Expand Down
10 changes: 5 additions & 5 deletions src/librustc/ty/structural_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::ProjectionTy<'a> {
tcx.lift(&self.substs).map(|substs| {
ty::ProjectionTy {
item_def_id: self.item_def_id,
substs,
substs: substs.clone(),
}
})
}
Expand All @@ -511,7 +511,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::ExistentialProjection<'a> {
fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> {
tcx.lift(&self.substs).map(|substs| {
ty::ExistentialProjection {
substs,
substs: substs.clone(),
ty: tcx.lift(&self.ty).expect("type must lift when substs do"),
item_def_id: self.item_def_id,
}
Expand Down Expand Up @@ -544,7 +544,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::Predicate<'a> {
ty::Predicate::ClosureKind(closure_def_id, closure_substs, kind) => {
tcx.lift(&closure_substs)
.map(|closure_substs| ty::Predicate::ClosureKind(closure_def_id,
closure_substs,
closure_substs.clone(),
kind))
}
ty::Predicate::ObjectSafe(trait_def_id) => {
Expand Down Expand Up @@ -597,7 +597,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::ClosureSubsts<'a> {
type Lifted = ty::ClosureSubsts<'tcx>;
fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> {
tcx.lift(&self.substs).map(|substs| {
ty::ClosureSubsts { substs }
ty::ClosureSubsts { substs: substs.clone() }
})
}
}
Expand All @@ -606,7 +606,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::GeneratorSubsts<'a> {
type Lifted = ty::GeneratorSubsts<'tcx>;
fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> {
tcx.lift(&self.substs).map(|substs| {
ty::GeneratorSubsts { substs }
ty::GeneratorSubsts { substs: substs.clone() }
})
}
}
Expand Down
Loading