Skip to content

Commit 03f456d

Browse files
committed
Auto merge of #47969 - Manishearth:ice-ice-beta, r=Mark-Simulacrum
Backport rustdoc ICE fixes to beta backport of #47959
2 parents 6a6b350 + c3cf9bc commit 03f456d

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-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
}

src/test/rustdoc/issue-47639.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// This should not ICE
12+
pub fn test() {
13+
macro_rules! foo {
14+
() => ()
15+
}
16+
}

0 commit comments

Comments
 (0)