Skip to content

Commit

Permalink
Auto merge of rust-lang#47969 - Manishearth:ice-ice-beta, r=Mark-Simu…
Browse files Browse the repository at this point in the history
…lacrum

Backport rustdoc ICE fixes to beta

backport of rust-lang#47959
  • Loading branch information
bors committed Feb 3, 2018
2 parents 6a6b350 + c3cf9bc commit 03f456d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/librustc/lint/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 bufferd 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");
}
}
}
}
Expand Down
16 changes: 16 additions & 0 deletions src/test/rustdoc/issue-47639.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// This should not ICE
pub fn test() {
macro_rules! foo {
() => ()
}
}

0 comments on commit 03f456d

Please sign in to comment.