Implement rustc side of report-future-incompat
This commit is contained in:
parent
ffe52882ed
commit
23018a55d9
22 changed files with 332 additions and 114 deletions
|
@ -225,9 +225,24 @@ pub fn struct_lint_level<'s, 'd>(
|
|||
span: Option<MultiSpan>,
|
||||
decorate: Box<dyn for<'b> FnOnce(LintDiagnosticBuilder<'b>) + 'd>,
|
||||
) {
|
||||
// Check for future incompatibility lints and issue a stronger warning.
|
||||
let lint_id = LintId::of(lint);
|
||||
let future_incompatible = lint.future_incompatible;
|
||||
|
||||
let has_future_breakage =
|
||||
future_incompatible.map_or(false, |incompat| incompat.future_breakage.is_some());
|
||||
|
||||
let mut err = match (level, span) {
|
||||
(Level::Allow, _) => {
|
||||
return;
|
||||
(Level::Allow, span) => {
|
||||
if has_future_breakage {
|
||||
if let Some(span) = span {
|
||||
sess.struct_span_allow(span, "")
|
||||
} else {
|
||||
sess.struct_allow("")
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
(Level::Warn, Some(span)) => sess.struct_span_warn(span, ""),
|
||||
(Level::Warn, None) => sess.struct_warn(""),
|
||||
|
@ -235,10 +250,6 @@ pub fn struct_lint_level<'s, 'd>(
|
|||
(Level::Deny | Level::Forbid, None) => sess.struct_err(""),
|
||||
};
|
||||
|
||||
// Check for future incompatibility lints and issue a stronger warning.
|
||||
let lint_id = LintId::of(lint);
|
||||
let future_incompatible = lint.future_incompatible;
|
||||
|
||||
// If this code originates in a foreign macro, aka something that this crate
|
||||
// did not itself author, then it's likely that there's nothing this crate
|
||||
// can do about it. We probably want to skip the lint entirely.
|
||||
|
@ -321,7 +332,7 @@ pub fn struct_lint_level<'s, 'd>(
|
|||
}
|
||||
}
|
||||
|
||||
err.code(DiagnosticId::Lint(name));
|
||||
err.code(DiagnosticId::Lint { name, has_future_breakage });
|
||||
|
||||
if let Some(future_incompatible) = future_incompatible {
|
||||
const STANDARD_MESSAGE: &str = "this was previously accepted by the compiler but is being phased out; \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue