Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/librustdoc/html/macro_expansion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use rustc_ast::visit::{
AssocCtxt, Visitor, walk_assoc_item, walk_crate, walk_expr, walk_item, walk_pat, walk_stmt,
walk_ty,
};
use rustc_ast::{AssocItem, Crate, Expr, Item, Pat, Stmt, Ty};
use rustc_ast::{AssocItem, Crate, Expr, ForeignItem, Item, Pat, Stmt, Ty};
use rustc_data_structures::fx::FxHashMap;
use rustc_span::source_map::SourceMap;
use rustc_span::{BytePos, Span};
Expand Down Expand Up @@ -174,4 +174,14 @@ impl<'ast> Visitor<'ast> for ExpandedCodeVisitor<'ast> {
walk_assoc_item(self, item, ctxt);
}
}

fn visit_foreign_item(&mut self, item: &'ast ForeignItem) -> Self::Result {
if item.span.from_expansion() {
self.handle_new_span(item.span, || {
rustc_ast_pretty::pprust::foreign_item_to_string(item)
});
} else {
walk_item(self, item);
}
}
}
19 changes: 19 additions & 0 deletions tests/rustdoc-html/macro-expansion/c-var-args.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Ensure that C var args (`va_list`) work.
// Regression test for <https://github.com/rust-lang/rust/issues/156486>.

//@ compile-flags: -Zunstable-options --generate-macro-expansion

#![crate_name = "foo"]

//@ has 'src/foo/c-var-args.rs.html'

macro_rules! print {
() => {
fn printf(...);
};
}

//@ has - '//*[@class="expansion"]/*[@class="expanded"]' 'fn printf(...);'
extern "C" {
print! {}
}
Loading