未验证 提交 daecd152 编写于 作者: K kennytm 提交者: GitHub

Rollup merge of #47959 - Manishearth:rustdoc-ice, r=Mark-Simulacrum

Fix rustdoc ICE on macros defined within functions

fixes #47639
......@@ -1042,13 +1042,22 @@ 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.
// 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");
}
}
}
}
impl Encodable for LintId {
......
// 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 {
() => ()
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册