From: est31 Date: Wed, 12 Aug 2020 01:45:16 +0000 (+0200) Subject: Fix the tests X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=d8c9a287036f72bf078f868f8fe635b7a7fde32c;p=rust.git Fix the tests --- 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::>();