Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use regex::bytes::Regex;

use crate::{dependencies::build_dependencies, CommandBuilder, Filter, Match, Mode, RustfixMode};
use crate::{
dependencies::build_dependencies, CommandBuilder, Filter, Level, Match, Mode, RustfixMode,
};
pub use color_eyre;
use color_eyre::eyre::Result;
use std::{
Expand Down Expand Up @@ -59,6 +61,9 @@ pub struct Config {
pub run_only_ignored: bool,
/// Filters must match exactly instead of just checking for substrings.
pub filter_exact: bool,
/// If set, lower level annotations will still be checked but we won't go below
/// `forced_lowest_annotation_level`.
pub forced_lowest_annotation_level: Option<Level>,
}

impl Config {
Expand Down Expand Up @@ -103,6 +108,7 @@ impl Config {
list: false,
run_only_ignored: false,
filter_exact: false,
forced_lowest_annotation_level: None,
}
}

Expand Down
15 changes: 12 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use dependencies::{Build, BuildManager};
use lazy_static::lazy_static;
use parser::{ErrorMatch, MaybeSpanned, OptWithLine, Revisioned, Spanned};
use regex::bytes::{Captures, Regex};
use rustc_stderr::{Level, Message};
use rustc_stderr::Message;
use spanned::Span;
use status_emitter::{StatusEmitter, TestStatus};
use std::borrow::Cow;
Expand Down Expand Up @@ -46,6 +46,7 @@ pub use cmd::*;
pub use config::*;
pub use error::*;
pub use mode::*;
pub use rustc_stderr::Level;

/// A filter's match rule.
#[derive(Clone, Debug)]
Expand Down Expand Up @@ -665,6 +666,7 @@ impl dyn TestStatus {
status,
&stdout,
&stderr,
config.forced_lowest_annotation_level,
)?;

if let Mode::Run { .. } = *mode {
Expand Down Expand Up @@ -990,6 +992,7 @@ fn check_test_result(
status: ExitStatus,
stdout: &[u8],
stderr: &[u8],
forced_lowest_annotation_level: Option<Level>,
) -> Result<Command, Errored> {
let mut errors = vec![];
errors.extend(mode.ok(status).err());
Expand All @@ -1013,6 +1016,7 @@ fn check_test_result(
config,
revision,
comments,
forced_lowest_annotation_level,
)?;
if errors.is_empty() {
Ok(command)
Expand Down Expand Up @@ -1067,6 +1071,7 @@ fn check_annotations(
config: &Config,
revision: &str,
comments: &Comments,
forced_lowest_annotation_level: Option<Level>,
) -> Result<(), Errored> {
let error_patterns = comments
.for_revision(revision)
Expand Down Expand Up @@ -1094,7 +1099,7 @@ fn check_annotations(
// The order on `Level` is such that `Error` is the highest level.
// We will ensure that *all* diagnostics of level at least `lowest_annotation_level`
// are matched.
let mut lowest_annotation_level = Level::Error;
let mut lowest_annotation_level = forced_lowest_annotation_level.unwrap_or(Level::Error);
for &ErrorMatch {
ref pattern,
level,
Expand All @@ -1107,7 +1112,11 @@ fn check_annotations(
// If we found a diagnostic with a level annotation, make sure that all
// diagnostics of that level have annotations, even if we don't end up finding a matching diagnostic
// for this pattern.
if lowest_annotation_level > level {
if lowest_annotation_level > level
&& forced_lowest_annotation_level
.map(|forced_minimum| forced_minimum <= level)
.unwrap_or(true)
{
lowest_annotation_level = level;
}

Expand Down
8 changes: 7 additions & 1 deletion src/rustc_stderr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@ struct RustcMessage {
children: Vec<RustcMessage>,
}

/// Message level.
#[derive(Copy, Clone, Debug, PartialOrd, Ord, PartialEq, Eq)]
pub(crate) enum Level {
pub enum Level {
/// Internal compiler error.
Ice = 5,
/// Compilation error.
Error = 4,
/// Compilation warning.
Warn = 3,
/// Help message.
Help = 2,
/// Note message.
Note = 1,
/// Only used for "For more information about this error, try `rustc --explain EXXXX`".
FailureNote = 0,
Expand Down
8 changes: 8 additions & 0 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ fn main() {
&config,
"",
&comments,
None,
)
.unwrap();
match &errors[..] {
Expand Down Expand Up @@ -81,6 +82,7 @@ fn main() {
&config,
"",
&comments,
None,
)
.unwrap();
match &errors[..] {
Expand Down Expand Up @@ -108,6 +110,7 @@ fn main() {
&config,
"",
&comments,
None,
)
.unwrap();
match &errors[..] {
Expand Down Expand Up @@ -139,6 +142,7 @@ fn main() {
&config,
"",
&comments,
None,
)
.unwrap();
match &errors[..] {
Expand Down Expand Up @@ -180,6 +184,7 @@ fn main() {
&config,
"",
&comments,
None,
)
.unwrap();
match &errors[..] {
Expand Down Expand Up @@ -223,6 +228,7 @@ fn main() {
&config,
"",
&comments,
None,
)
.unwrap();
match &errors[..] {
Expand Down Expand Up @@ -277,6 +283,7 @@ fn main() {
&config,
"",
&comments,
None,
)
.unwrap();
match &errors[..] {
Expand Down Expand Up @@ -341,6 +348,7 @@ fn main() {
&config,
"",
&comments,
None,
)
.unwrap();
match &errors[..] {
Expand Down