Skip to content

Commit 54a2945

Browse files
committed
remove result, use PathBuf
1 parent a46a7ba commit 54a2945

File tree

6 files changed

+11
-15
lines changed

6 files changed

+11
-15
lines changed

compiler/rustc_expand/src/proc_macro_server.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,8 @@ impl server::FreeFunctions for Rustc<'_, '_> {
402402
.insert((Symbol::intern(var), value.map(Symbol::intern)));
403403
}
404404

405-
fn track_path(&mut self, path: &str) {
406-
self.sess().file_depinfo.borrow_mut().insert(Symbol::intern(path));
405+
fn track_path(&mut self, path: std::path::PathBuf) {
406+
self.sess().file_depinfo.borrow_mut().insert(path);
407407
}
408408

409409
fn literal_from_str(&mut self, s: &str) -> Result<Literal<Self::Span, Self::Symbol>, ()> {

compiler/rustc_interface/src/passes.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -476,13 +476,12 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
476476
// (e.g. accessed in proc macros).
477477
let file_depinfo = sess.parse_sess.file_depinfo.borrow();
478478

479-
let normalize_path = |path: PathBuf| {
479+
let normalize_path = |path: PathBuf| -> String {
480480
let file = FileName::from(path);
481481
escape_dep_filename(&file.prefer_local().to_string())
482482
};
483483

484-
let extra_tracked_files =
485-
file_depinfo.iter().map(|path_sym| normalize_path(PathBuf::from(path_sym.as_str())));
484+
let extra_tracked_files = file_depinfo.iter().map(|path| normalize_path(path.to_owned()));
486485
files.extend(extra_tracked_files);
487486

488487
// We also need to track used PGO profile files

compiler/rustc_session/src/parse.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ pub struct ParseSess {
209209
/// Environment variables accessed during the build and their values when they exist.
210210
pub env_depinfo: Lock<FxHashSet<(Symbol, Option<Symbol>)>>,
211211
/// File paths accessed during the build.
212-
pub file_depinfo: Lock<FxHashSet<Symbol>>,
212+
/// Paths are relative to ???.
213+
pub file_depinfo: Lock<FxHashSet<std::path::PathBuf>>,
213214
/// Whether cfg(version) should treat the current release as incomplete
214215
pub assume_incomplete_release: bool,
215216
/// Spans passed to `proc_macro::quote_span`. Each span has a numerical

library/proc_macro/src/bridge/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ macro_rules! with_api {
5757
FreeFunctions {
5858
fn drop($self: $S::FreeFunctions);
5959
fn track_env_var(var: &str, value: Option<&str>);
60-
fn track_path(path: &str);
60+
fn track_path(path: std::path::PathBuf);
6161
fn literal_from_str(s: &str) -> Result<Literal<$S::Span, $S::Symbol>, ()>;
6262
fn emit_diagnostic(diagnostic: Diagnostic<$S::Span>);
6363
},

library/proc_macro/src/lib.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -1476,18 +1476,14 @@ pub mod tracked {
14761476
///
14771477
/// Commonly used for tracking asset preprocessing.
14781478
#[unstable(feature = "proc_macro_tracked_path", issue = "73921")]
1479-
pub fn path<P: AsRef<Path>>(path: P) -> Result<(), ()> {
1479+
pub fn path<P: AsRef<Path>>(path: P) {
14801480
let path: &Path = path.as_ref();
1481-
if let Some(path) = path.to_str() {
1482-
crate::bridge::client::FreeFunctions::track_path(path);
1483-
Ok(())
1484-
} else {
1485-
Err(())
1486-
}
1481+
crate::bridge::client::FreeFunctions::track_path(PathBuf::from(path));
14871482
}
14881483

14891484
use std::env::{self, VarError};
14901485
use std::ffi::OsStr;
1486+
use std::path::PathBuf;
14911487

14921488
/// Retrieve an environment variable and add it to build dependency info.
14931489
/// The build system executing the compiler will know that the variable was accessed during

src/tools/rust-analyzer/crates/proc-macro-srv/src/server.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl server::FreeFunctions for RustAnalyzer {
5555
// FIXME: track env var accesses
5656
// https://github.com/rust-lang/rust/pull/71858
5757
}
58-
fn track_path(&mut self, _path: &str) {}
58+
fn track_path(&mut self, _path: std::path::PathBuf) {}
5959

6060
fn literal_from_str(
6161
&mut self,

0 commit comments

Comments
 (0)