Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 506b0df

Browse files
committedSep 26, 2024
Add environment variable tracking in places where it was convenient
1 parent 3f246fa commit 506b0df

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed
 

‎compiler/rustc_borrowck/src/nll.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use rustc_mir_dataflow::move_paths::MoveData;
2222
use rustc_mir_dataflow::points::DenseLocationMap;
2323
use rustc_session::config::MirIncludeSpans;
2424
use rustc_span::symbol::sym;
25+
use rustc_span::Symbol;
2526
use tracing::{debug, instrument};
2627

2728
use crate::borrow_set::BorrowSet;
@@ -179,9 +180,11 @@ pub(crate) fn compute_regions<'a, 'tcx>(
179180
}
180181

181182
if polonius_output {
182-
let algorithm =
183-
env::var("POLONIUS_ALGORITHM").unwrap_or_else(|_| String::from("Hybrid"));
184-
let algorithm = Algorithm::from_str(&algorithm).unwrap();
183+
let algorithm = infcx
184+
.tcx
185+
.env_var(Symbol::intern("POLONIUS_ALGORITHM"))
186+
.unwrap_or_else(|| Symbol::intern("Hybrid"));
187+
let algorithm = Algorithm::from_str(algorithm.as_str()).unwrap();
185188
debug!("compute_regions: using polonius algorithm {:?}", algorithm);
186189
let _prof_timer = infcx.tcx.prof.generic_activity("polonius_analysis");
187190
Some(Rc::new(Output::compute(all_facts, algorithm, false)))

‎compiler/rustc_lint/src/non_local_def.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,10 @@ impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions {
105105
// determining if we are in a doctest context can't currently be determined
106106
// by the code itself (there are no specific attributes), but fortunately rustdoc
107107
// sets a perma-unstable env var for libtest so we just reuse that for now
108-
let is_at_toplevel_doctest =
109-
|| self.body_depth == 2 && std::env::var("UNSTABLE_RUSTDOC_TEST_PATH").is_ok();
108+
let is_at_toplevel_doctest = || {
109+
self.body_depth == 2
110+
&& cx.tcx.env_var(Symbol::intern("UNSTABLE_RUSTDOC_TEST_PATH")).is_some()
111+
};
110112

111113
match item.kind {
112114
ItemKind::Impl(impl_) => {

0 commit comments

Comments
 (0)
Failed to load comments.