@@ -1489,9 +1489,34 @@ impl fmt::Debug for Literal {
1489
1489
}
1490
1490
}
1491
1491
1492
- /// Tracked access to environment variables.
1493
- #[ unstable( feature = "proc_macro_tracked_env" , issue = "99515" ) ]
1494
- pub mod tracked_env {
1492
+ #[ unstable( feature = "proc_macro_tracked_env" , issue = "74690" ) ]
1493
+ /// Tracked access to env and path.
1494
+ pub mod tracked {
1495
+ #[ unstable( feature = "proc_macro_tracked_path" , issue = "73921" ) ]
1496
+ use std:: path:: Path ;
1497
+
1498
+ /// Track a file as if it was a dependency.
1499
+ ///
1500
+ /// The file is located relative to the current file where the proc-macro
1501
+ /// is used (similarly to how modules are found). The provided path is
1502
+ /// interpreted in a platform-specific way at compile time. So, for
1503
+ /// instance, an invocation with a Windows path
1504
+ /// containing backslashes `\` would not compile correctly on Unix.
1505
+ ///
1506
+ /// Errors if the provided `Path` cannot be encoded as a `str`
1507
+ ///
1508
+ /// Commonly used for tracking asset preprocessing.
1509
+ #[ unstable( feature = "proc_macro_tracked_path" , issue = "73921" ) ]
1510
+ pub fn path < P : AsRef < Path > > ( path : P ) -> Result < ( ) , ( ) > {
1511
+ let path: & Path = path. as_ref ( ) ;
1512
+ if let Some ( path) = path. to_str ( ) {
1513
+ crate :: bridge:: client:: FreeFunctions :: track_fs_path ( path) ;
1514
+ Ok ( ( ) )
1515
+ } else {
1516
+ Err ( ( ) )
1517
+ }
1518
+ }
1519
+
1495
1520
use std:: env:: { self , VarError } ;
1496
1521
use std:: ffi:: OsStr ;
1497
1522
@@ -1500,25 +1525,11 @@ pub mod tracked_env {
1500
1525
/// compilation, and will be able to rerun the build when the value of that variable changes.
1501
1526
/// Besides the dependency tracking this function should be equivalent to `env::var` from the
1502
1527
/// standard library, except that the argument must be UTF-8.
1503
- #[ unstable( feature = "proc_macro_tracked_env" , issue = "99515 " ) ]
1504
- pub fn var < K : AsRef < OsStr > + AsRef < str > > ( key : K ) -> Result < String , VarError > {
1528
+ #[ unstable( feature = "proc_macro_tracked_env" , issue = "74690 " ) ]
1529
+ pub fn env_var < K : AsRef < OsStr > + AsRef < str > > ( key : K ) -> Result < String , VarError > {
1505
1530
let key: & str = key. as_ref ( ) ;
1506
1531
let value = env:: var ( key) ;
1507
1532
crate :: bridge:: client:: FreeFunctions :: track_env_var ( key, value. as_deref ( ) . ok ( ) ) ;
1508
1533
value
1509
1534
}
1510
1535
}
1511
-
1512
- /// Tracked access to additional files.
1513
- #[ unstable( feature = "track_path" , issue = "99515" ) ]
1514
- pub mod tracked_path {
1515
-
1516
- /// Track a file explicitly.
1517
- ///
1518
- /// Commonly used for tracking asset preprocessing.
1519
- #[ unstable( feature = "track_path" , issue = "99515" ) ]
1520
- pub fn path < P : AsRef < str > > ( path : P ) {
1521
- let path: & str = path. as_ref ( ) ;
1522
- crate :: bridge:: client:: FreeFunctions :: track_path ( path) ;
1523
- }
1524
- }
0 commit comments