Skip to content
/ rust Public
forked from rust-lang/rust

Commit a175db1

Browse files
authored
Rollup merge of rust-lang#133108 - RalfJung:future-compat-needs-to-run, r=lcnr
lints_that_dont_need_to_run: never skip future-compat-reported lints Follow-up to rust-lang#125116: future-compat lints show up with `--json=future-incompat` even if they are otherwise allowed in the crate. So let's ensure we do not skip those as part of the `lints_that_dont_need_to_run` logic. I could not find a current future compat lint that is emitted by a lint pass, so there's no clear way to add a test for this. Cc `@blyxyas` `@cjgillot`
2 parents 25dc4d0 + df94818 commit a175db1

File tree

3 files changed

+27
-16
lines changed

3 files changed

+27
-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

+14
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,20 @@ impl FutureIncompatibilityReason {
466466
| FutureIncompatibilityReason::Custom(_) => None,
467467
}
468468
}
469+
470+
pub fn has_future_breakage(self) -> bool {
471+
match self {
472+
FutureIncompatibilityReason::FutureReleaseErrorReportInDeps => true,
473+
474+
FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps
475+
| FutureIncompatibilityReason::FutureReleaseSemanticsChange
476+
| FutureIncompatibilityReason::EditionError(_)
477+
| FutureIncompatibilityReason::EditionSemanticsChange(_)
478+
| FutureIncompatibilityReason::EditionAndFutureReleaseError(_)
479+
| FutureIncompatibilityReason::EditionAndFutureReleaseSemanticsChange(_)
480+
| FutureIncompatibilityReason::Custom(_) => false,
481+
}
482+
}
469483
}
470484

471485
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)