diff options
| author | bors <bors@rust-lang.org> | 2025-08-13 19:23:12 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-08-13 19:23:12 +0000 |
| commit | 3672a55b7cfd0a12e7097197b6242872473ffaa7 (patch) | |
| tree | 3e7a90f0636c0a4646eeee7514d2708b6bd69938 /src/librustdoc/clean/inline.rs | |
| parent | f5b8a11fecf23cb669f6d1feae81aafc2930aeb9 (diff) | |
| parent | bb46a20df47aff847b728177a6432285d30c6922 (diff) | |
| download | rust-3672a55b7cfd0a12e7097197b6242872473ffaa7.tar.gz rust-3672a55b7cfd0a12e7097197b6242872473ffaa7.zip | |
Auto merge of #145366 - GuillaumeGomez:rollup-v0a6v3u, r=GuillaumeGomez
Rollup of 9 pull requests Successful merges: - rust-lang/rust#144761 (aarch64: Make `outline-atomics` a known target feature) - rust-lang/rust#144949 (More `Printer` cleanups) - rust-lang/rust#144955 (search graph: lazily update parent goals) - rust-lang/rust#144962 (Add aarch64_be-unknown-none-softfloat target) - rust-lang/rust#145153 (Handle macros with multiple kinds, and improve errors) - rust-lang/rust#145241 ([AVR] Changed data_layout) - rust-lang/rust#145341 (Install libgccjit into the compiler's sysroot when cg_gcc is enabled) - rust-lang/rust#145349 (Correctly handle when there are no unstable items in the documented crate) - rust-lang/rust#145356 (Add another example for escaped `#` character in doctest in rustdoc book) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src/librustdoc/clean/inline.rs')
| -rw-r--r-- | src/librustdoc/clean/inline.rs | 53 |
1 files changed, 35 insertions, 18 deletions
diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 8c0f897c992..0d98c64bbde 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -6,7 +6,7 @@ use std::sync::Arc; use rustc_data_structures::fx::FxHashSet; use rustc_hir as hir; use rustc_hir::Mutability; -use rustc_hir::def::{DefKind, Res}; +use rustc_hir::def::{DefKind, MacroKinds, Res}; use rustc_hir::def_id::{DefId, DefIdSet, LocalDefId, LocalModDefId}; use rustc_metadata::creader::{CStore, LoadedMacro}; use rustc_middle::ty::fast_reject::SimplifiedType; @@ -137,13 +137,16 @@ pub(crate) fn try_inline( clean::ConstantItem(Box::new(ct)) }) } - Res::Def(DefKind::Macro(kind), did) => { - let mac = build_macro(cx, did, name, kind); - - let type_kind = match kind { - MacroKind::Bang => ItemType::Macro, - MacroKind::Attr => ItemType::ProcAttribute, - MacroKind::Derive => ItemType::ProcDerive, + Res::Def(DefKind::Macro(kinds), did) => { + let mac = build_macro(cx, did, name, kinds); + + // FIXME: handle attributes and derives that aren't proc macros, and macros with + // multiple kinds + let type_kind = match kinds { + MacroKinds::BANG => ItemType::Macro, + MacroKinds::ATTR => ItemType::ProcAttribute, + MacroKinds::DERIVE => ItemType::ProcDerive, + _ => todo!("Handle macros with multiple kinds"), }; record_extern_fqn(cx, did, type_kind); mac @@ -749,22 +752,36 @@ fn build_macro( cx: &mut DocContext<'_>, def_id: DefId, name: Symbol, - macro_kind: MacroKind, + macro_kinds: MacroKinds, ) -> clean::ItemKind { match CStore::from_tcx(cx.tcx).load_macro_untracked(def_id, cx.tcx) { - LoadedMacro::MacroDef { def, .. } => match macro_kind { - MacroKind::Bang => clean::MacroItem(clean::Macro { + // FIXME: handle attributes and derives that aren't proc macros, and macros with multiple + // kinds + LoadedMacro::MacroDef { def, .. } => match macro_kinds { + MacroKinds::BANG => clean::MacroItem(clean::Macro { source: utils::display_macro_source(cx, name, &def), macro_rules: def.macro_rules, }), - MacroKind::Derive | MacroKind::Attr => { - clean::ProcMacroItem(clean::ProcMacro { kind: macro_kind, helpers: Vec::new() }) - } + MacroKinds::DERIVE => clean::ProcMacroItem(clean::ProcMacro { + kind: MacroKind::Derive, + helpers: Vec::new(), + }), + MacroKinds::ATTR => clean::ProcMacroItem(clean::ProcMacro { + kind: MacroKind::Attr, + helpers: Vec::new(), + }), + _ => todo!("Handle macros with multiple kinds"), }, - LoadedMacro::ProcMacro(ext) => clean::ProcMacroItem(clean::ProcMacro { - kind: ext.macro_kind(), - helpers: ext.helper_attrs, - }), + LoadedMacro::ProcMacro(ext) => { + // Proc macros can only have a single kind + let kind = match ext.macro_kinds() { + MacroKinds::BANG => MacroKind::Bang, + MacroKinds::ATTR => MacroKind::Attr, + MacroKinds::DERIVE => MacroKind::Derive, + _ => unreachable!(), + }; + clean::ProcMacroItem(clean::ProcMacro { kind, helpers: ext.helper_attrs }) + } } } |
