change usages of type_of to bound_type_of

This commit is contained in:
Kyle Matsuda 2023-02-06 17:48:12 -07:00
parent 9a7cc6c32f
commit d822b97a27
136 changed files with 385 additions and 262 deletions

View file

@ -1580,7 +1580,8 @@ fn compare_generic_param_kinds<'tcx>(
use GenericParamDefKind::*;
if match (&param_impl.kind, &param_trait.kind) {
(Const { .. }, Const { .. })
if tcx.type_of(param_impl.def_id) != tcx.type_of(param_trait.def_id) =>
if tcx.bound_type_of(param_impl.def_id)
!= tcx.bound_type_of(param_trait.def_id) =>
{
true
}
@ -1605,7 +1606,11 @@ fn compare_generic_param_kinds<'tcx>(
let make_param_message = |prefix: &str, param: &ty::GenericParamDef| match param.kind {
Const { .. } => {
format!("{} const parameter of type `{}`", prefix, tcx.type_of(param.def_id))
format!(
"{} const parameter of type `{}`",
prefix,
tcx.bound_type_of(param.def_id).subst_identity()
)
}
Type { .. } => format!("{} type parameter", prefix),
Lifetime { .. } => unreachable!(),
@ -1654,7 +1659,7 @@ pub(super) fn compare_impl_const_raw(
// Create a parameter environment that represents the implementation's
// method.
// Compute placeholder form of impl and trait const tys.
let impl_ty = tcx.type_of(impl_const_item_def.to_def_id());
let impl_ty = tcx.bound_type_of(impl_const_item_def.to_def_id()).subst_identity();
let trait_ty = tcx.bound_type_of(trait_const_item_def).subst(tcx, trait_to_impl_substs);
let mut cause = ObligationCause::new(
impl_c_span,
@ -1927,7 +1932,7 @@ pub(super) fn check_type_bounds<'tcx>(
bound_vars.push(bound_var);
tcx.mk_const(
ty::ConstKind::Bound(ty::INNERMOST, ty::BoundVar::from_usize(bound_vars.len() - 1)),
tcx.type_of(param.def_id),
tcx.bound_type_of(param.def_id).subst_identity(),
)
.into()
}
@ -1937,7 +1942,7 @@ pub(super) fn check_type_bounds<'tcx>(
let container_id = impl_ty.container_id(tcx);
let rebased_substs = impl_ty_substs.rebase_onto(tcx, container_id, impl_trait_ref.substs);
let impl_ty_value = tcx.type_of(impl_ty.def_id);
let impl_ty_value = tcx.bound_type_of(impl_ty.def_id).subst_identity();
let param_env = tcx.param_env(impl_ty.def_id);