Skip to content

Commit 4dc0d1e

Browse files
committed
analyze: borrowck: don't dump facts to disk for debugging by default
1 parent ff75175 commit 4dc0d1e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

c2rust-analyze/src/borrowck/dump.rs

+13
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,28 @@
33
use crate::borrowck::atoms::{AllFacts, AtomMaps, Loan, Origin, Output, Path, Point, Variable};
44
use rustc_hash::{FxHashMap, FxHashSet};
55
use std::collections::{BTreeMap, BTreeSet};
6+
use std::env;
67
use std::error::Error;
78
use std::fmt::Write as _;
89
use std::fs::{self, File};
910
use std::hash::Hash;
1011
use std::io::{BufWriter, Write};
1112
use std::path;
1213

14+
thread_local! {
15+
static DUMP_FACTS: bool = {
16+
env::var("C2RUST_ANALYZE_DUMP_POLONIUS_FACTS").map_or(false, |val| &val == "1")
17+
};
18+
}
19+
1320
pub fn dump_facts_to_dir(
1421
facts: &AllFacts,
1522
maps: &AtomMaps,
1623
dir: impl AsRef<path::Path>,
1724
) -> Result<(), Box<dyn Error>> {
25+
if !DUMP_FACTS.with(|&flag| flag) {
26+
return Ok(());
27+
}
1828
let dir: &path::Path = dir.as_ref();
1929
fs::create_dir_all(dir)?;
2030
let wr = FactWriter { maps, dir };
@@ -60,6 +70,9 @@ pub fn dump_output_to_dir(
6070
maps: &AtomMaps,
6171
dir: impl AsRef<path::Path>,
6272
) -> Result<(), Box<dyn Error>> {
73+
if !DUMP_FACTS.with(|&flag| flag) {
74+
return Ok(());
75+
}
6376
let dir: &path::Path = dir.as_ref();
6477
fs::create_dir_all(dir)?;
6578
let wr = FactWriter { maps, dir };

0 commit comments

Comments
 (0)