]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #47959 - Manishearth:rustdoc-ice, r=Mark-Simulacrum
authorkennytm <kennytm@gmail.com>
Mon, 5 Feb 2018 18:13:52 +0000 (02:13 +0800)
committerGitHub <noreply@github.com>
Mon, 5 Feb 2018 18:13:52 +0000 (02:13 +0800)
Fix rustdoc ICE on macros defined within functions

fixes #47639

1  2 
src/librustc/lint/context.rs

index 929d5e7ec62bb055274509b9618daf70727fec9d,2efb9f2dc9cae04a7aafd133d194a8949f9ac24a..ed937046e5ed747b6ece8e486bcfbc250e79140e
@@@ -631,7 -631,7 +631,7 @@@ impl<'a, 'tcx> LayoutOf<Ty<'tcx>> for &
      type TyLayout = Result<TyLayout<'tcx>, LayoutError<'tcx>>;
  
      fn layout_of(self, ty: Ty<'tcx>) -> Self::TyLayout {
 -        (self.tcx, self.param_env.reveal_all()).layout_of(ty)
 +        self.tcx.layout_of(self.param_env.and(ty))
      }
  }
  
@@@ -1042,11 -1042,20 +1042,20 @@@ pub fn check_ast_crate(sess: &Session, 
      // 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");
+             }
          }
      }
  }