Add another check

This commit is contained in:
Charles Marsh 2022-08-09 22:16:50 -04:00
parent 6257dd00c7
commit 211849901c
7 changed files with 120 additions and 54 deletions

View file

@ -27,26 +27,27 @@ pub enum Message {
#[serde(with = "LocationDef")]
location: Location,
},
IfTuple {
filename: PathBuf,
#[serde(with = "LocationDef")]
location: Location,
},
}
impl Message {
/// A four-letter shorthand code for the message.
pub fn code(&self) -> &'static str {
match self {
Message::ImportStarUsage {
filename: _,
location: _,
} => "F403",
Message::ImportStarUsage { .. } => "F403",
Message::IfTuple { .. } => "F634",
}
}
/// The body text for the message.
pub fn body(&self) -> &'static str {
match self {
Message::ImportStarUsage {
filename: _,
location: _,
} => "Unable to detect undefined names",
Message::ImportStarUsage { .. } => "Unable to detect undefined names",
Message::IfTuple { .. } => "If test is a tuple, which is always `True`",
}
}
}
@ -65,6 +66,17 @@ impl fmt::Display for Message {
self.code().red().bold(),
self.body()
),
Message::IfTuple { filename, location } => write!(
f,
"{}{}{}{}{}\t{}\t{}",
filename.to_string_lossy().white().bold(),
":".cyan(),
location.column(),
":".cyan(),
location.row(),
self.code().red().bold(),
self.body()
),
}
}
}