change usages of type_of to bound_type_of
This commit is contained in:
@@ -104,7 +104,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
self.impl_trait_ref(def_id)
|
||||
.map(|t| t.subst_identity())
|
||||
.map(ImplSubject::Trait)
|
||||
.unwrap_or_else(|| ImplSubject::Inherent(self.type_of(def_id)))
|
||||
.unwrap_or_else(|| ImplSubject::Inherent(self.bound_type_of(def_id).subst_identity()))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2497,7 +2497,7 @@ impl<'tcx> ConstantKind<'tcx> {
|
||||
};
|
||||
debug!("expr.kind: {:?}", expr.kind);
|
||||
|
||||
let ty = tcx.type_of(def.def_id_for_type_of());
|
||||
let ty = tcx.bound_type_of(def.def_id_for_type_of()).subst_identity();
|
||||
debug!(?ty);
|
||||
|
||||
// FIXME(const_generics): We currently have to special case parameters because `min_const_generics`
|
||||
|
||||
@@ -165,7 +165,7 @@ impl<'tcx> Rvalue<'tcx> {
|
||||
tcx.mk_array_with_const_len(operand.ty(local_decls, tcx), count)
|
||||
}
|
||||
Rvalue::ThreadLocalRef(did) => {
|
||||
let static_ty = tcx.type_of(did);
|
||||
let static_ty = tcx.bound_type_of(did).subst_identity();
|
||||
if tcx.is_mutable_static(did) {
|
||||
tcx.mk_mut_ptr(static_ty)
|
||||
} else if tcx.is_foreign_item(did) {
|
||||
|
||||
@@ -263,7 +263,9 @@ pub fn ancestors(
|
||||
|
||||
if let Some(reported) = specialization_graph.has_errored {
|
||||
Err(reported)
|
||||
} else if let Err(reported) = tcx.type_of(start_from_impl).error_reported() {
|
||||
} else if let Err(reported) =
|
||||
tcx.bound_type_of(start_from_impl).subst_identity().error_reported()
|
||||
{
|
||||
Err(reported)
|
||||
} else {
|
||||
Ok(Ancestors {
|
||||
|
||||
@@ -83,7 +83,11 @@ impl AssocItem {
|
||||
}
|
||||
ty::AssocKind::Type => format!("type {};", self.name),
|
||||
ty::AssocKind::Const => {
|
||||
format!("const {}: {:?};", self.name, tcx.type_of(self.def_id))
|
||||
format!(
|
||||
"const {}: {:?};",
|
||||
self.name,
|
||||
tcx.bound_type_of(self.def_id).subst_identity()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ impl<'tcx> Const<'tcx> {
|
||||
let expr = &tcx.hir().body(body_id).value;
|
||||
debug!(?expr);
|
||||
|
||||
let ty = tcx.type_of(def.def_id_for_type_of());
|
||||
let ty = tcx.bound_type_of(def.def_id_for_type_of()).subst_identity();
|
||||
|
||||
match Self::try_eval_lit_or_param(tcx, ty, expr) {
|
||||
Some(v) => v,
|
||||
|
||||
@@ -1149,7 +1149,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
_ => return None,
|
||||
}
|
||||
|
||||
let ret_ty = self.type_of(scope_def_id);
|
||||
let ret_ty = self.bound_type_of(scope_def_id).subst_identity();
|
||||
match ret_ty.kind() {
|
||||
ty::FnDef(_, _) => {
|
||||
let sig = ret_ty.fn_sig(self);
|
||||
@@ -2002,7 +2002,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
GenericParamDefKind::Const { .. } => self
|
||||
.mk_const(
|
||||
ParamConst { index: param.index, name: param.name },
|
||||
self.type_of(param.def_id),
|
||||
self.bound_type_of(param.def_id).subst_identity(),
|
||||
)
|
||||
.into(),
|
||||
}
|
||||
|
||||
@@ -481,8 +481,9 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for IsSuggestableVisitor<'tcx> {
|
||||
|
||||
Alias(Opaque, AliasTy { def_id, .. }) => {
|
||||
let parent = self.tcx.parent(def_id);
|
||||
let parent_ty = self.tcx.bound_type_of(parent).subst_identity();
|
||||
if let DefKind::TyAlias | DefKind::AssocTy = self.tcx.def_kind(parent)
|
||||
&& let Alias(Opaque, AliasTy { def_id: parent_opaque_def_id, .. }) = *self.tcx.type_of(parent).kind()
|
||||
&& let Alias(Opaque, AliasTy { def_id: parent_opaque_def_id, .. }) = *parent_ty.kind()
|
||||
&& parent_opaque_def_id == def_id
|
||||
{
|
||||
// Okay
|
||||
@@ -564,8 +565,9 @@ impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for MakeSuggestableFolder<'tcx> {
|
||||
|
||||
Alias(Opaque, AliasTy { def_id, .. }) => {
|
||||
let parent = self.tcx.parent(def_id);
|
||||
let parent_ty = self.tcx.bound_type_of(parent).subst_identity();
|
||||
if let hir::def::DefKind::TyAlias | hir::def::DefKind::AssocTy = self.tcx.def_kind(parent)
|
||||
&& let Alias(Opaque, AliasTy { def_id: parent_opaque_def_id, .. }) = *self.tcx.type_of(parent).kind()
|
||||
&& let Alias(Opaque, AliasTy { def_id: parent_opaque_def_id, .. }) = *parent_ty.kind()
|
||||
&& parent_opaque_def_id == def_id
|
||||
{
|
||||
t
|
||||
|
||||
@@ -87,7 +87,7 @@ impl<'tcx> VariantDef {
|
||||
InhabitedPredicate::all(
|
||||
tcx,
|
||||
self.fields.iter().map(|field| {
|
||||
let pred = tcx.type_of(field.did).inhabited_predicate(tcx);
|
||||
let pred = tcx.bound_type_of(field.did).subst_identity().inhabited_predicate(tcx);
|
||||
if adt.is_enum() {
|
||||
return pred;
|
||||
}
|
||||
|
||||
@@ -102,8 +102,8 @@ impl<'tcx> Instance<'tcx> {
|
||||
/// Returns the `Ty` corresponding to this `Instance`, with generic substitutions applied and
|
||||
/// lifetimes erased, allowing a `ParamEnv` to be specified for use during normalization.
|
||||
pub fn ty(&self, tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>) -> Ty<'tcx> {
|
||||
let ty = tcx.type_of(self.def.def_id());
|
||||
tcx.subst_and_normalize_erasing_regions(self.substs, param_env, ty)
|
||||
let ty = tcx.bound_type_of(self.def.def_id());
|
||||
tcx.subst_and_normalize_erasing_regions(self.substs, param_env, ty.skip_binder())
|
||||
}
|
||||
|
||||
/// Finds a crate that contains a monomorphization of this instance that
|
||||
@@ -662,7 +662,7 @@ fn polymorphize<'tcx>(
|
||||
let def_id = instance.def_id();
|
||||
let upvars_ty = if tcx.is_closure(def_id) {
|
||||
Some(substs.as_closure().tupled_upvars_ty())
|
||||
} else if tcx.type_of(def_id).is_generator() {
|
||||
} else if tcx.bound_type_of(def_id).skip_binder().is_generator() {
|
||||
Some(substs.as_generator().tupled_upvars_ty())
|
||||
} else {
|
||||
None
|
||||
|
||||
@@ -754,7 +754,7 @@ pub trait PrettyPrinter<'tcx>:
|
||||
// NOTE: I know we should check for NO_QUERIES here, but it's alright.
|
||||
// `type_of` on a type alias or assoc type should never cause a cycle.
|
||||
if let ty::Alias(ty::Opaque, ty::AliasTy { def_id: d, .. }) =
|
||||
*self.tcx().type_of(parent).kind()
|
||||
*self.tcx().bound_type_of(parent).subst_identity().kind()
|
||||
{
|
||||
if d == def_id {
|
||||
// If the type alias directly starts with the `impl` of the
|
||||
|
||||
@@ -225,7 +225,7 @@ pub(super) fn trait_impls_of_provider(tcx: TyCtxt<'_>, trait_id: DefId) -> Trait
|
||||
for &impl_def_id in tcx.hir().trait_impls(trait_id) {
|
||||
let impl_def_id = impl_def_id.to_def_id();
|
||||
|
||||
let impl_self_ty = tcx.type_of(impl_def_id);
|
||||
let impl_self_ty = tcx.bound_type_of(impl_def_id).subst_identity();
|
||||
if impl_self_ty.references_error() {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -362,7 +362,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
let drop_trait = self.lang_items().drop_trait()?;
|
||||
self.ensure().coherent_trait(drop_trait);
|
||||
|
||||
let ty = self.type_of(adt_did);
|
||||
let ty = self.bound_type_of(adt_did).subst_identity();
|
||||
let (did, constness) = self.find_map_relevant_impl(drop_trait, ty, |impl_did| {
|
||||
if let Some(item_id) = self.associated_item_def_ids(impl_did).first() {
|
||||
if validate(self, impl_did).is_ok() {
|
||||
@@ -415,12 +415,12 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
// <P1, P2, P0>, and then look up which of the impl substs refer to
|
||||
// parameters marked as pure.
|
||||
|
||||
let impl_substs = match *self.type_of(impl_def_id).kind() {
|
||||
let impl_substs = match *self.bound_type_of(impl_def_id).subst_identity().kind() {
|
||||
ty::Adt(def_, substs) if def_ == def => substs,
|
||||
_ => bug!(),
|
||||
};
|
||||
|
||||
let item_substs = match *self.type_of(def.did()).kind() {
|
||||
let item_substs = match *self.bound_type_of(def.did()).subst_identity().kind() {
|
||||
ty::Adt(def_, substs) if def_ == def => substs,
|
||||
_ => bug!(),
|
||||
};
|
||||
@@ -602,7 +602,10 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
/// Get the type of the pointer to the static that we use in MIR.
|
||||
pub fn static_ptr_ty(self, def_id: DefId) -> Ty<'tcx> {
|
||||
// Make sure that any constants in the static's type are evaluated.
|
||||
let static_ty = self.normalize_erasing_regions(ty::ParamEnv::empty(), self.type_of(def_id));
|
||||
let static_ty = self.normalize_erasing_regions(
|
||||
ty::ParamEnv::empty(),
|
||||
self.bound_type_of(def_id).subst_identity(),
|
||||
);
|
||||
|
||||
// Make sure that accesses to unsafe statics end up using raw pointers.
|
||||
// For thread-locals, this needs to be kept in sync with `Rvalue::ty`.
|
||||
|
||||
Reference in New Issue
Block a user