mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
In case a foreign item has doc(hidden)
attribute, we simply merged its attributes
with the re-export's, making it being removed once in the `strip_hidden` pass. The solution was to use the same as for local reexported items: merge attributes, but not some of them (like `doc(hidden)`).
This commit is contained in:
parent
20ed9712a7
commit
0ee34e1914
@ -63,8 +63,6 @@ pub(crate) fn try_inline(
|
|||||||
|
|
||||||
let import_def_id = attrs.and_then(|(_, def_id)| def_id);
|
let import_def_id = attrs.and_then(|(_, def_id)| def_id);
|
||||||
|
|
||||||
let (attrs, cfg) = merge_attrs(cx, load_attrs(cx, did), attrs);
|
|
||||||
|
|
||||||
let kind = match res {
|
let kind = match res {
|
||||||
Res::Def(DefKind::Trait, did) => {
|
Res::Def(DefKind::Trait, did) => {
|
||||||
record_extern_fqn(cx, did, ItemType::Trait);
|
record_extern_fqn(cx, did, ItemType::Trait);
|
||||||
@ -134,7 +132,11 @@ pub(crate) fn try_inline(
|
|||||||
cx.with_param_env(did, |cx| clean::ConstantItem(build_const(cx, did)))
|
cx.with_param_env(did, |cx| clean::ConstantItem(build_const(cx, did)))
|
||||||
}
|
}
|
||||||
Res::Def(DefKind::Macro(kind), did) => {
|
Res::Def(DefKind::Macro(kind), did) => {
|
||||||
let mac = build_macro(cx, did, name, import_def_id, kind, attrs.is_doc_hidden());
|
let is_doc_hidden = cx.tcx.is_doc_hidden(did)
|
||||||
|
|| attrs_without_docs
|
||||||
|
.map(|(attrs, _)| attrs)
|
||||||
|
.is_some_and(|attrs| utils::attrs_have_doc_flag(attrs.iter(), sym::hidden));
|
||||||
|
let mac = build_macro(cx, did, name, import_def_id, kind, is_doc_hidden);
|
||||||
|
|
||||||
let type_kind = match kind {
|
let type_kind = match kind {
|
||||||
MacroKind::Bang => ItemType::Macro,
|
MacroKind::Bang => ItemType::Macro,
|
||||||
@ -148,8 +150,14 @@ pub(crate) fn try_inline(
|
|||||||
};
|
};
|
||||||
|
|
||||||
cx.inlined.insert(did.into());
|
cx.inlined.insert(did.into());
|
||||||
let mut item =
|
let mut item = crate::clean::generate_item_with_correct_attrs(
|
||||||
clean::Item::from_def_id_and_attrs_and_parts(did, Some(name), kind, Box::new(attrs), cfg);
|
cx,
|
||||||
|
kind,
|
||||||
|
did,
|
||||||
|
name,
|
||||||
|
import_def_id.and_then(|def_id| def_id.as_local()),
|
||||||
|
None,
|
||||||
|
);
|
||||||
// The visibility needs to reflect the one from the reexport and not from the "source" DefId.
|
// The visibility needs to reflect the one from the reexport and not from the "source" DefId.
|
||||||
item.inline_stmt_id = import_def_id;
|
item.inline_stmt_id = import_def_id;
|
||||||
ret.push(item);
|
ret.push(item);
|
||||||
@ -179,6 +187,7 @@ pub(crate) fn try_inline_glob(
|
|||||||
.iter()
|
.iter()
|
||||||
.filter(|child| !child.reexport_chain.is_empty())
|
.filter(|child| !child.reexport_chain.is_empty())
|
||||||
.filter_map(|child| child.res.opt_def_id())
|
.filter_map(|child| child.res.opt_def_id())
|
||||||
|
.filter(|def_id| !cx.tcx.is_doc_hidden(def_id))
|
||||||
.collect();
|
.collect();
|
||||||
let attrs = cx.tcx.hir().attrs(import.hir_id());
|
let attrs = cx.tcx.hir().attrs(import.hir_id());
|
||||||
let mut items = build_module_items(
|
let mut items = build_module_items(
|
||||||
|
@ -581,7 +581,14 @@ pub(crate) fn find_nearest_parent_module(tcx: TyCtxt<'_>, def_id: DefId) -> Opti
|
|||||||
/// 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.
|
||||||
pub(crate) fn has_doc_flag(tcx: TyCtxt<'_>, did: DefId, flag: Symbol) -> bool {
|
pub(crate) fn has_doc_flag(tcx: TyCtxt<'_>, did: DefId, flag: Symbol) -> bool {
|
||||||
tcx.get_attrs(did, sym::doc)
|
attrs_have_doc_flag(tcx.get_attrs(did, sym::doc), flag)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn attrs_have_doc_flag<'a>(
|
||||||
|
mut attrs: impl Iterator<Item = &'a ast::Attribute>,
|
||||||
|
flag: Symbol,
|
||||||
|
) -> bool {
|
||||||
|
attrs
|
||||||
.any(|attr| attr.meta_item_list().is_some_and(|l| rustc_attr::list_contains_name(&l, flag)))
|
.any(|attr| attr.meta_item_list().is_some_and(|l| rustc_attr::list_contains_name(&l, flag)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user