]> git.lizzy.rs Git - rust.git/commitdiff
Add polonius compare mode
authorSantiago Pastorino <spastorino@gmail.com>
Mon, 28 May 2018 18:30:02 +0000 (15:30 -0300)
committerSantiago Pastorino <spastorino@gmail.com>
Wed, 30 May 2018 17:03:31 +0000 (14:03 -0300)
src/tools/compiletest/src/common.rs
src/tools/compiletest/src/runtest.rs

index b2ce5ce52f719ef2c073f83e946e3370150cecba..951a72fec6891209c5b7988aef31c8d63305a318 100644 (file)
@@ -99,18 +99,21 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 #[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),
         }
     }
index 9ff80cc1d3c3069b3b1e0add1048515f7d91c2ca..f1e0c2bea0e4043196b79b0211bbd3cd908e7e42 100644 (file)
@@ -1729,6 +1729,9 @@ fn make_compile_args(&self, input_file: &Path, output_file: TargetLocation) -> C
             Some(CompareMode::Nll) => {
                 rustc.args(&["-Zborrowck=mir", "-Ztwo-phase-borrows"]);
             }
+            Some(CompareMode::Polonius) => {
+                rustc.args(&["-Zpolonius", "-Zborrowck=mir", "-Ztwo-phase-borrows"]);
+            }
             None => {}
         }
 
@@ -2898,8 +2901,14 @@ fn expected_output_path(&self, kind: &str) -> PathBuf {
             &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);
         }