DefPathData::Impl => {
let generics = self.tcx().generics_of(def_id);
- let mut self_ty = self.tcx().type_of(def_id);
- let mut impl_trait_ref = self.tcx().impl_trait_ref(def_id);
- if substs.len() >= generics.count() {
- self_ty = self_ty.subst(self.tcx(), substs);
- impl_trait_ref = impl_trait_ref.subst(self.tcx(), substs);
- }
+ let self_ty = self.tcx().bound_type_of(def_id);
+ let impl_trait_ref = self.tcx().bound_impl_trait_ref(def_id);
+ let (self_ty, impl_trait_ref) = if substs.len() >= generics.count() {
+ (
+ self_ty.subst(self.tcx(), substs),
+ impl_trait_ref.map(|i| i.subst(self.tcx(), substs)),
+ )
+ } else {
+ (self_ty.0, impl_trait_ref.map(|i| i.0))
+ };
self.print_impl_path(def_id, substs, self_ty, impl_trait_ref)
}
match key.disambiguated_data.data {
// Closures' own generics are only captures, don't print them.
DefPathData::ClosureExpr => {}
+ // This covers both `DefKind::AnonConst` and `DefKind::InlineConst`.
+ // Anon consts doesn't have their own generics, and inline consts' own
+ // generics are their inferred types, so don't print them.
+ DefPathData::AnonConst => {}
// If we have any generic arguments to print, we do that
// on top of the same path, but without its own generics.
has_default
&& substs[param.index as usize]
== GenericArg::from(
- self.tcx().type_of(param.def_id).subst(self.tcx(), substs),
+ self.tcx().bound_type_of(param.def_id).subst(self.tcx(), substs),
)
}
ty::GenericParamDefKind::Const { has_default } => {
// as the trait.
let in_self_mod = match characteristic_def_id_of_type(self_ty) {
None => false,
- Some(ty_def_id) => self.tcx().parent(ty_def_id) == Some(parent_def_id),
+ Some(ty_def_id) => self.tcx().parent(ty_def_id) == parent_def_id,
};
let in_trait_mod = match impl_trait_ref {
None => false,
- Some(trait_ref) => self.tcx().parent(trait_ref.def_id) == Some(parent_def_id),
+ Some(trait_ref) => self.tcx().parent(trait_ref.def_id) == parent_def_id,
};
if !in_self_mod && !in_trait_mod {