Skip to content

Commit

Permalink
Add environment variable tracking in places where it was convenient
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Sep 27, 2024
1 parent 8deec6f commit dee9b61
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
9 changes: 6 additions & 3 deletions compiler/rustc_borrowck/src/nll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
use rustc_mir_dataflow::move_paths::MoveData;
use rustc_mir_dataflow::points::DenseLocationMap;
use rustc_session::config::MirIncludeSpans;
use rustc_span::Symbol;
use rustc_span::symbol::sym;
use tracing::{debug, instrument};

Expand Down Expand Up @@ -179,9 +180,11 @@ 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(Symbol::intern("POLONIUS_ALGORITHM"))
.unwrap_or_else(|| Symbol::intern("Hybrid"));
let algorithm = Algorithm::from_str(algorithm.as_str()).unwrap();
debug!("compute_regions: using polonius algorithm {:?}", algorithm);
let _prof_timer = infcx.tcx.prof.generic_activity("polonius_analysis");
Some(Rc::new(Output::compute(all_facts, algorithm, false)))
Expand Down
8 changes: 5 additions & 3 deletions compiler/rustc_lint/src/non_local_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use rustc_middle::ty::TyCtxt;
use rustc_session::{declare_lint, impl_lint_pass};
use rustc_span::def_id::{DefId, LOCAL_CRATE};
use rustc_span::symbol::kw;
use rustc_span::{ExpnKind, MacroKind, Span, sym};
use rustc_span::{ExpnKind, MacroKind, Span, Symbol, sym};

use crate::lints::{NonLocalDefinitionsCargoUpdateNote, NonLocalDefinitionsDiag};
use crate::{LateContext, LateLintPass, LintContext, fluent_generated as fluent};
Expand Down Expand Up @@ -105,8 +105,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(Symbol::intern("UNSTABLE_RUSTDOC_TEST_PATH")).is_some()
};

match item.kind {
ItemKind::Impl(impl_) => {
Expand Down

0 comments on commit dee9b61

Please sign in to comment.