diff options
| -rw-r--r-- | library/std/src/prelude/v1.rs | 8 | ||||
| -rw-r--r-- | src/librustdoc/clean/inline.rs | 12 | ||||
| -rw-r--r-- | src/librustdoc/visit_ast.rs | 13 |
3 files changed, 21 insertions, 12 deletions
diff --git a/library/std/src/prelude/v1.rs b/library/std/src/prelude/v1.rs index 0fbd6b62f18..26302d0ecf2 100644 --- a/library/std/src/prelude/v1.rs +++ b/library/std/src/prelude/v1.rs @@ -41,17 +41,17 @@ pub use crate::result::Result::{self, Err, Ok}; pub use core::prelude::v1::{ asm, assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args, format_args_nl, global_asm, include, include_bytes, include_str, line, llvm_asm, log_syntax, - module_path, option_env, stringify, trace_macros, + module_path, option_env, stringify, trace_macros, Clone, Copy, Debug, Default, Eq, Hash, Ord, + PartialEq, PartialOrd, }; -// FIXME: Attribute and derive macros are not documented because for them rustdoc generates +// FIXME: Attribute and internal derive macros are not documented because for them rustdoc generates // dead links which fail link checker testing. #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] #[allow(deprecated)] #[doc(hidden)] pub use core::prelude::v1::{ - bench, global_allocator, test, test_case, Clone, Copy, Debug, Default, Eq, Hash, Ord, - PartialEq, PartialOrd, RustcDecodable, RustcEncodable, + bench, global_allocator, test, test_case, RustcDecodable, RustcEncodable, }; #[unstable( diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index ed972cc16e9..beb2c09fecc 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -169,7 +169,17 @@ crate fn record_extern_fqn(cx: &DocContext<'_>, did: DefId, kind: clean::TypeKin if !s.is_empty() { Some(s) } else { None } }); let fqn = if let clean::TypeKind::Macro = kind { - vec![crate_name, relative.last().expect("relative was empty")] + // Check to see if it is a macro 2.0 or built-in macro + if matches!( + cx.enter_resolver(|r| r.cstore().load_macro_untracked(did, cx.sess())), + LoadedMacro::MacroDef(def, _) + if matches!(&def.kind, ast::ItemKind::MacroDef(def) + if !def.macro_rules) + ) { + once(crate_name).chain(relative).collect() + } else { + vec![crate_name, relative.last().expect("relative was empty")] + } } else { once(crate_name).chain(relative).collect() }; diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index ebad35f4e55..1e78a014048 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -73,16 +73,15 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { // In the case of macros 2.0 (`pub macro`), and for built-in `derive`s or attributes as // well (_e.g._, `Copy`), these are wrongly bundled in there too, so we need to fix that by // moving them back to their correct locations. - krate.exported_macros.iter().for_each(|def| { - let visit_macro = || self.visit_local_macro(def, None); + 'exported_macros: for def in krate.exported_macros { // The `def` of a macro in `exported_macros` should correspond to either: // - a `#[macro-export] macro_rules!` macro, // - a built-in `derive` (or attribute) macro such as the ones in `::core`, // - a `pub macro`. // Only the last two need to be fixed, thus: if def.ast.macro_rules { - top_level_module.macros.push(visit_macro()); - return; + top_level_module.macros.push((def, None)); + continue 'exported_macros; } let tcx = self.cx.tcx; /* Because of #77828 we cannot do the simpler: @@ -104,7 +103,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { // `fn f() { pub macro m() {} }` // then the item is not accessible, and should thus act as if it didn't // exist (unless "associated macros" (inside an `impl`) were a thing…). - return; + continue 'exported_macros; } }; cur_mod = cur_mod @@ -113,8 +112,8 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { .find(|module| module.name == Some(path_segment_ty_ns)) .unwrap(); } - cur_mod.macros.push(visit_macro()); - }); + cur_mod.macros.push((def, None)); + } self.cx.renderinfo.get_mut().exact_paths = self.exact_paths; |
