Skip to content

Commit 72076c6

Browse files
committed
move and rename proc_macro::tracked_{env::var,path::path}
1 parent 99ca3fc commit 72076c6

File tree

6 files changed

+30
-16
lines changed

6 files changed

+30
-16
lines changed

compiler/rustc_fluent_macro/src/fluent.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ use fluent_syntax::ast::{
88
Attribute, Entry, Expression, Identifier, InlineExpression, Message, Pattern, PatternElement,
99
};
1010
use fluent_syntax::parser::ParserError;
11+
#[cfg(not(bootstrap))]
12+
use proc_macro::tracked::path;
13+
#[cfg(bootstrap)]
1114
use proc_macro::tracked_path::path;
1215
use proc_macro::{Diagnostic, Level, Span};
1316
use proc_macro2::TokenStream;

compiler/rustc_fluent_macro/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// tidy-alphabetical-start
22
#![allow(rustc::default_hash_types)]
3+
#![cfg_attr(bootstrap, feature(track_path))]
4+
#![cfg_attr(not(bootstrap), feature(proc_macro_tracked_path))]
35
#![feature(proc_macro_diagnostic)]
4-
#![feature(track_path)]
56
// tidy-alphabetical-end
67

78
use proc_macro::TokenStream;

compiler/rustc_macros/src/current_version.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ struct RustcVersion {
2222

2323
impl RustcVersion {
2424
fn parse_cfg_release(env_var: &str) -> Result<Self, Box<dyn std::error::Error>> {
25+
#[cfg(not(bootstrap))]
26+
let value = proc_macro::tracked::env_var(env_var)?;
27+
#[cfg(bootstrap)]
2528
let value = proc_macro::tracked_env::var(env_var)?;
29+
2630
Self::parse_str(&value)
2731
.ok_or_else(|| format!("failed to parse rustc version: {:?}", value).into())
2832
}

compiler/rustc_macros/src/symbols.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,13 @@ fn symbols_with_errors(input: TokenStream) -> (TokenStream, Vec<syn::Error>) {
259259
break;
260260
}
261261

262-
let value = match proc_macro::tracked_env::var(env_var.value()) {
262+
#[cfg(bootstrap)]
263+
let tracked_env = proc_macro::tracked_env::var(env_var.value());
264+
265+
#[cfg(not(bootstrap))]
266+
let tracked_env = proc_macro::tracked::env_var(env_var.value());
267+
268+
let value = match tracked_env {
263269
Ok(value) => value,
264270
Err(err) => {
265271
errors.list.push(syn::Error::new_spanned(expr, err));

library/proc_macro/src/lib.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,9 +1594,14 @@ impl fmt::Debug for Literal {
15941594
}
15951595
}
15961596

1597-
/// Tracked access to environment variables.
1598-
#[unstable(feature = "proc_macro_tracked_env", issue = "99515")]
1599-
pub mod tracked_env {
1597+
#[unstable(
1598+
feature = "proc_macro_tracked_path",
1599+
issue = "99515",
1600+
implied_by = "proc_macro_tracked_env"
1601+
)]
1602+
/// Functionality for adding environment state to the build dependency info.
1603+
pub mod tracked {
1604+
16001605
use std::env::{self, VarError};
16011606
use std::ffi::OsStr;
16021607

@@ -1606,23 +1611,18 @@ pub mod tracked_env {
16061611
/// Besides the dependency tracking this function should be equivalent to `env::var` from the
16071612
/// standard library, except that the argument must be UTF-8.
16081613
#[unstable(feature = "proc_macro_tracked_env", issue = "99515")]
1609-
pub fn var<K: AsRef<OsStr> + AsRef<str>>(key: K) -> Result<String, VarError> {
1614+
pub fn env_var<K: AsRef<OsStr> + AsRef<str>>(key: K) -> Result<String, VarError> {
16101615
let key: &str = key.as_ref();
16111616
let value = crate::bridge::client::FreeFunctions::injected_env_var(key)
16121617
.map_or_else(|| env::var(key), Ok);
16131618
crate::bridge::client::FreeFunctions::track_env_var(key, value.as_deref().ok());
16141619
value
16151620
}
1616-
}
1617-
1618-
/// Tracked access to additional files.
1619-
#[unstable(feature = "track_path", issue = "99515")]
1620-
pub mod tracked_path {
16211621

1622-
/// Track a file explicitly.
1622+
/// Track a file or directory explicitly.
16231623
///
16241624
/// Commonly used for tracking asset preprocessing.
1625-
#[unstable(feature = "track_path", issue = "99515")]
1625+
#[unstable(feature = "proc_macro_tracked_path", issue = "99515")]
16261626
pub fn path<P: AsRef<str>>(path: P) {
16271627
let path: &str = path.as_ref();
16281628
crate::bridge::client::FreeFunctions::track_path(path);

tests/ui/proc-macro/auxiliary/env.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
extern crate proc_macro;
44

55
use proc_macro::TokenStream;
6-
use proc_macro::tracked_env::var;
6+
use proc_macro::tracked::env_var;
77

88
#[proc_macro]
99
pub fn generate_const(input: TokenStream) -> TokenStream {
10-
let the_const = match var("THE_CONST") {
10+
let the_const = match env_var("THE_CONST") {
1111
Ok(x) if x == "12" => {
1212
"const THE_CONST: u32 = 12;"
1313
}
1414
_ => {
1515
"const THE_CONST: u32 = 0;"
1616
}
1717
};
18-
let another = if var("ANOTHER").is_ok() {
18+
let another = if env_var("ANOTHER").is_ok() {
1919
"const ANOTHER: u32 = 1;"
2020
} else {
2121
"const ANOTHER: u32 = 2;"

0 commit comments

Comments
 (0)