diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-04-11 20:20:49 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-11 20:20:49 +0200 |
| commit | bcdc281e5c0429450dc6122930bbde3753491f3f (patch) | |
| tree | 1b4fb9abf2f4e760ee98532295a6c7533676a507 /src/librustdoc/clean/utils.rs | |
| parent | df7daa815f4047a1cfe24ecfbc12cfd4f40fa928 (diff) | |
| parent | 5a0be6ff3dcc89a14e22c8613c86acbb0cd55b4a (diff) | |
| download | rust-bcdc281e5c0429450dc6122930bbde3753491f3f.tar.gz rust-bcdc281e5c0429450dc6122930bbde3753491f3f.zip | |
Rollup merge of #123459 - GuillaumeGomez:fix-123435, r=notriddle
Correctly handle inlining of doc hidden foreign items Fixes #123435. 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)`). I originally checked if we could simply update `Item::is_doc_hidden` method to use `self.inline_stmt_id.is_some_and(|def_id| tcx.is_doc_hidden(def_id))` but unfortunately, it added (local) items that shouldn't be inlined. At least it unifies local and foreign items inlining, which I think is the best course of action here. r? `@notriddle`
Diffstat (limited to 'src/librustdoc/clean/utils.rs')
| -rw-r--r-- | src/librustdoc/clean/utils.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index dc62fbb5edb..aa923cc6117 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -580,7 +580,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 /// `clean::Attributes` method. 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))) } |
