Skip to content

Commit 94064d4

Browse files
committed
Make lint level minimums parallel
1 parent bbffe00 commit 94064d4

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

compiler/rustc_lint/src/levels.rs

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_ast as ast;
1717
use rustc_ast_pretty::pprust;
1818
use rustc_data_structures::{
1919
fx::FxIndexMap,
20-
sync::{par_for_each_in, Lock, Lrc},
20+
sync::{join, par_for_each_in, Lock, Lrc},
2121
};
2222
use rustc_errors::{Diag, DiagMessage, LintDiagnostic, MultiSpan};
2323
use rustc_feature::{Features, GateIssue};
@@ -160,12 +160,9 @@ fn lint_expectations(tcx: TyCtxt<'_>, (): ()) -> Vec<(LintExpectationId, LintExp
160160
/// of 1. The lints that will emit (or at least, should run), and 2.
161161
/// The lints that are allowed at the crate level and will not emit.
162162
pub fn lints_that_can_emit(tcx: TyCtxt<'_>, (): ()) -> Lrc<(Vec<Symbol>, Vec<Symbol>)> {
163-
// builder.add_command_line();
164-
// builder.add_id(hir::CRATE_HIR_ID);
165-
166163
let mut visitor = LintLevelMinimum::new(tcx);
167164
visitor.process_opts();
168-
visitor.lint_level_minimums(tcx);
165+
visitor.lint_level_minimums();
169166

170167
Lrc::new((visitor.lints_to_emit.into_inner(), visitor.lints_allowed.into_inner()))
171168
}
@@ -503,17 +500,25 @@ impl<'tcx> LintLevelMinimum<'tcx> {
503500
}
504501
}
505502

506-
fn lint_level_minimums(&mut self, tcx: TyCtxt<'tcx>) {
507-
tcx.sess.psess.lints_that_can_emit.with_lock(|vec| {
508-
par_for_each_in(vec, |lint_symbol| {
509-
self.lints_to_emit.with_lock(|lints_to_emit| lints_to_emit.push(*lint_symbol));
510-
});
511-
});
512-
tcx.sess.psess.lints_allowed.with_lock(|vec| {
513-
par_for_each_in(vec, |lint_symbol| {
514-
self.lints_allowed.with_lock(|lints_allowed| lints_allowed.push(*lint_symbol));
515-
});
516-
});
503+
fn lint_level_minimums(&mut self) {
504+
join(
505+
|| {
506+
self.tcx.sess.psess.lints_that_can_emit.with_lock(|vec| {
507+
par_for_each_in(vec, |lint_symbol| {
508+
self.lints_to_emit
509+
.with_lock(|lints_to_emit| lints_to_emit.push(*lint_symbol));
510+
});
511+
});
512+
},
513+
|| {
514+
self.tcx.sess.psess.lints_allowed.with_lock(|vec| {
515+
par_for_each_in(vec, |lint_symbol| {
516+
self.lints_allowed
517+
.with_lock(|lints_allowed| lints_allowed.push(*lint_symbol));
518+
});
519+
});
520+
},
521+
);
517522
}
518523
}
519524

0 commit comments

Comments
 (0)