From 4e74eb5ba0bbf60ab70a0680d1e07d7a0f59d383 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 30 Nov 2017 07:59:35 -0800 Subject: rustc: Filter out bogus extern crate warnings Rustdoc has for some time now used the "everybody loops" pass in the compiler to avoid typechecking and otherwise avoid looking at implementation details. In #46115 the placement of this pass was pushed back in the compiler to after macro expansion to ensure that it works with macro-expanded code as well. This in turn caused the regression in #46271. The bug here was that the resolver was producing `def_id` instances for "possibly unused extern crates" which would then later get processed during typeck to actually issue lint warnings. The problem was that *after* resolution these `def_id` nodes were actually removed from the AST by the "everybody loops" pass. This later, when we tried to take a look at `def_id`, caused the compiler to panic. The fix applied here is a bit of a heavy hammer which is to just, in this one case, ignore the `extern crate` lints if the `def_id` looks "bogus" in any way (basically if it looks like the node was removed after resolution). The real underlying bug here is probably that the "everybody loops" AST pass is being stressed to much beyond what it was originally intended to do, but this should at least fix the ICE for now... Closes #46271 --- src/test/rustdoc/issue-46271.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/test/rustdoc/issue-46271.rs (limited to 'src/test/rustdoc') diff --git a/src/test/rustdoc/issue-46271.rs b/src/test/rustdoc/issue-46271.rs new file mode 100644 index 00000000000..cc3be08c568 --- /dev/null +++ b/src/test/rustdoc/issue-46271.rs @@ -0,0 +1,15 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// hopefully this doesn't cause an ICE + +pub fn foo() { + extern crate std; +} -- cgit 1.4.1-3-g733a5