about summary refs log tree commit diff
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2018-02-02 12:09:25 +0530
committerManish Goregaokar <manishsmail@gmail.com>2018-02-02 12:13:12 +0530
commitc22d6e2fda06841dd77e9f92247fe9de575845a6 (patch)
treeb0c3b38d2ac944d8c370e03ab79fbd052f7473a3
parent6741e416feb54b18de41c348ecc70ba5cbc961ce (diff)
downloadrust-c22d6e2fda06841dd77e9f92247fe9de575845a6.tar.gz
rust-c22d6e2fda06841dd77e9f92247fe9de575845a6.zip
Fix rustdoc ICE on macros defined within functions
fixes #47639
-rw-r--r--src/librustc/lint/context.rs19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs
index 5336c1944e8..2efb9f2dc9c 100644
--- a/src/librustc/lint/context.rs
+++ b/src/librustc/lint/context.rs
@@ -1042,11 +1042,20 @@ pub fn check_ast_crate(sess: &Session, krate: &ast::Crate) {
     // Put the lint store levels and passes back in the session.
     cx.lint_sess.restore(&sess.lint_store);
 
-    // Emit all buffered lints from early on in the session now that we've
-    // calculated the lint levels for all AST nodes.
-    for (_id, lints) in cx.buffered.map {
-        for early_lint in lints {
-            span_bug!(early_lint.span, "failed to process buffered lint here");
+    // All of the buffered lints should have been emitted at this point.
+    // If not, that means that we somehow buffered a lint for a node id
+    // that was not lint-checked (perhaps it doesn't exist?). This is a bug.
+    //
+    // Rustdoc runs everybody-loops before the early lints and removes
+    // function bodies, so it's totally possible for linted
+    // node ids to not exist (e.g. macros defined within functions for the
+    // unused_macro lint) anymore. So we only run this check
+    // when we're not in rustdoc mode. (see issue #47639)
+    if !sess.opts.actually_rustdoc {
+        for (_id, lints) in cx.buffered.map {
+            for early_lint in lints {
+                span_bug!(early_lint.span, "failed to process buffered lint here");
+            }
         }
     }
 }