diff options
| author | Mads Marquart <mads@marquart.dk> | 2024-12-01 11:55:46 +0100 |
|---|---|---|
| committer | Mads Marquart <mads@marquart.dk> | 2025-03-26 15:46:40 +0100 |
| commit | 632ce38c9a93a6ee890aedd99fcb1a61cabd0a46 (patch) | |
| tree | 2cad08b6cac298e2c4907cc57b8d358f625dea4a | |
| parent | 17db054141f909277a0c57b4698f420636a2c511 (diff) | |
| download | rust-632ce38c9a93a6ee890aedd99fcb1a61cabd0a46.tar.gz rust-632ce38c9a93a6ee890aedd99fcb1a61cabd0a46.zip | |
Add environment variable tracking in places where it was convenient
This won't work with Cargo's change tracking, but it should work with incremental.
| -rw-r--r-- | compiler/rustc_borrowck/src/nll.rs | 7 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/non_local_def.rs | 6 |
2 files changed, 7 insertions, 6 deletions
diff --git a/compiler/rustc_borrowck/src/nll.rs b/compiler/rustc_borrowck/src/nll.rs index d0bd364425a..8e7b6f083ac 100644 --- a/compiler/rustc_borrowck/src/nll.rs +++ b/compiler/rustc_borrowck/src/nll.rs @@ -1,9 +1,9 @@ //! The entry point of the NLL borrow checker. +use std::io; use std::path::PathBuf; use std::rc::Rc; use std::str::FromStr; -use std::{env, io}; use polonius_engine::{Algorithm, Output}; use rustc_index::IndexSlice; @@ -162,9 +162,8 @@ pub(crate) fn compute_regions<'a, 'tcx>( } if polonius_output { - let algorithm = - env::var("POLONIUS_ALGORITHM").unwrap_or_else(|_| String::from("Hybrid")); - let algorithm = Algorithm::from_str(&algorithm).unwrap(); + let algorithm = infcx.tcx.env_var("POLONIUS_ALGORITHM").unwrap_or("Hybrid"); + let algorithm = Algorithm::from_str(algorithm).unwrap(); debug!("compute_regions: using polonius algorithm {:?}", algorithm); let _prof_timer = infcx.tcx.prof.generic_activity("polonius_analysis"); Some(Box::new(Output::compute(polonius_facts, algorithm, false))) diff --git a/compiler/rustc_lint/src/non_local_def.rs b/compiler/rustc_lint/src/non_local_def.rs index f8e0a94f9ec..9ed11d9cc82 100644 --- a/compiler/rustc_lint/src/non_local_def.rs +++ b/compiler/rustc_lint/src/non_local_def.rs @@ -104,8 +104,10 @@ impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions { // determining if we are in a doctest context can't currently be determined // by the code itself (there are no specific attributes), but fortunately rustdoc // sets a perma-unstable env var for libtest so we just reuse that for now - let is_at_toplevel_doctest = - || self.body_depth == 2 && std::env::var("UNSTABLE_RUSTDOC_TEST_PATH").is_ok(); + let is_at_toplevel_doctest = || { + self.body_depth == 2 + && cx.tcx.env_var_os("UNSTABLE_RUSTDOC_TEST_PATH".as_ref()).is_some() + }; match item.kind { ItemKind::Impl(impl_) => { |
