Skip to content

Commit

Permalink
Add polonius compare mode
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino committed May 30, 2018
1 parent 74d0939 commit 9df0a41
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/tools/compiletest/src/common.rs
Expand Up @@ -99,18 +99,21 @@ impl fmt::Display for Mode {
#[derive(Clone, PartialEq)]
pub enum CompareMode {
Nll,
Polonius,
}

impl CompareMode {
pub(crate) fn to_str(&self) -> &'static str {
match *self {
CompareMode::Nll => "nll",
CompareMode::Polonius => "polonius",
}
}

pub fn parse(s: String) -> CompareMode {
match s.as_str() {
"nll" => CompareMode::Nll,
"polonius" => CompareMode::Polonius,
x => panic!("unknown --compare-mode option: {}", x),
}
}
Expand Down
13 changes: 11 additions & 2 deletions src/tools/compiletest/src/runtest.rs
Expand Up @@ -1729,6 +1729,9 @@ impl<'test> TestCx<'test> {
Some(CompareMode::Nll) => {
rustc.args(&["-Zborrowck=mir", "-Ztwo-phase-borrows"]);
}
Some(CompareMode::Polonius) => {
rustc.args(&["-Zpolonius", "-Zborrowck=mir", "-Ztwo-phase-borrows"]);
}
None => {}
}

Expand Down Expand Up @@ -2898,8 +2901,14 @@ impl<'test> TestCx<'test> {
&self.config.compare_mode,
kind,
);
if !path.exists() && self.config.compare_mode.is_some() {
// fallback!

if !path.exists() {
if let Some(CompareMode::Polonius) = self.config.compare_mode {
path = expected_output_path(&self.testpaths, self.revision, &Some(CompareMode::Nll), kind);
}
}

if !path.exists() {
path = expected_output_path(&self.testpaths, self.revision, &None, kind);
}

Expand Down

0 comments on commit 9df0a41

Please sign in to comment.