From 8adb0b6d6c264facc6e213ad06a25194e7591682 Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Wed, 24 Nov 2021 12:21:44 -0800 Subject: [PATCH 1/3] Clean up `clean` re-exports This will allow re-exporting only certain enum variants. --- src/librustdoc/clean/mod.rs | 5 ----- src/librustdoc/clean/types.rs | 13 ++++++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 5c893e44a9f..10648d74e93 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -43,11 +43,6 @@ use utils::*; crate use utils::{get_auto_trait_and_blanket_impls, krate, register_res}; -crate use self::types::FnRetTy::*; -crate use self::types::ItemKind::*; -crate use self::types::SelfTy::*; -crate use self::types::Type::*; -crate use self::types::Visibility::{Inherited, Public}; crate use self::types::*; crate trait Clean { diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 9e088ac72ad..7704e66bd39 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -34,7 +34,6 @@ use rustc_target::spec::abi::Abi; use crate::clean::cfg::Cfg; use crate::clean::external_path; use crate::clean::inline::{self, print_inlined_const}; -use crate::clean::types::Type::{QPath, ResolvedPath}; use crate::clean::utils::{is_literal_expr, print_const_expr, print_evaluated_const}; use crate::clean::Clean; use crate::core::DocContext; @@ -43,10 +42,14 @@ use crate::formats::item_type::ItemType; use crate::html::render::cache::ExternalLocation; use crate::html::render::Context; -use self::FnRetTy::*; -use self::ItemKind::*; -use self::SelfTy::*; -use self::Type::*; +crate use self::FnRetTy::*; +crate use self::ItemKind::*; +crate use self::SelfTy::*; +crate use self::Type::{ + Array, BareFunction, BorrowedRef, DynTrait, Generic, ImplTrait, Infer, Primitive, QPath, + RawPointer, ResolvedPath, Slice, Tuple, +}; +crate use self::Visibility::{Inherited, Public}; crate type ItemIdSet = FxHashSet; From d81deb33fa8e9f03006b637fd0c035dc7acc5343 Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Wed, 24 Nov 2021 12:27:37 -0800 Subject: [PATCH 2/3] Stop re-exporting `Type::ResolvedPath` I would like to rename it to `Type::Path`, but then it can't be re-exported since the name would conflict with the `Path` struct. Usually enum variants are referred to using their qualified names in Rust (and parts of rustdoc already do that with `clean::Type`), so this is also more consistent with the language. --- src/librustdoc/clean/mod.rs | 7 +++---- src/librustdoc/clean/types.rs | 8 ++++---- src/librustdoc/clean/utils.rs | 7 +++---- src/librustdoc/formats/cache.rs | 8 +++++--- src/librustdoc/html/format.rs | 2 +- src/librustdoc/html/render/cache.rs | 2 +- src/librustdoc/html/render/mod.rs | 2 +- src/librustdoc/html/render/print_item.rs | 25 ++++++++++++------------ src/librustdoc/json/conversions.rs | 14 ++++++++----- 9 files changed, 39 insertions(+), 36 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 10648d74e93..e8c55d10901 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -41,9 +41,8 @@ use crate::visit_ast::Module as DocModule; use utils::*; -crate use utils::{get_auto_trait_and_blanket_impls, krate, register_res}; - crate use self::types::*; +crate use self::utils::{get_auto_trait_and_blanket_impls, krate, register_res}; crate trait Clean { fn clean(&self, cx: &mut DocContext<'_>) -> T; @@ -1406,12 +1405,12 @@ impl<'tcx> Clean for Ty<'tcx> { }; inline::record_extern_fqn(cx, did, kind); let path = external_path(cx, did, false, vec![], substs); - ResolvedPath { path } + Type::ResolvedPath { path } } ty::Foreign(did) => { inline::record_extern_fqn(cx, did, ItemType::ForeignType); let path = external_path(cx, did, false, vec![], InternalSubsts::empty()); - ResolvedPath { path } + Type::ResolvedPath { path } } ty::Dynamic(obj, ref reg) => { // HACK: pick the first `did` as the `did` of the trait object. Someone diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 7704e66bd39..b5192d2c082 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -47,7 +47,7 @@ crate use self::ItemKind::*; crate use self::SelfTy::*; crate use self::Type::{ Array, BareFunction, BorrowedRef, DynTrait, Generic, ImplTrait, Infer, Primitive, QPath, - RawPointer, ResolvedPath, Slice, Tuple, + RawPointer, Slice, Tuple, }; crate use self::Visibility::{Inherited, Public}; @@ -1488,7 +1488,7 @@ impl Type { /// Checks if this is a `T::Name` path for an associated type. crate fn is_assoc_ty(&self) -> bool { match self { - ResolvedPath { path, .. } => path.is_assoc_ty(), + Type::ResolvedPath { path, .. } => path.is_assoc_ty(), _ => false, } } @@ -1502,7 +1502,7 @@ impl Type { crate fn generics(&self) -> Option> { match self { - ResolvedPath { path, .. } => path.generics(), + Type::ResolvedPath { path, .. } => path.generics(), _ => None, } } @@ -1525,7 +1525,7 @@ impl Type { fn inner_def_id(&self, cache: Option<&Cache>) -> Option { let t: PrimitiveType = match *self { - ResolvedPath { ref path } => return Some(path.def_id()), + Type::ResolvedPath { ref path } => return Some(path.def_id()), DynTrait(ref bounds, _) => return Some(bounds[0].trait_.def_id()), Primitive(p) => return cache.and_then(|c| c.primitive_locations.get(&p).cloned()), BorrowedRef { type_: box Generic(..), .. } => PrimitiveType::Reference, diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index 1141aff41f2..40fa5b8a33e 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -2,8 +2,7 @@ use crate::clean::auto_trait::AutoTraitFinder; use crate::clean::blanket_impl::BlanketImplFinder; use crate::clean::{ inline, Clean, Crate, ExternalCrate, Generic, GenericArg, GenericArgs, ImportSource, Item, - ItemKind, Lifetime, Path, PathSegment, Primitive, PrimitiveType, ResolvedPath, Type, - TypeBinding, Visibility, + ItemKind, Lifetime, Path, PathSegment, Primitive, PrimitiveType, Type, TypeBinding, Visibility, }; use crate::core::DocContext; use crate::formats::item_type::ItemType; @@ -187,7 +186,7 @@ crate fn build_deref_target_impls(cx: &mut DocContext<'_>, items: &[Item], ret: for &did in prim.impls(tcx).iter().filter(|did| !did.is_local()) { inline::build_impl(cx, None, did, None, ret); } - } else if let ResolvedPath { path } = target { + } else if let Type::ResolvedPath { path } = target { let did = path.def_id(); if !did.is_local() { inline::build_impls(cx, None, did, None, ret); @@ -362,7 +361,7 @@ crate fn resolve_type(cx: &mut DocContext<'_>, path: Path) -> Type { Res::Def(DefKind::TyParam, _) if path.segments.len() == 1 => Generic(path.segments[0].name), _ => { let _ = register_res(cx, path.res); - ResolvedPath { path } + Type::ResolvedPath { path } } } } diff --git a/src/librustdoc/formats/cache.rs b/src/librustdoc/formats/cache.rs index dd13c4809bb..06fcdd05212 100644 --- a/src/librustdoc/formats/cache.rs +++ b/src/librustdoc/formats/cache.rs @@ -401,7 +401,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> { clean::ImplItem(ref i) => { self.cache.parent_is_trait_impl = i.trait_.is_some(); match i.for_ { - clean::ResolvedPath { ref path } => { + clean::Type::ResolvedPath { ref path } => { self.cache.parent_stack.push(path.def_id()); true } @@ -436,8 +436,10 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> { // Note: matching twice to restrict the lifetime of the `i` borrow. let mut dids = FxHashSet::default(); match i.for_ { - clean::ResolvedPath { ref path } - | clean::BorrowedRef { type_: box clean::ResolvedPath { ref path }, .. } => { + clean::Type::ResolvedPath { ref path } + | clean::BorrowedRef { + type_: box clean::Type::ResolvedPath { ref path }, .. + } => { dids.insert(path.def_id()); } clean::DynTrait(ref bounds, _) diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 1ed3ba7ece0..d3603d17925 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -762,7 +762,7 @@ fn fmt_type<'cx>( match *t { clean::Generic(name) => write!(f, "{}", name), - clean::ResolvedPath { ref path } => { + clean::Type::ResolvedPath { ref path } => { // Paths like `T::Output` and `Self::Output` should be rendered with all segments. let did = path.def_id(); resolved_path(f, did, path, path.is_assoc_ty(), use_absolute, cx) diff --git a/src/librustdoc/html/render/cache.rs b/src/librustdoc/html/render/cache.rs index c114edf1e70..ffa5ec8a3ee 100644 --- a/src/librustdoc/html/render/cache.rs +++ b/src/librustdoc/html/render/cache.rs @@ -218,7 +218,7 @@ fn get_index_type(clean_type: &clean::Type, generics: Vec) -> Rend fn get_index_type_name(clean_type: &clean::Type, accept_generic: bool) -> Option { match *clean_type { - clean::ResolvedPath { ref path, .. } => { + clean::Type::ResolvedPath { ref path, .. } => { let path_segment = path.segments.last().unwrap(); Some(path_segment.name) } diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 7d231a0d649..42a2defa757 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -1227,7 +1227,7 @@ fn should_render_item(item: &clean::Item, deref_mut_: bool, tcx: TyCtxt<'_>) -> | SelfTy::SelfExplicit(clean::BorrowedRef { mutability, .. }) => { (mutability == Mutability::Mut, false, false) } - SelfTy::SelfExplicit(clean::ResolvedPath { path }) => { + SelfTy::SelfExplicit(clean::Type::ResolvedPath { path }) => { (false, Some(path.def_id()) == tcx.lang_items().owned_box(), false) } SelfTy::SelfValue => (false, false, true), diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index e59b94f6b7d..f8a16fb9b71 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -727,10 +727,10 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra let mut implementor_dups: FxHashMap = FxHashMap::default(); for implementor in implementors { match implementor.inner_impl().for_ { - clean::ResolvedPath { ref path } - | clean::BorrowedRef { type_: box clean::ResolvedPath { ref path }, .. } - if !path.is_assoc_ty() => - { + clean::Type::ResolvedPath { ref path } + | clean::BorrowedRef { + type_: box clean::Type::ResolvedPath { ref path }, .. + } if !path.is_assoc_ty() => { let did = path.def_id(); let &mut (prev_did, ref mut has_duplicates) = implementor_dups.entry(path.last()).or_insert((did, false)); @@ -1452,15 +1452,14 @@ fn render_implementor( ) { // If there's already another implementor that has the same abridged name, use the // full path, for example in `std::iter::ExactSizeIterator` - let use_absolute = match implementor.inner_impl().for_ { - clean::ResolvedPath { ref path, .. } - | clean::BorrowedRef { type_: box clean::ResolvedPath { ref path, .. }, .. } - if !path.is_assoc_ty() => - { - implementor_dups[&path.last()].1 - } - _ => false, - }; + let use_absolute = + match implementor.inner_impl().for_ { + clean::Type::ResolvedPath { ref path, .. } + | clean::BorrowedRef { + type_: box clean::Type::ResolvedPath { ref path, .. }, .. + } if !path.is_assoc_ty() => implementor_dups[&path.last()].1, + _ => false, + }; render_impl( w, cx, diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index a5c1eb12410..ed8f7274591 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -365,7 +365,7 @@ impl FromWithTcx for GenericBound { match bound { TraitBound(clean::PolyTrait { trait_, generic_params }, modifier) => { // FIXME: should `trait_` be a clean::Path equivalent in JSON? - let trait_ = clean::ResolvedPath { path: trait_ }.into_tcx(tcx); + let trait_ = clean::Type::ResolvedPath { path: trait_ }.into_tcx(tcx); GenericBound::TraitBound { trait_, generic_params: generic_params.into_iter().map(|x| x.into_tcx(tcx)).collect(), @@ -388,9 +388,13 @@ crate fn from_trait_bound_modifier(modifier: rustc_hir::TraitBoundModifier) -> T impl FromWithTcx for Type { fn from_tcx(ty: clean::Type, tcx: TyCtxt<'_>) -> Self { - use clean::Type::*; + use clean::Type::{ + Array, BareFunction, BorrowedRef, DynTrait, Generic, ImplTrait, Infer, Primitive, + QPath, RawPointer, Slice, Tuple, + }; + match ty { - ResolvedPath { path } => Type::ResolvedPath { + clean::Type::ResolvedPath { path } => Type::ResolvedPath { name: path.whole_name(), id: from_item_id(path.def_id().into()), args: path.segments.last().map(|args| Box::new(args.clone().args.into_tcx(tcx))), @@ -435,7 +439,7 @@ impl FromWithTcx for Type { }, QPath { name, self_type, trait_, .. } => { // FIXME: should `trait_` be a clean::Path equivalent in JSON? - let trait_ = ResolvedPath { path: trait_ }.into_tcx(tcx); + let trait_ = clean::Type::ResolvedPath { path: trait_ }.into_tcx(tcx); Type::QualifiedPath { name: name.to_string(), self_type: Box::new((*self_type).into_tcx(tcx)), @@ -501,7 +505,7 @@ impl FromWithTcx for Impl { let provided_trait_methods = impl_.provided_trait_methods(tcx); let clean::Impl { unsafety, generics, trait_, for_, items, polarity, kind } = impl_; // FIXME: should `trait_` be a clean::Path equivalent in JSON? - let trait_ = trait_.map(|path| clean::ResolvedPath { path }.into_tcx(tcx)); + let trait_ = trait_.map(|path| clean::Type::ResolvedPath { path }.into_tcx(tcx)); // FIXME: use something like ImplKind in JSON? let (synthetic, blanket_impl) = match kind { clean::ImplKind::Normal => (false, None), From 79c718f1d5916318b5d55e6c1391a438cae1f763 Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Wed, 24 Nov 2021 12:29:58 -0800 Subject: [PATCH 3/3] Rename `Type::ResolvedPath` to `Type::Path` At last! The new name is shorter, simpler, and consistent with `hir::Ty`. --- src/librustdoc/clean/mod.rs | 4 ++-- src/librustdoc/clean/types.rs | 11 ++++++----- src/librustdoc/clean/utils.rs | 4 ++-- src/librustdoc/formats/cache.rs | 10 ++++------ src/librustdoc/html/format.rs | 5 ++--- src/librustdoc/html/render/cache.rs | 4 ++-- src/librustdoc/html/render/mod.rs | 4 ++-- src/librustdoc/html/render/print_item.rs | 25 ++++++++++++------------ src/librustdoc/json/conversions.rs | 8 ++++---- 9 files changed, 37 insertions(+), 38 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index e8c55d10901..4e1dabd05bb 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1405,12 +1405,12 @@ impl<'tcx> Clean for Ty<'tcx> { }; inline::record_extern_fqn(cx, did, kind); let path = external_path(cx, did, false, vec![], substs); - Type::ResolvedPath { path } + Type::Path { path } } ty::Foreign(did) => { inline::record_extern_fqn(cx, did, ItemType::ForeignType); let path = external_path(cx, did, false, vec![], InternalSubsts::empty()); - Type::ResolvedPath { path } + Type::Path { path } } ty::Dynamic(obj, ref reg) => { // HACK: pick the first `did` as the `did` of the trait object. Someone diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index b5192d2c082..37acf68defd 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -1421,8 +1421,9 @@ crate struct PolyTrait { crate enum Type { /// A named type, which could be a trait. /// - /// This is mostly Rustdoc's version of [`hir::Path`]. It has to be different because Rustdoc's [`PathSegment`] can contain cleaned generics. - ResolvedPath { path: Path }, + /// This is mostly Rustdoc's version of [`hir::Path`]. + /// It has to be different because Rustdoc's [`PathSegment`] can contain cleaned generics. + Path { path: Path }, /// A `dyn Trait` object: `dyn for<'a> Trait<'a> + Send + 'static` DynTrait(Vec, Option), /// A type parameter. @@ -1488,7 +1489,7 @@ impl Type { /// Checks if this is a `T::Name` path for an associated type. crate fn is_assoc_ty(&self) -> bool { match self { - Type::ResolvedPath { path, .. } => path.is_assoc_ty(), + Type::Path { path, .. } => path.is_assoc_ty(), _ => false, } } @@ -1502,7 +1503,7 @@ impl Type { crate fn generics(&self) -> Option> { match self { - Type::ResolvedPath { path, .. } => path.generics(), + Type::Path { path, .. } => path.generics(), _ => None, } } @@ -1525,7 +1526,7 @@ impl Type { fn inner_def_id(&self, cache: Option<&Cache>) -> Option { let t: PrimitiveType = match *self { - Type::ResolvedPath { ref path } => return Some(path.def_id()), + Type::Path { ref path } => return Some(path.def_id()), DynTrait(ref bounds, _) => return Some(bounds[0].trait_.def_id()), Primitive(p) => return cache.and_then(|c| c.primitive_locations.get(&p).cloned()), BorrowedRef { type_: box Generic(..), .. } => PrimitiveType::Reference, diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index 40fa5b8a33e..38f53d7e0b2 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -186,7 +186,7 @@ crate fn build_deref_target_impls(cx: &mut DocContext<'_>, items: &[Item], ret: for &did in prim.impls(tcx).iter().filter(|did| !did.is_local()) { inline::build_impl(cx, None, did, None, ret); } - } else if let Type::ResolvedPath { path } = target { + } else if let Type::Path { path } = target { let did = path.def_id(); if !did.is_local() { inline::build_impls(cx, None, did, None, ret); @@ -361,7 +361,7 @@ crate fn resolve_type(cx: &mut DocContext<'_>, path: Path) -> Type { Res::Def(DefKind::TyParam, _) if path.segments.len() == 1 => Generic(path.segments[0].name), _ => { let _ = register_res(cx, path.res); - Type::ResolvedPath { path } + Type::Path { path } } } } diff --git a/src/librustdoc/formats/cache.rs b/src/librustdoc/formats/cache.rs index 06fcdd05212..d3831450e1d 100644 --- a/src/librustdoc/formats/cache.rs +++ b/src/librustdoc/formats/cache.rs @@ -27,7 +27,7 @@ use crate::html::render::IndexItem; #[derive(Default)] crate struct Cache { /// Maps a type ID to all known implementations for that type. This is only - /// recognized for intra-crate `ResolvedPath` types, and is used to print + /// recognized for intra-crate [`clean::Type::Path`]s, and is used to print /// out extra documentation on the page of an enum/struct. /// /// The values of the map are a list of implementations and documentation @@ -401,7 +401,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> { clean::ImplItem(ref i) => { self.cache.parent_is_trait_impl = i.trait_.is_some(); match i.for_ { - clean::Type::ResolvedPath { ref path } => { + clean::Type::Path { ref path } => { self.cache.parent_stack.push(path.def_id()); true } @@ -436,10 +436,8 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> { // Note: matching twice to restrict the lifetime of the `i` borrow. let mut dids = FxHashSet::default(); match i.for_ { - clean::Type::ResolvedPath { ref path } - | clean::BorrowedRef { - type_: box clean::Type::ResolvedPath { ref path }, .. - } => { + clean::Type::Path { ref path } + | clean::BorrowedRef { type_: box clean::Type::Path { ref path }, .. } => { dids.insert(path.def_id()); } clean::DynTrait(ref bounds, _) diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index d3603d17925..34742fac0e4 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -607,8 +607,7 @@ crate fn href_relative_parts<'a>(fqp: &'a [String], relative_to_fqp: &'a [String } } -/// Used when rendering a `ResolvedPath` structure. This invokes the `path` -/// rendering function with the necessary arguments for linking to a local path. +/// Used to render a [`clean::Path`]. fn resolved_path<'cx>( w: &mut fmt::Formatter<'_>, did: DefId, @@ -762,7 +761,7 @@ fn fmt_type<'cx>( match *t { clean::Generic(name) => write!(f, "{}", name), - clean::Type::ResolvedPath { ref path } => { + clean::Type::Path { ref path } => { // Paths like `T::Output` and `Self::Output` should be rendered with all segments. let did = path.def_id(); resolved_path(f, did, path, path.is_assoc_ty(), use_absolute, cx) diff --git a/src/librustdoc/html/render/cache.rs b/src/librustdoc/html/render/cache.rs index ffa5ec8a3ee..d12667c9e5c 100644 --- a/src/librustdoc/html/render/cache.rs +++ b/src/librustdoc/html/render/cache.rs @@ -218,7 +218,7 @@ fn get_index_type(clean_type: &clean::Type, generics: Vec) -> Rend fn get_index_type_name(clean_type: &clean::Type, accept_generic: bool) -> Option { match *clean_type { - clean::Type::ResolvedPath { ref path, .. } => { + clean::Type::Path { ref path, .. } => { let path_segment = path.segments.last().unwrap(); Some(path_segment.name) } @@ -371,7 +371,7 @@ crate fn get_real_types<'tcx>( let mut ty_generics = Vec::new(); for bound in bound.get_bounds().unwrap_or(&[]) { if let Some(path) = bound.get_trait_path() { - let ty = Type::ResolvedPath { path }; + let ty = Type::Path { path }; get_real_types(generics, &ty, tcx, recurse + 1, &mut ty_generics, cache); } } diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 42a2defa757..20a200f0484 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -1227,7 +1227,7 @@ fn should_render_item(item: &clean::Item, deref_mut_: bool, tcx: TyCtxt<'_>) -> | SelfTy::SelfExplicit(clean::BorrowedRef { mutability, .. }) => { (mutability == Mutability::Mut, false, false) } - SelfTy::SelfExplicit(clean::Type::ResolvedPath { path }) => { + SelfTy::SelfExplicit(clean::Type::Path { path }) => { (false, Some(path.def_id()) == tcx.lang_items().owned_box(), false) } SelfTy::SelfValue => (false, false, true), @@ -2520,7 +2520,7 @@ fn collect_paths_for_type(first_ty: clean::Type, cache: &Cache) -> Vec { } match ty { - clean::Type::ResolvedPath { path } => process_path(path.def_id()), + clean::Type::Path { path } => process_path(path.def_id()), clean::Type::Tuple(tys) => { work.extend(tys.into_iter()); } diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index f8a16fb9b71..d3738cfa3e7 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -727,10 +727,10 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra let mut implementor_dups: FxHashMap = FxHashMap::default(); for implementor in implementors { match implementor.inner_impl().for_ { - clean::Type::ResolvedPath { ref path } - | clean::BorrowedRef { - type_: box clean::Type::ResolvedPath { ref path }, .. - } if !path.is_assoc_ty() => { + clean::Type::Path { ref path } + | clean::BorrowedRef { type_: box clean::Type::Path { ref path }, .. } + if !path.is_assoc_ty() => + { let did = path.def_id(); let &mut (prev_did, ref mut has_duplicates) = implementor_dups.entry(path.last()).or_insert((did, false)); @@ -1452,14 +1452,15 @@ fn render_implementor( ) { // If there's already another implementor that has the same abridged name, use the // full path, for example in `std::iter::ExactSizeIterator` - let use_absolute = - match implementor.inner_impl().for_ { - clean::Type::ResolvedPath { ref path, .. } - | clean::BorrowedRef { - type_: box clean::Type::ResolvedPath { ref path, .. }, .. - } if !path.is_assoc_ty() => implementor_dups[&path.last()].1, - _ => false, - }; + let use_absolute = match implementor.inner_impl().for_ { + clean::Type::Path { ref path, .. } + | clean::BorrowedRef { type_: box clean::Type::Path { ref path, .. }, .. } + if !path.is_assoc_ty() => + { + implementor_dups[&path.last()].1 + } + _ => false, + }; render_impl( w, cx, diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index ed8f7274591..7fc295747f4 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -365,7 +365,7 @@ impl FromWithTcx for GenericBound { match bound { TraitBound(clean::PolyTrait { trait_, generic_params }, modifier) => { // FIXME: should `trait_` be a clean::Path equivalent in JSON? - let trait_ = clean::Type::ResolvedPath { path: trait_ }.into_tcx(tcx); + let trait_ = clean::Type::Path { path: trait_ }.into_tcx(tcx); GenericBound::TraitBound { trait_, generic_params: generic_params.into_iter().map(|x| x.into_tcx(tcx)).collect(), @@ -394,7 +394,7 @@ impl FromWithTcx for Type { }; match ty { - clean::Type::ResolvedPath { path } => Type::ResolvedPath { + clean::Type::Path { path } => Type::ResolvedPath { name: path.whole_name(), id: from_item_id(path.def_id().into()), args: path.segments.last().map(|args| Box::new(args.clone().args.into_tcx(tcx))), @@ -439,7 +439,7 @@ impl FromWithTcx for Type { }, QPath { name, self_type, trait_, .. } => { // FIXME: should `trait_` be a clean::Path equivalent in JSON? - let trait_ = clean::Type::ResolvedPath { path: trait_ }.into_tcx(tcx); + let trait_ = clean::Type::Path { path: trait_ }.into_tcx(tcx); Type::QualifiedPath { name: name.to_string(), self_type: Box::new((*self_type).into_tcx(tcx)), @@ -505,7 +505,7 @@ impl FromWithTcx for Impl { let provided_trait_methods = impl_.provided_trait_methods(tcx); let clean::Impl { unsafety, generics, trait_, for_, items, polarity, kind } = impl_; // FIXME: should `trait_` be a clean::Path equivalent in JSON? - let trait_ = trait_.map(|path| clean::Type::ResolvedPath { path }.into_tcx(tcx)); + let trait_ = trait_.map(|path| clean::Type::Path { path }.into_tcx(tcx)); // FIXME: use something like ImplKind in JSON? let (synthetic, blanket_impl) = match kind { clean::ImplKind::Normal => (false, None),