Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
  • Loading branch information
drahnr committed Aug 1, 2023
1 parent 54a2945 commit a750c03
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions library/proc_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1459,42 +1459,43 @@ impl fmt::Debug for Literal {
}

#[unstable(feature = "proc_macro_tracked_env", issue = "74690")]
/// Tracked access to env and path.
pub mod tracked {
#[unstable(feature = "proc_macro_tracked_path", issue = "73921")]
use std::path::Path;

/// Track a file as if it was a dependency.
///
/// The file is located relative to the current file where the proc-macro
/// is used (similarly to how modules are found). The provided path is
/// interpreted in a platform-specific way at compile time. So, for
/// instance, an invocation with a Windows path
/// containing backslashes `\` would not compile correctly on Unix.
///
/// Errors if the provided `Path` cannot be encoded as a `str`
///
/// Commonly used for tracking asset preprocessing.
#[unstable(feature = "proc_macro_tracked_path", issue = "73921")]
pub fn path<P: AsRef<Path>>(path: P) {
let path: &Path = path.as_ref();
crate::bridge::client::FreeFunctions::track_path(PathBuf::from(path));
}

/// Tracked access to env variables.
pub mod tracked_env {
use std::env::{self, VarError};
use std::ffi::OsStr;
use std::path::PathBuf;

/// Retrieve an environment variable and add it to build dependency info.
/// The build system executing the compiler will know that the variable was accessed during
/// compilation, and will be able to rerun the build when the value of that variable changes.
/// Besides the dependency tracking this function should be equivalent to `env::var` from the
/// standard library, except that the argument must be UTF-8.
#[unstable(feature = "proc_macro_tracked_env", issue = "74690")]
pub fn env_var<K: AsRef<OsStr> + AsRef<str>>(key: K) -> Result<String, VarError> {
pub fn var<K: AsRef<OsStr> + AsRef<str>>(key: K) -> Result<String, VarError> {
let key: &str = key.as_ref();
let value = env::var(key);
crate::bridge::client::FreeFunctions::track_env_var(key, value.as_deref().ok());
value
}
}

/// Tracked access to additional files.
#[unstable(feature = "track_path", issue = "99515")]
pub mod tracked_path {
use std::path::{Path, PathBuf};

/// Track a file as if it was a dependency.
///
/// The file is located relative to the current file where the proc-macro
/// is used (similarly to how modules are found). The provided path is
/// interpreted in a platform-specific way at compile time. So, for
/// instance, an invocation with a Windows path
/// containing backslashes `\` would not compile correctly on Unix.
///
/// Errors if the provided `Path` cannot be encoded as a `str`
///
/// Commonly used for tracking asset preprocessing.
pub fn path<P: AsRef<Path>>(path: P) {
let path = PathBuf::from(path.as_ref());
crate::bridge::client::FreeFunctions::track_path(path);
}
}

0 comments on commit a750c03

Please sign in to comment.