-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unstable proc_macro tracked::* rename/restructure #87173
base: master
Are you sure you want to change the base?
Changes from all commits
806c6de
4d885df
14eccf6
c8aaec5
1112eb7
2ab0080
fa67588
2738a9f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1489,8 +1489,8 @@ impl fmt::Debug for Literal { | |
} | ||
} | ||
|
||
/// Tracked access to environment variables. | ||
#[unstable(feature = "proc_macro_tracked_env", issue = "99515")] | ||
#[unstable(feature = "proc_macro_tracked_env", issue = "74690")] | ||
/// Tracked access to env variables. | ||
pub mod tracked_env { | ||
use std::env::{self, VarError}; | ||
use std::ffi::OsStr; | ||
|
@@ -1500,7 +1500,7 @@ pub mod tracked_env { | |
/// 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 = "99515")] | ||
#[unstable(feature = "proc_macro_tracked_env", issue = "74690")] | ||
pub fn var<K: AsRef<OsStr> + AsRef<str>>(key: K) -> Result<String, VarError> { | ||
let key: &str = key.as_ref(); | ||
let value = env::var(key); | ||
|
@@ -1510,15 +1510,23 @@ pub mod tracked_env { | |
} | ||
|
||
/// Tracked access to additional files. | ||
#[unstable(feature = "track_path", issue = "99515")] | ||
#[unstable(feature = "proc_macro_tracked_path", issue = "99515")] | ||
pub mod tracked_path { | ||
use std::path::{Path, PathBuf}; | ||
|
||
/// Track a file explicitly. | ||
/// 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 | ||
Comment on lines
+1519
to
+1521
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it not relative to the current working directory? So if I do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I understand the docs correct, this would behave similar to using the |
||
/// instance, an invocation with a Windows path | ||
/// containing backslashes `\` would not compile correctly on Unix. | ||
Comment on lines
+1521
to
+1523
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I find the note on windows/unix paths quite confusing. Who is that note for? What user error is it trying to prevent? |
||
/// | ||
/// Errors if the provided `Path` cannot be encoded as a `str` | ||
/// | ||
/// Commonly used for tracking asset preprocessing. | ||
#[unstable(feature = "track_path", issue = "99515")] | ||
pub fn path<P: AsRef<str>>(path: P) { | ||
let path: &str = path.as_ref(); | ||
pub fn path<P: AsRef<Path>>(path: P) { | ||
let path = PathBuf::from(path.as_ref()); | ||
crate::bridge::client::FreeFunctions::track_path(path); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,23 @@ | ||
#![feature(track_path)] | ||
#![crate_type = "proc-macro"] | ||
#![feature(proc_macro_tracked_path)] | ||
|
||
extern crate proc_macro; | ||
use proc_macro::*; | ||
|
||
use std::str; | ||
|
||
#[proc_macro] | ||
pub fn access_tracked_paths(_: TokenStream) -> TokenStream { | ||
tracked_path::path("emojis.txt"); | ||
|
||
// currently only valid utf-8 paths are supported | ||
if false { | ||
let invalid = [1_u8, 2,123, 254, 0, 0, 1, 1]; | ||
let invalid: &str = unsafe { | ||
str::from_utf8_unchecked(&invalid[..]) | ||
}; | ||
tracked_path::path(invalid); | ||
} | ||
|
||
TokenStream::new() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the tracking issue changed? #74690 is a closed issue.