Skip to content

Commit 4645679

Browse files
committed
Add explain_reason: false in future_incompatible.
This allows supressing the default warning message for future incompatible ints, for lints that already provide a more detailed warning.
1 parent 543ab99 commit 4645679

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

compiler/rustc_lint_defs/src/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ pub struct FutureIncompatibleInfo {
145145
/// The reason for the lint used by diagnostics to provide
146146
/// the right help message
147147
pub reason: FutureIncompatibilityReason,
148+
/// Whether to explain the reason to the user.
149+
///
150+
/// Set to false for lints that already include a more detailed
151+
/// explanation.
152+
pub explain_reason: bool,
148153
/// Information about a future breakage, which will
149154
/// be emitted in JSON messages to be displayed by Cargo
150155
/// for upstream deps
@@ -185,6 +190,7 @@ impl FutureIncompatibleInfo {
185190
FutureIncompatibleInfo {
186191
reference: "",
187192
reason: FutureIncompatibilityReason::FutureReleaseError,
193+
explain_reason: true,
188194
future_breakage: None,
189195
}
190196
}

compiler/rustc_middle/src/lint.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -398,9 +398,14 @@ pub fn struct_lint_level<'s, 'd>(
398398
it will become a hard error in a future release!"
399399
.to_owned()
400400
};
401-
let citation = format!("for more information, see {}", future_incompatible.reference);
402-
err.warn(&explanation);
403-
err.note(&citation);
401+
if future_incompatible.explain_reason {
402+
err.warn(&explanation);
403+
}
404+
if !future_incompatible.reference.is_empty() {
405+
let citation =
406+
format!("for more information, see {}", future_incompatible.reference);
407+
err.note(&citation);
408+
}
404409
}
405410

406411
// Finally, run `decorate`. This function is also responsible for emitting the diagnostic.

0 commit comments

Comments
 (0)