Skip to content

Commit 2ee0861

Browse files
committed
Add environment variable tracking in places where it was convenient
1 parent 8d1d4be commit 2ee0861

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

compiler/rustc_borrowck/src/nll.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//! The entry point of the NLL borrow checker.
22
3+
use std::io;
34
use std::path::PathBuf;
45
use std::rc::Rc;
56
use std::str::FromStr;
6-
use std::{env, io};
77

88
use polonius_engine::{Algorithm, Output};
99
use rustc_data_structures::fx::FxIndexMap;
@@ -21,7 +21,7 @@ use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
2121
use rustc_mir_dataflow::move_paths::MoveData;
2222
use rustc_mir_dataflow::points::DenseLocationMap;
2323
use rustc_session::config::MirIncludeSpans;
24-
use rustc_span::symbol::sym;
24+
use rustc_span::{Symbol, sym};
2525
use tracing::{debug, instrument};
2626

2727
use crate::borrow_set::BorrowSet;
@@ -179,9 +179,11 @@ pub(crate) fn compute_regions<'a, 'tcx>(
179179
}
180180

181181
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();
182+
let algorithm = infcx
183+
.tcx
184+
.env_var(Symbol::intern("POLONIUS_ALGORITHM"))
185+
.unwrap_or_else(|| Symbol::intern("Hybrid"));
186+
let algorithm = Algorithm::from_str(algorithm.as_str()).unwrap();
185187
debug!("compute_regions: using polonius algorithm {:?}", algorithm);
186188
let _prof_timer = infcx.tcx.prof.generic_activity("polonius_analysis");
187189
Some(Box::new(Output::compute(all_facts, algorithm, false)))

compiler/rustc_lint/src/non_local_def.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_middle::ty::TyCtxt;
66
use rustc_session::{declare_lint, impl_lint_pass};
77
use rustc_span::def_id::{DefId, LOCAL_CRATE};
88
use rustc_span::symbol::kw;
9-
use rustc_span::{ExpnKind, MacroKind, Span, sym};
9+
use rustc_span::{ExpnKind, MacroKind, Span, Symbol, sym};
1010

1111
use crate::lints::{NonLocalDefinitionsCargoUpdateNote, NonLocalDefinitionsDiag};
1212
use crate::{LateContext, LateLintPass, LintContext, fluent_generated as fluent};
@@ -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)