Skip to content

Commit 9df0a41

Browse files
committed
Add polonius compare mode
1 parent 74d0939 commit 9df0a41

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/tools/compiletest/src/common.rs

+3
Original file line numberDiff line numberDiff line change
@@ -99,18 +99,21 @@ impl fmt::Display for Mode {
9999
#[derive(Clone, PartialEq)]
100100
pub enum CompareMode {
101101
Nll,
102+
Polonius,
102103
}
103104

104105
impl CompareMode {
105106
pub(crate) fn to_str(&self) -> &'static str {
106107
match *self {
107108
CompareMode::Nll => "nll",
109+
CompareMode::Polonius => "polonius",
108110
}
109111
}
110112

111113
pub fn parse(s: String) -> CompareMode {
112114
match s.as_str() {
113115
"nll" => CompareMode::Nll,
116+
"polonius" => CompareMode::Polonius,
114117
x => panic!("unknown --compare-mode option: {}", x),
115118
}
116119
}

src/tools/compiletest/src/runtest.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -1729,6 +1729,9 @@ impl<'test> TestCx<'test> {
17291729
Some(CompareMode::Nll) => {
17301730
rustc.args(&["-Zborrowck=mir", "-Ztwo-phase-borrows"]);
17311731
}
1732+
Some(CompareMode::Polonius) => {
1733+
rustc.args(&["-Zpolonius", "-Zborrowck=mir", "-Ztwo-phase-borrows"]);
1734+
}
17321735
None => {}
17331736
}
17341737

@@ -2898,8 +2901,14 @@ impl<'test> TestCx<'test> {
28982901
&self.config.compare_mode,
28992902
kind,
29002903
);
2901-
if !path.exists() && self.config.compare_mode.is_some() {
2902-
// fallback!
2904+
2905+
if !path.exists() {
2906+
if let Some(CompareMode::Polonius) = self.config.compare_mode {
2907+
path = expected_output_path(&self.testpaths, self.revision, &Some(CompareMode::Nll), kind);
2908+
}
2909+
}
2910+
2911+
if !path.exists() {
29032912
path = expected_output_path(&self.testpaths, self.revision, &None, kind);
29042913
}
29052914

0 commit comments

Comments
 (0)