Skip to content

Commit 04309be

Browse files
committed
Fix rustdoc ICE on macros defined within functions
fixes #47639
1 parent ed9751a commit 04309be

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/librustc/lint/context.rs

+14-5
Original file line numberDiff line numberDiff line change
@@ -1042,11 +1042,20 @@ pub fn check_ast_crate(sess: &Session, krate: &ast::Crate) {
10421042
// Put the lint store levels and passes back in the session.
10431043
cx.lint_sess.restore(&sess.lint_store);
10441044

1045-
// Emit all buffered lints from early on in the session now that we've
1046-
// calculated the lint levels for all AST nodes.
1047-
for (_id, lints) in cx.buffered.map {
1048-
for early_lint in lints {
1049-
span_bug!(early_lint.span, "failed to process bufferd lint here");
1045+
// All of the buffered lints should have been emitted at this point.
1046+
// If not, that means that we somehow buffered a lint for a node id
1047+
// that was not lint-checked (perhaps it doesn't exist?). This is a bug.
1048+
//
1049+
// Rustdoc runs everybody-loops before the early lints and removes
1050+
// function bodies, so it's totally possible for linted
1051+
// node ids to not exist (e.g. macros defined within functions for the
1052+
// unused_macro lint) anymore. So we only run this check
1053+
// when we're not in rustdoc mode. (see issue #47639)
1054+
if !sess.opts.actually_rustdoc {
1055+
for (_id, lints) in cx.buffered.map {
1056+
for early_lint in lints {
1057+
span_bug!(early_lint.span, "failed to process buffered lint here");
1058+
}
10501059
}
10511060
}
10521061
}

0 commit comments

Comments
 (0)