1
Fork 0

Change how edition based future compatibility warnings are handled

This commit is contained in:
Ryan Levick 2021-06-15 17:16:21 +02:00
parent 117799b73c
commit 23176f60e7
98 changed files with 380 additions and 540 deletions

View file

@ -142,13 +142,39 @@ pub struct Lint {
pub struct FutureIncompatibleInfo {
/// e.g., a URL for an issue/PR/RFC or error code
pub reference: &'static str,
/// If this is an edition fixing lint, the edition in which
/// this lint becomes obsolete
pub edition: Option<Edition>,
/// The reason for the lint used by diagnostics to provide
/// the right help message
pub reason: FutureIncompatibilityReason,
/// Information about a future breakage, which will
/// be emitted in JSON messages to be displayed by Cargo
/// for upstream deps
pub future_breakage: Option<FutureBreakage>,
/// Provide a custom explanation message for diagnostics
/// if the default explanation message is not appropriate
pub custom_explanation: Option<&'static str>,
}
/// The reason for future incompatibility
#[derive(Copy, Clone, Debug)]
pub enum FutureIncompatibilityReason {
/// We're fixing a bug which will impact all editions
BugFix,
/// Previously accepted code that will become an
/// error in the provided edition
EditionError(Edition),
/// Code that changes meaning in some way in
/// the provided edition
EditionSemanticsChange(Edition),
}
impl FutureIncompatibilityReason {
pub fn edition(self) -> Option<Edition> {
match self {
Self::EditionError(e) => Some(e),
Self::EditionSemanticsChange(e) => Some(e),
_ => None,
}
}
}
#[derive(Copy, Clone, Debug)]
@ -158,7 +184,12 @@ pub struct FutureBreakage {
impl FutureIncompatibleInfo {
pub const fn default_fields_for_macro() -> Self {
FutureIncompatibleInfo { reference: "", edition: None, future_breakage: None }
FutureIncompatibleInfo {
reference: "",
reason: FutureIncompatibilityReason::BugFix,
future_breakage: None,
custom_explanation: None,
}
}
}