Add TyCtx::env_var_os
Along with `TyCtx::env_var` helper. These can be used to track environment variable accesses in the query system. Since `TyCtx::env_var_os` uses `OsStr`, this commit also adds the necessary trait implementations for that to work.
This commit is contained in:
parent
c772573708
commit
17db054141
6 changed files with 75 additions and 1 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#![allow(unused_parens)]
|
||||
|
||||
use std::ffi::OsStr;
|
||||
use std::mem;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
@ -119,6 +120,21 @@ rustc_queries! {
|
|||
desc { "perform lints prior to AST lowering" }
|
||||
}
|
||||
|
||||
/// Tracked access to environment variables.
|
||||
///
|
||||
/// Useful for the implementation of `std::env!`, `proc-macro`s change
|
||||
/// detection and other changes in the compiler's behaviour that is easier
|
||||
/// to control with an environment variable than a flag.
|
||||
///
|
||||
/// NOTE: This currently does not work with dependency info in the
|
||||
/// analysis, codegen and linking passes, place extra code at the top of
|
||||
/// `rustc_interface::passes::write_dep_info` to make that work.
|
||||
query env_var_os(key: &'tcx OsStr) -> Option<&'tcx OsStr> {
|
||||
// Environment variables are global state
|
||||
eval_always
|
||||
desc { "get the value of an environment variable" }
|
||||
}
|
||||
|
||||
query resolutions(_: ()) -> &'tcx ty::ResolverGlobalCtxt {
|
||||
no_hash
|
||||
desc { "getting the resolver outputs" }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue