change usages of type_of to bound_type_of
This commit is contained in:
@@ -82,8 +82,8 @@ pub fn overlapping_impls(
|
||||
(Some(a), Some(b)) => iter::zip(a.skip_binder().substs, b.skip_binder().substs)
|
||||
.all(|(arg1, arg2)| drcx.generic_args_may_unify(arg1, arg2)),
|
||||
(None, None) => {
|
||||
let self_ty1 = tcx.type_of(impl1_def_id);
|
||||
let self_ty2 = tcx.type_of(impl2_def_id);
|
||||
let self_ty1 = tcx.bound_type_of(impl1_def_id).skip_binder();
|
||||
let self_ty2 = tcx.bound_type_of(impl2_def_id).skip_binder();
|
||||
drcx.types_may_unify(self_ty1, self_ty2)
|
||||
}
|
||||
_ => bug!("unexpected impls: {impl1_def_id:?} {impl2_def_id:?}"),
|
||||
|
||||
@@ -2432,7 +2432,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
};
|
||||
let mut suggestions = vec![(
|
||||
path.span.shrink_to_lo(),
|
||||
format!("<{} as ", self.tcx.type_of(impl_def_id))
|
||||
format!("<{} as ", self.tcx.bound_type_of(impl_def_id).subst_identity())
|
||||
)];
|
||||
if let Some(generic_arg) = trait_path_segment.args {
|
||||
let between_span = trait_path_segment.ident.span.between(generic_arg.span_ext);
|
||||
|
||||
@@ -200,7 +200,10 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
if let Some(def) = self_ty.ty_adt_def() {
|
||||
// We also want to be able to select self's original
|
||||
// signature with no type arguments resolved
|
||||
flags.push((sym::_Self, Some(self.tcx.type_of(def.did()).to_string())));
|
||||
flags.push((
|
||||
sym::_Self,
|
||||
Some(self.tcx.bound_type_of(def.did()).subst_identity().to_string()),
|
||||
));
|
||||
}
|
||||
|
||||
for param in generics.params.iter() {
|
||||
@@ -218,7 +221,10 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
if let Some(def) = param_ty.ty_adt_def() {
|
||||
// We also want to be able to select the parameter's
|
||||
// original signature with no type arguments resolved
|
||||
flags.push((name, Some(self.tcx.type_of(def.did()).to_string())));
|
||||
flags.push((
|
||||
name,
|
||||
Some(self.tcx.bound_type_of(def.did()).subst_identity().to_string()),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -251,7 +257,10 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
if let Some(def) = aty.ty_adt_def() {
|
||||
// We also want to be able to select the slice's type's original
|
||||
// signature with no type arguments resolved
|
||||
flags.push((sym::_Self, Some(format!("[{}]", self.tcx.type_of(def.did())))));
|
||||
flags.push((
|
||||
sym::_Self,
|
||||
Some(format!("[{}]", self.tcx.bound_type_of(def.did()).subst_identity())),
|
||||
));
|
||||
}
|
||||
if aty.is_integral() {
|
||||
flags.push((sym::_Self, Some("[{integral}]".to_string())));
|
||||
@@ -269,7 +278,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
if let Some(def) = aty.ty_adt_def() {
|
||||
// We also want to be able to select the array's type's original
|
||||
// signature with no type arguments resolved
|
||||
let def_ty = self.tcx.type_of(def.did());
|
||||
let def_ty = self.tcx.bound_type_of(def.did()).subst_identity();
|
||||
flags.push((sym::_Self, Some(format!("[{def_ty}; _]"))));
|
||||
if let Some(n) = len {
|
||||
flags.push((sym::_Self, Some(format!("[{def_ty}; {n}]"))));
|
||||
|
||||
@@ -557,7 +557,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
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()
|
||||
}
|
||||
|
||||
@@ -455,7 +455,13 @@ pub(crate) fn to_pretty_impl_header(tcx: TyCtxt<'_>, impl_def_id: DefId) -> Opti
|
||||
w.push('>');
|
||||
}
|
||||
|
||||
write!(w, " {} for {}", trait_ref.print_only_trait_path(), tcx.type_of(impl_def_id)).unwrap();
|
||||
write!(
|
||||
w,
|
||||
" {} for {}",
|
||||
trait_ref.print_only_trait_path(),
|
||||
tcx.bound_type_of(impl_def_id).subst_identity()
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
// The predicates will contain default bounds like `T: Sized`. We need to
|
||||
// remove these bounds, and add `T: ?Sized` to any untouched type parameters.
|
||||
|
||||
Reference in New Issue
Block a user