From d8c9a287036f72bf078f868f8fe635b7a7fde32c Mon Sep 17 00:00:00 2001 From: est31 Date: Wed, 12 Aug 2020 03:45:16 +0200 Subject: [PATCH] Fix the tests --- compiler/rustc_metadata/src/creader.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_metadata/src/creader.rs b/compiler/rustc_metadata/src/creader.rs index 9e3f121378c..5634467eeb7 100644 --- a/compiler/rustc_metadata/src/creader.rs +++ b/compiler/rustc_metadata/src/creader.rs @@ -195,10 +195,16 @@ fn crate_dependencies_in_reverse_postorder(&self, cnum: CrateNum) -> Vec) { + // We put the check for the option before the lint_level_at_node call + // because the call mutates internal state and introducing it + // leads to some ui tests failing. + if !tcx.sess.opts.json_unused_externs { + return; + } let level = tcx .lint_level_at_node(lint::builtin::UNUSED_CRATE_DEPENDENCIES, rustc_hir::CRATE_HIR_ID) .0; - if level != lint::Level::Allow && tcx.sess.opts.json_unused_externs { + if level != lint::Level::Allow { let unused_externs = self.unused_externs.iter().map(|ident| ident.to_ident_string()).collect::>(); let unused_externs = unused_externs.iter().map(String::as_str).collect::>(); -- 2.44.0