From 1404c00eb05931399e23338df30461ea1203fabd Mon Sep 17 00:00:00 2001 From: Vytautas Astrauskas Date: Wed, 30 May 2018 17:17:37 +0200 Subject: [PATCH 1/2] Allow choosing Polonius algorithm via environment variable POLONIUS_ALGORITHM. --- src/Cargo.lock | 9 +++++---- src/librustc/Cargo.toml | 2 +- src/librustc_mir/Cargo.toml | 2 +- src/librustc_mir/borrow_check/nll/mod.rs | 8 +++++++- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index d5a1d18a67608..d17faef82b563 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -1456,10 +1456,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "polonius-engine" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "datafrog 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1785,7 +1786,7 @@ dependencies = [ "jobserver 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "polonius-engine 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "polonius-engine 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc_macro 0.0.0", "rustc_apfloat 0.0.0", "rustc_data_structures 0.0.0", @@ -2174,7 +2175,7 @@ dependencies = [ "graphviz 0.0.0", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "log_settings 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "polonius-engine 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "polonius-engine 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc 0.0.0", "rustc_apfloat 0.0.0", "rustc_data_structures 0.0.0", @@ -3176,7 +3177,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum phf_generator 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "6b07ffcc532ccc85e3afc45865469bf5d9e4ef5bfcf9622e3cfe80c2d275ec03" "checksum phf_shared 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "07e24b0ca9643bdecd0632f2b3da6b1b89bbb0030e0b992afc1113b23a7bc2f2" "checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903" -"checksum polonius-engine 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9385a6d8f8ff6fd7e48a803c6a77fb89cc929dc7e2af6bf972494bbc8ff8b9e4" +"checksum polonius-engine 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a5b6b0a7f5f4278b991ffd14abce1d01b013121ad297460237ef0a2f08d43201" "checksum precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" "checksum pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a029430f0d744bc3d15dd474d591bed2402b645d024583082b9f63bb936dac6" "checksum proc-macro2 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "49b6a521dc81b643e9a51e0d1cf05df46d5a2f3c0280ea72bcb68276ba64a118" diff --git a/src/librustc/Cargo.toml b/src/librustc/Cargo.toml index df68bf1fd9aab..1d1166ad2c4fd 100644 --- a/src/librustc/Cargo.toml +++ b/src/librustc/Cargo.toml @@ -16,7 +16,7 @@ graphviz = { path = "../libgraphviz" } jobserver = "0.1" lazy_static = "1.0.0" log = { version = "0.4", features = ["release_max_level_info", "std"] } -polonius-engine = "0.4.0" +polonius-engine = "0.5.0" proc_macro = { path = "../libproc_macro" } rustc_apfloat = { path = "../librustc_apfloat" } rustc_target = { path = "../librustc_target" } diff --git a/src/librustc_mir/Cargo.toml b/src/librustc_mir/Cargo.toml index 512ab53f401a6..0fd1f92a51627 100644 --- a/src/librustc_mir/Cargo.toml +++ b/src/librustc_mir/Cargo.toml @@ -15,7 +15,7 @@ either = "1.5.0" graphviz = { path = "../libgraphviz" } log = "0.4" log_settings = "0.1.1" -polonius-engine = "0.4.0" +polonius-engine = "0.5.0" rustc = { path = "../librustc" } rustc_target = { path = "../librustc_target" } rustc_data_structures = { path = "../librustc_data_structures" } diff --git a/src/librustc_mir/borrow_check/nll/mod.rs b/src/librustc_mir/borrow_check/nll/mod.rs index ec1f3dbaeebf5..c95b236faaf5f 100644 --- a/src/librustc_mir/borrow_check/nll/mod.rs +++ b/src/librustc_mir/borrow_check/nll/mod.rs @@ -22,9 +22,11 @@ use rustc::ty::{self, RegionKind, RegionVid}; use rustc::util::nodemap::FxHashMap; use std::collections::BTreeSet; use std::fmt::Debug; +use std::env; use std::io; use std::path::PathBuf; use std::rc::Rc; +use std::str::FromStr; use transform::MirSource; use util::liveness::{LivenessResults, LocalSet}; @@ -156,9 +158,13 @@ pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>( } if infcx.tcx.sess.opts.debugging_opts.polonius { + let algorithm = env::var("POLONIUS_ALGORITHM") + .unwrap_or(String::from("DatafrogOpt")); + let algorithm = Algorithm::from_str(&algorithm).unwrap(); + info!("Using Polonius algorithm: {:?}", algorithm); Some(Rc::new(Output::compute( &all_facts, - Algorithm::DatafrogOpt, + algorithm, false, ))) } else { From 265b04df9a5c75ed021c35abfbda3439e9858018 Mon Sep 17 00:00:00 2001 From: Vytautas Astrauskas Date: Sat, 2 Jun 2018 14:20:04 +0200 Subject: [PATCH 2/2] Change the log level of the message reporting the selected Polonius algorithm to debug. --- src/librustc_mir/borrow_check/nll/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_mir/borrow_check/nll/mod.rs b/src/librustc_mir/borrow_check/nll/mod.rs index c95b236faaf5f..c3d9dd8378d4a 100644 --- a/src/librustc_mir/borrow_check/nll/mod.rs +++ b/src/librustc_mir/borrow_check/nll/mod.rs @@ -161,7 +161,7 @@ pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>( let algorithm = env::var("POLONIUS_ALGORITHM") .unwrap_or(String::from("DatafrogOpt")); let algorithm = Algorithm::from_str(&algorithm).unwrap(); - info!("Using Polonius algorithm: {:?}", algorithm); + debug!("compute_regions: using polonius algorithm {:?}", algorithm); Some(Rc::new(Output::compute( &all_facts, algorithm,