diff options
Diffstat (limited to 'src/librustdoc/clean/utils.rs')
| -rw-r--r-- | src/librustdoc/clean/utils.rs | 45 |
1 files changed, 13 insertions, 32 deletions
diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index 22917fbceb4..1b22d26f49b 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -1,15 +1,14 @@ use crate::clean::auto_trait::AutoTraitFinder; use crate::clean::blanket_impl::BlanketImplFinder; use crate::clean::{ - inline, Clean, Crate, Deprecation, ExternalCrate, FnDecl, FnRetTy, Generic, GenericArg, - GenericArgs, GenericBound, Generics, GetDefId, ImportSource, Item, ItemKind, Lifetime, - MacroKind, Path, PathSegment, Primitive, PrimitiveType, ResolvedPath, Span, Type, TypeBinding, - TypeKind, Visibility, WherePredicate, + inline, Clean, Crate, ExternalCrate, FnDecl, FnRetTy, Generic, GenericArg, GenericArgs, + GenericBound, Generics, GetDefId, ImportSource, Item, ItemKind, Lifetime, MacroKind, Path, + PathSegment, Primitive, PrimitiveType, ResolvedPath, Type, TypeBinding, TypeKind, + WherePredicate, }; use crate::core::DocContext; use itertools::Itertools; -use rustc_attr::Stability; use rustc_data_structures::fx::FxHashSet; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; @@ -66,25 +65,16 @@ crate fn krate(mut cx: &mut DocContext<'_>) -> Crate { ItemKind::ModuleItem(ref mut m) => m, _ => unreachable!(), }; - m.items.extend(primitives.iter().map(|&(def_id, prim, ref attrs)| Item { - source: Span::empty(), - name: Some(prim.to_url_str().to_string()), - attrs: attrs.clone(), - visibility: Visibility::Public, - stability: get_stability(cx, def_id), - deprecation: get_deprecation(cx, def_id), - def_id, - kind: ItemKind::PrimitiveItem(prim), + m.items.extend(primitives.iter().map(|&(def_id, prim)| { + Item::from_def_id_and_parts( + def_id, + Some(prim.to_url_str().to_owned()), + ItemKind::PrimitiveItem(prim), + cx, + ) })); - m.items.extend(keywords.into_iter().map(|(def_id, kw, attrs)| Item { - source: Span::empty(), - name: Some(kw.clone()), - attrs, - visibility: Visibility::Public, - stability: get_stability(cx, def_id), - deprecation: get_deprecation(cx, def_id), - def_id, - kind: ItemKind::KeywordItem(kw), + m.items.extend(keywords.into_iter().map(|(def_id, kw)| { + Item::from_def_id_and_parts(def_id, Some(kw.clone()), ItemKind::KeywordItem(kw), cx) })); } @@ -101,15 +91,6 @@ crate fn krate(mut cx: &mut DocContext<'_>) -> Crate { } } -// extract the stability index for a node from tcx, if possible -crate fn get_stability(cx: &DocContext<'_>, def_id: DefId) -> Option<Stability> { - cx.tcx.lookup_stability(def_id).cloned() -} - -crate fn get_deprecation(cx: &DocContext<'_>, def_id: DefId) -> Option<Deprecation> { - cx.tcx.lookup_deprecation(def_id).clean(cx) -} - fn external_generic_args( cx: &DocContext<'_>, trait_did: Option<DefId>, |
