update rustdoc
This commit is contained in:
parent
6c8265dc56
commit
bae84a484c
5 changed files with 27 additions and 23 deletions
|
@ -22,7 +22,7 @@ use crate::clean::{
|
||||||
use crate::core::DocContext;
|
use crate::core::DocContext;
|
||||||
use crate::formats::item_type::ItemType;
|
use crate::formats::item_type::ItemType;
|
||||||
|
|
||||||
type Attrs<'hir> = rustc_middle::ty::Attributes<'hir>;
|
type Attrs<'hir> = &'hir [ast::Attribute];
|
||||||
|
|
||||||
/// Attempt to inline a definition into this AST.
|
/// Attempt to inline a definition into this AST.
|
||||||
///
|
///
|
||||||
|
@ -155,7 +155,7 @@ crate fn try_inline_glob(
|
||||||
}
|
}
|
||||||
|
|
||||||
crate fn load_attrs<'hir>(cx: &DocContext<'hir>, did: DefId) -> Attrs<'hir> {
|
crate fn load_attrs<'hir>(cx: &DocContext<'hir>, did: DefId) -> Attrs<'hir> {
|
||||||
cx.tcx.get_attrs(did)
|
cx.tcx.get_attrs_unchecked(did)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Record an external fully qualified name in the external_paths cache.
|
/// Record an external fully qualified name in the external_paths cache.
|
||||||
|
@ -691,7 +691,7 @@ crate fn record_extern_trait(cx: &mut DocContext<'_>, did: DefId) {
|
||||||
|
|
||||||
let trait_ = clean::TraitWithExtraInfo {
|
let trait_ = clean::TraitWithExtraInfo {
|
||||||
trait_,
|
trait_,
|
||||||
is_notable: clean::utils::has_doc_flag(cx.tcx.get_attrs(did), sym::notable_trait),
|
is_notable: clean::utils::has_doc_flag(cx.tcx, did, sym::notable_trait),
|
||||||
};
|
};
|
||||||
cx.external_traits.borrow_mut().insert(did, trait_);
|
cx.external_traits.borrow_mut().insert(did, trait_);
|
||||||
cx.active_extern_traits.remove(&did);
|
cx.active_extern_traits.remove(&did);
|
||||||
|
|
|
@ -211,8 +211,8 @@ impl ExternalCrate {
|
||||||
// Failing that, see if there's an attribute specifying where to find this
|
// Failing that, see if there's an attribute specifying where to find this
|
||||||
// external crate
|
// external crate
|
||||||
let did = self.crate_num.as_def_id();
|
let did = self.crate_num.as_def_id();
|
||||||
tcx.get_attrs(did)
|
tcx.get_attrs(did, sym::doc)
|
||||||
.lists(sym::doc)
|
.flat_map(|attr| attr.meta_item_list().unwrap_or_default())
|
||||||
.filter(|a| a.has_name(sym::html_root_url))
|
.filter(|a| a.has_name(sym::html_root_url))
|
||||||
.filter_map(|a| a.value_str())
|
.filter_map(|a| a.value_str())
|
||||||
.map(to_remote)
|
.map(to_remote)
|
||||||
|
@ -226,11 +226,13 @@ impl ExternalCrate {
|
||||||
|
|
||||||
let as_keyword = |res: Res<!>| {
|
let as_keyword = |res: Res<!>| {
|
||||||
if let Res::Def(DefKind::Mod, def_id) = res {
|
if let Res::Def(DefKind::Mod, def_id) = res {
|
||||||
let attrs = tcx.get_attrs(def_id);
|
|
||||||
let mut keyword = None;
|
let mut keyword = None;
|
||||||
for attr in attrs.lists(sym::doc) {
|
let meta_items = tcx
|
||||||
if attr.has_name(sym::keyword) {
|
.get_attrs(def_id, sym::doc)
|
||||||
if let Some(v) = attr.value_str() {
|
.flat_map(|attr| attr.meta_item_list().unwrap_or_default());
|
||||||
|
for meta in meta_items {
|
||||||
|
if meta.has_name(sym::keyword) {
|
||||||
|
if let Some(v) = meta.value_str() {
|
||||||
keyword = Some(v);
|
keyword = Some(v);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -288,11 +290,13 @@ impl ExternalCrate {
|
||||||
// rendering by delegating everything to a hash map.
|
// rendering by delegating everything to a hash map.
|
||||||
let as_primitive = |res: Res<!>| {
|
let as_primitive = |res: Res<!>| {
|
||||||
if let Res::Def(DefKind::Mod, def_id) = res {
|
if let Res::Def(DefKind::Mod, def_id) = res {
|
||||||
let attrs = tcx.get_attrs(def_id);
|
|
||||||
let mut prim = None;
|
let mut prim = None;
|
||||||
for attr in attrs.lists(sym::doc) {
|
let meta_items = tcx
|
||||||
if let Some(v) = attr.value_str() {
|
.get_attrs(def_id, sym::doc)
|
||||||
if attr.has_name(sym::primitive) {
|
.flat_map(|attr| attr.meta_item_list().unwrap_or_default());
|
||||||
|
for meta in meta_items {
|
||||||
|
if let Some(v) = meta.value_str() {
|
||||||
|
if meta.has_name(sym::primitive) {
|
||||||
prim = PrimitiveType::from_symbol(v);
|
prim = PrimitiveType::from_symbol(v);
|
||||||
if prim.is_some() {
|
if prim.is_some() {
|
||||||
break;
|
break;
|
||||||
|
@ -413,7 +417,10 @@ impl Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
crate fn inner_docs(&self, tcx: TyCtxt<'_>) -> bool {
|
crate fn inner_docs(&self, tcx: TyCtxt<'_>) -> bool {
|
||||||
self.item_id.as_def_id().map(|did| tcx.get_attrs(did).inner_docs()).unwrap_or(false)
|
self.item_id
|
||||||
|
.as_def_id()
|
||||||
|
.map(|did| tcx.get_attrs_unchecked(did).inner_docs())
|
||||||
|
.unwrap_or(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
crate fn span(&self, tcx: TyCtxt<'_>) -> Span {
|
crate fn span(&self, tcx: TyCtxt<'_>) -> Span {
|
||||||
|
@ -464,7 +471,7 @@ impl Item {
|
||||||
kind: ItemKind,
|
kind: ItemKind,
|
||||||
cx: &mut DocContext<'_>,
|
cx: &mut DocContext<'_>,
|
||||||
) -> Item {
|
) -> Item {
|
||||||
let ast_attrs = cx.tcx.get_attrs(def_id);
|
let ast_attrs = cx.tcx.get_attrs_unchecked(def_id);
|
||||||
|
|
||||||
Self::from_def_id_and_attrs_and_parts(
|
Self::from_def_id_and_attrs_and_parts(
|
||||||
def_id,
|
def_id,
|
||||||
|
|
|
@ -474,10 +474,9 @@ crate fn find_nearest_parent_module(tcx: TyCtxt<'_>, def_id: DefId) -> Option<De
|
||||||
///
|
///
|
||||||
/// This function exists because it runs on `hir::Attributes` whereas the other is a
|
/// This function exists because it runs on `hir::Attributes` whereas the other is a
|
||||||
/// `clean::Attributes` method.
|
/// `clean::Attributes` method.
|
||||||
crate fn has_doc_flag(attrs: ty::Attributes<'_>, flag: Symbol) -> bool {
|
crate fn has_doc_flag(tcx: TyCtxt<'_>, did: DefId, flag: Symbol) -> bool {
|
||||||
attrs.iter().any(|attr| {
|
tcx.get_attrs(did, sym::doc).any(|attr| {
|
||||||
attr.has_name(sym::doc)
|
attr.meta_item_list().map_or(false, |l| rustc_attr::list_contains_name(&l, flag))
|
||||||
&& attr.meta_item_list().map_or(false, |l| rustc_attr::list_contains_name(&l, flag))
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -323,7 +323,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
|
||||||
|
|
||||||
clean::ImportItem(ref import) => {
|
clean::ImportItem(ref import) => {
|
||||||
let (stab, stab_tags) = if let Some(import_def_id) = import.source.did {
|
let (stab, stab_tags) = if let Some(import_def_id) = import.source.did {
|
||||||
let ast_attrs = cx.tcx().get_attrs(import_def_id);
|
let ast_attrs = cx.tcx().get_attrs_unchecked(import_def_id);
|
||||||
let import_attrs = Box::new(clean::Attributes::from_ast(ast_attrs, None));
|
let import_attrs = Box::new(clean::Attributes::from_ast(ast_attrs, None));
|
||||||
|
|
||||||
// Just need an item with the correct def_id and attrs
|
// Just need an item with the correct def_id and attrs
|
||||||
|
|
|
@ -53,9 +53,7 @@ crate fn collect_trait_impls(mut krate: Crate, cx: &mut DocContext<'_>) -> Crate
|
||||||
while let Some(did) = parent {
|
while let Some(did) = parent {
|
||||||
attr_buf.extend(
|
attr_buf.extend(
|
||||||
cx.tcx
|
cx.tcx
|
||||||
.get_attrs(did)
|
.get_attrs(did, sym::doc)
|
||||||
.iter()
|
|
||||||
.filter(|attr| attr.has_name(sym::doc))
|
|
||||||
.filter(|attr| {
|
.filter(|attr| {
|
||||||
if let Some([attr]) = attr.meta_item_list().as_deref() {
|
if let Some([attr]) = attr.meta_item_list().as_deref() {
|
||||||
attr.has_name(sym::cfg)
|
attr.has_name(sym::cfg)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue