Skip to content

Commit d8c9a28

Browse files
committed
Fix the tests
1 parent 3a62eb7 commit d8c9a28

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

compiler/rustc_metadata/src/creader.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,16 @@ impl CStore {
195195
}
196196

197197
pub fn report_unused_deps(&self, tcx: TyCtxt<'_>) {
198+
// We put the check for the option before the lint_level_at_node call
199+
// because the call mutates internal state and introducing it
200+
// leads to some ui tests failing.
201+
if !tcx.sess.opts.json_unused_externs {
202+
return;
203+
}
198204
let level = tcx
199205
.lint_level_at_node(lint::builtin::UNUSED_CRATE_DEPENDENCIES, rustc_hir::CRATE_HIR_ID)
200206
.0;
201-
if level != lint::Level::Allow && tcx.sess.opts.json_unused_externs {
207+
if level != lint::Level::Allow {
202208
let unused_externs =
203209
self.unused_externs.iter().map(|ident| ident.to_ident_string()).collect::<Vec<_>>();
204210
let unused_externs = unused_externs.iter().map(String::as_str).collect::<Vec<&str>>();

0 commit comments

Comments
 (0)