Skip to content

Commit

Permalink
Rollup merge of rust-lang#96630 - m-ysk:fix/issue-88038, r=notriddle
Browse files Browse the repository at this point in the history
Include nonexported macro_rules! macros in the doctest target

Fixes rust-lang#88038

This PR aims to include nonexported `macro_rules!` macros in the doctest target. For more details, please see the above issue.
  • Loading branch information
JohnTitor authored May 3, 2022
2 parents 90749fc + 4698a3f commit 5c2d31c
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 12 deletions.
2 changes: 1 addition & 1 deletion library/core/src/internal_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ macro_rules! impl_fn_for_zst {
///
/// # Example
///
/// ```
/// ```ignore(cannot-test-this-because-non-exported-macro)
/// cfg_if! {
/// if #[cfg(unix)] {
/// fn foo() { /* unix specific functionality */ }
Expand Down
10 changes: 0 additions & 10 deletions src/librustdoc/doctest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1225,16 +1225,6 @@ impl<'a, 'hir, 'tcx> intravisit::Visitor<'hir> for HirCollector<'a, 'hir, 'tcx>

fn visit_item(&mut self, item: &'hir hir::Item<'_>) {
let name = match &item.kind {
hir::ItemKind::Macro(ref macro_def, _) => {
// FIXME(#88038): Non exported macros have historically not been tested,
// but we really ought to start testing them.
let def_id = item.def_id.to_def_id();
if macro_def.macro_rules && !self.tcx.has_attr(def_id, sym::macro_export) {
intravisit::walk_item(self, item);
return;
}
item.ident.to_string()
}
hir::ItemKind::Impl(impl_) => {
rustc_hir_pretty::id_to_string(&self.map, impl_.self_ty.hir_id)
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ use crate::passes::collect_intra_doc_links;
///
/// Example:
///
/// ```
/// ```ignore(cannot-test-this-because-non-exported-macro)
/// let letters = map!{"a" => "b", "c" => "d"};
/// ```
///
Expand Down

0 comments on commit 5c2d31c

Please sign in to comment.