Skip to content

Commit e7d2d4c

Browse files
committed
lints_that_dont_need_to_run: never skip future-compat-reported lints
1 parent 46e8d20 commit e7d2d4c

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

compiler/rustc_lint/src/levels.rs

+12-10
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,19 @@ fn lints_that_dont_need_to_run(tcx: TyCtxt<'_>, (): ()) -> FxIndexSet<LintId> {
123123
let dont_need_to_run: FxIndexSet<LintId> = store
124124
.get_lints()
125125
.into_iter()
126+
.filter(|lint| {
127+
// Lints that show up in future-compat reports must always be run.
128+
let has_future_breakage =
129+
lint.future_incompatible.is_some_and(|fut| fut.reason.has_future_breakage());
130+
!has_future_breakage && !lint.eval_always
131+
})
126132
.filter_map(|lint| {
127-
if !lint.eval_always {
128-
let lint_level = map.lint_level_id_at_node(tcx, LintId::of(lint), CRATE_HIR_ID);
129-
if matches!(lint_level, (Level::Allow, ..))
130-
|| (matches!(lint_level, (.., LintLevelSource::Default)))
131-
&& lint.default_level(tcx.sess.edition()) == Level::Allow
132-
{
133-
Some(LintId::of(lint))
134-
} else {
135-
None
136-
}
133+
let lint_level = map.lint_level_id_at_node(tcx, LintId::of(lint), CRATE_HIR_ID);
134+
if matches!(lint_level, (Level::Allow, ..))
135+
|| (matches!(lint_level, (.., LintLevelSource::Default)))
136+
&& lint.default_level(tcx.sess.edition()) == Level::Allow
137+
{
138+
Some(LintId::of(lint))
137139
} else {
138140
None
139141
}

compiler/rustc_lint_defs/src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,10 @@ impl FutureIncompatibilityReason {
466466
| FutureIncompatibilityReason::Custom(_) => None,
467467
}
468468
}
469+
470+
pub fn has_future_breakage(self) -> bool {
471+
matches!(self, FutureIncompatibilityReason::FutureReleaseErrorReportInDeps)
472+
}
469473
}
470474

471475
impl FutureIncompatibleInfo {

compiler/rustc_middle/src/lint.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,7 @@ pub fn lint_level(
290290
let has_future_breakage = future_incompatible.map_or(
291291
// Default allow lints trigger too often for testing.
292292
sess.opts.unstable_opts.future_incompat_test && lint.default_level != Level::Allow,
293-
|incompat| {
294-
matches!(
295-
incompat.reason,
296-
FutureIncompatibilityReason::FutureReleaseErrorReportInDeps
297-
)
298-
},
293+
|incompat| incompat.reason.has_future_breakage(),
299294
);
300295

301296
// Convert lint level to error level.

0 commit comments

Comments
 (0)