@@ -1458,9 +1458,34 @@ impl fmt::Debug for Literal {
14581458 }
14591459}
14601460
1461- /// Tracked access to environment variables.
1462- #[ unstable( feature = "proc_macro_tracked_env" , issue = "99515" ) ]
1463- pub mod tracked_env {
1461+ #[ unstable( feature = "proc_macro_tracked_env" , issue = "74690" ) ]
1462+ /// Tracked access to env and path.
1463+ pub mod tracked {
1464+ #[ unstable( feature = "proc_macro_tracked_path" , issue = "73921" ) ]
1465+ use std:: path:: Path ;
1466+
1467+ /// Track a file as if it was a dependency.
1468+ ///
1469+ /// The file is located relative to the current file where the proc-macro
1470+ /// is used (similarly to how modules are found). The provided path is
1471+ /// interpreted in a platform-specific way at compile time. So, for
1472+ /// instance, an invocation with a Windows path
1473+ /// containing backslashes `\` would not compile correctly on Unix.
1474+ ///
1475+ /// Errors if the provided `Path` cannot be encoded as a `str`
1476+ ///
1477+ /// Commonly used for tracking asset preprocessing.
1478+ #[ unstable( feature = "proc_macro_tracked_path" , issue = "73921" ) ]
1479+ pub fn path < P : AsRef < Path > > ( path : P ) -> Result < ( ) , ( ) > {
1480+ let path: & Path = path. as_ref ( ) ;
1481+ if let Some ( path) = path. to_str ( ) {
1482+ crate :: bridge:: client:: FreeFunctions :: track_fs_path ( path) ;
1483+ Ok ( ( ) )
1484+ } else {
1485+ Err ( ( ) )
1486+ }
1487+ }
1488+
14641489 use std:: env:: { self , VarError } ;
14651490 use std:: ffi:: OsStr ;
14661491
@@ -1469,25 +1494,11 @@ pub mod tracked_env {
14691494 /// compilation, and will be able to rerun the build when the value of that variable changes.
14701495 /// Besides the dependency tracking this function should be equivalent to `env::var` from the
14711496 /// standard library, except that the argument must be UTF-8.
1472- #[ unstable( feature = "proc_macro_tracked_env" , issue = "99515 " ) ]
1473- pub fn var < K : AsRef < OsStr > + AsRef < str > > ( key : K ) -> Result < String , VarError > {
1497+ #[ unstable( feature = "proc_macro_tracked_env" , issue = "74690 " ) ]
1498+ pub fn env_var < K : AsRef < OsStr > + AsRef < str > > ( key : K ) -> Result < String , VarError > {
14741499 let key: & str = key. as_ref ( ) ;
14751500 let value = env:: var ( key) ;
14761501 crate :: bridge:: client:: FreeFunctions :: track_env_var ( key, value. as_deref ( ) . ok ( ) ) ;
14771502 value
14781503 }
14791504}
1480-
1481- /// Tracked access to additional files.
1482- #[ unstable( feature = "track_path" , issue = "99515" ) ]
1483- pub mod tracked_path {
1484-
1485- /// Track a file explicitly.
1486- ///
1487- /// Commonly used for tracking asset preprocessing.
1488- #[ unstable( feature = "track_path" , issue = "99515" ) ]
1489- pub fn path < P : AsRef < str > > ( path : P ) {
1490- let path: & str = path. as_ref ( ) ;
1491- crate :: bridge:: client:: FreeFunctions :: track_path ( path) ;
1492- }
1493- }
0 commit comments