]> git.lizzy.rs Git - rust.git/commitdiff
Stop re-exporting `Type::ResolvedPath`
authorNoah Lev <camelidcamel@gmail.com>
Wed, 24 Nov 2021 20:27:37 +0000 (12:27 -0800)
committerNoah Lev <camelidcamel@gmail.com>
Thu, 25 Nov 2021 20:08:05 +0000 (12:08 -0800)
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
src/librustdoc/clean/types.rs
src/librustdoc/clean/utils.rs
src/librustdoc/formats/cache.rs
src/librustdoc/html/format.rs
src/librustdoc/html/render/cache.rs
src/librustdoc/html/render/mod.rs
src/librustdoc/html/render/print_item.rs
src/librustdoc/json/conversions.rs

index 10648d74e930a75c21250ec270a944e94b210bb8..e8c55d10901e8e7a6660b6ac722f5ecde9731ceb 100644 (file)
@@ -41,9 +41,8 @@
 
 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<T> {
     fn clean(&self, cx: &mut DocContext<'_>) -> T;
@@ -1406,12 +1405,12 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Type {
                 };
                 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
index 7704e66bd394dea15a370a0f2a3b2be2105053e7..b5192d2c08257f09b44e9e952aac1ed4c2f890bb 100644 (file)
@@ -47,7 +47,7 @@
 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<Vec<&Type>> {
         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<DefId> {
         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,
index 1141aff41f2da46abecfcf02e03216272dfc20ef..40fa5b8a33e1b755892204801b527558d4ec20af 100644 (file)
@@ -2,8 +2,7 @@
 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 @@ pub(super) fn external_path(
             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 @@ fn print_const_with_custom_print_scalar(tcx: TyCtxt<'_>, ct: &'tcx ty::Const<'tc
         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 }
         }
     }
 }
index dd13c4809bbce94bc511c4af9144f01f71f25b01..06fcdd0521287f0967a7d8cd053fe99d3e7f6b3a 100644 (file)
@@ -401,7 +401,7 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
             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 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
             // 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, _)
index 1ed3ba7ece05638b5fb26f972843df3f5f08fdc3..d3603d17925da35e5a12e41612aa829c7c2a5d67 100644 (file)
@@ -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)
index c114edf1e704c17564127dcb0f9d9a697a606d79..ffa5ec8a3ee320a8945f151437b3d237bb891817 100644 (file)
@@ -218,7 +218,7 @@ fn get_index_type(clean_type: &clean::Type, generics: Vec<TypeWithKind>) -> Rend
 
 fn get_index_type_name(clean_type: &clean::Type, accept_generic: bool) -> Option<Symbol> {
     match *clean_type {
-        clean::ResolvedPath { ref path, .. } => {
+        clean::Type::ResolvedPath { ref path, .. } => {
             let path_segment = path.segments.last().unwrap();
             Some(path_segment.name)
         }
index 7d231a0d64922ea87003b88767087c66d2fdcfd3..42a2defa757a456f4447179073a4115300bcc798 100644 (file)
@@ -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),
index e59b94f6b7d3d09bcf351a92b2253a342e226573..f8a16fb9b713d0af1d345b78179dea9b0a30e453 100644 (file)
@@ -727,10 +727,10 @@ fn trait_item(w: &mut Buffer, cx: &Context<'_>, m: &clean::Item, t: &clean::Item
         let mut implementor_dups: FxHashMap<Symbol, (DefId, bool)> = 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,
index a5c1eb1241096212722d02ca7fcdc8d591039366..ed8f7274591d6faf5b712395da4065d17039c29d 100644 (file)
@@ -365,7 +365,7 @@ fn from_tcx(bound: clean::GenericBound, tcx: TyCtxt<'_>) -> Self {
         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 @@ fn from_tcx(bound: clean::GenericBound, tcx: TyCtxt<'_>) -> Self {
 
 impl FromWithTcx<clean::Type> 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 @@ fn from_tcx(ty: clean::Type, tcx: TyCtxt<'_>) -> Self {
             },
             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 @@ fn from_tcx(impl_: clean::Impl, tcx: TyCtxt<'_>) -> Self {
         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),