Check for warnings after compilation (#772)
* Check for warnings after compilation * Always catch errors first
This commit is contained in:
parent
24fd7e16fd
commit
21a4adea3e
|
@ -531,11 +531,16 @@ pub struct CompilerOutput {
|
|||
}
|
||||
|
||||
impl CompilerOutput {
|
||||
/// Whether the output contains an compiler error
|
||||
/// Whether the output contains a compiler error
|
||||
pub fn has_error(&self) -> bool {
|
||||
self.errors.iter().any(|err| err.severity.is_error())
|
||||
}
|
||||
|
||||
/// Whether the output contains a compiler warning
|
||||
pub fn has_warning(&self) -> bool {
|
||||
self.errors.iter().any(|err| err.severity.is_warning())
|
||||
}
|
||||
|
||||
pub fn diagnostics<'a>(&'a self, ignored_error_codes: &'a [u64]) -> OutputDiagnostics {
|
||||
OutputDiagnostics { errors: &self.errors, ignored_error_codes }
|
||||
}
|
||||
|
@ -687,11 +692,20 @@ impl<'a> OutputDiagnostics<'a> {
|
|||
pub fn has_error(&self) -> bool {
|
||||
self.errors.iter().any(|err| err.severity.is_error())
|
||||
}
|
||||
|
||||
/// Returns true if there is at least one warning
|
||||
pub fn has_warning(&self) -> bool {
|
||||
self.errors.iter().any(|err| err.severity.is_warning())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> fmt::Display for OutputDiagnostics<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
if !self.has_error() {
|
||||
if self.has_error() {
|
||||
f.write_str("Compiler run failed")?;
|
||||
} else if self.has_warning() {
|
||||
f.write_str("Compiler run successful (with warnings)")?;
|
||||
} else {
|
||||
f.write_str("Compiler run successful")?;
|
||||
}
|
||||
for err in self.errors {
|
||||
|
|
Loading…
Reference in New Issue