Skip to content

Commit c8aaec5

Browse files
committed
remove result, use PathBuf
1 parent 14eccf6 commit c8aaec5

File tree

6 files changed

+11
-15
lines changed

6 files changed

+11
-15
lines changed

compiler/rustc_expand/src/proc_macro_server.rs

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,13 +469,12 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
469469
// (e.g. accessed in proc macros).
470470
let file_depinfo = sess.parse_sess.file_depinfo.borrow();
471471

472-
let normalize_path = |path: PathBuf| {
472+
let normalize_path = |path: PathBuf| -> String {
473473
let file = FileName::from(path);
474474
escape_dep_filename(&file.prefer_local().to_string())
475475
};
476476

477-
let extra_tracked_files =
478-
file_depinfo.iter().map(|path_sym| normalize_path(PathBuf::from(path_sym.as_str())));
477+
let extra_tracked_files = file_depinfo.iter().map(|path| normalize_path(path.to_owned()));
479478
files.extend(extra_tracked_files);
480479

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

compiler/rustc_session/src/parse.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ pub struct ParseSess {
214214
/// Environment variables accessed during the build and their values when they exist.
215215
pub env_depinfo: Lock<FxHashSet<(Symbol, Option<Symbol>)>>,
216216
/// File paths accessed during the build.
217-
pub file_depinfo: Lock<FxHashSet<Symbol>>,
217+
/// Paths are relative to ???.
218+
pub file_depinfo: Lock<FxHashSet<std::path::PathBuf>>,
218219
/// Whether cfg(version) should treat the current release as incomplete
219220
pub assume_incomplete_release: bool,
220221
/// Spans passed to `proc_macro::quote_span`. Each span has a numerical

library/proc_macro/src/bridge/mod.rs

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,18 +1507,14 @@ pub mod tracked {
15071507
///
15081508
/// Commonly used for tracking asset preprocessing.
15091509
#[unstable(feature = "proc_macro_tracked_path", issue = "73921")]
1510-
pub fn path<P: AsRef<Path>>(path: P) -> Result<(), ()> {
1510+
pub fn path<P: AsRef<Path>>(path: P) {
15111511
let path: &Path = path.as_ref();
1512-
if let Some(path) = path.to_str() {
1513-
crate::bridge::client::FreeFunctions::track_path(path);
1514-
Ok(())
1515-
} else {
1516-
Err(())
1517-
}
1512+
crate::bridge::client::FreeFunctions::track_path(PathBuf::from(path));
15181513
}
15191514

15201515
use std::env::{self, VarError};
15211516
use std::ffi::OsStr;
1517+
use std::path::PathBuf;
15221518

15231519
/// Retrieve an environment variable and add it to build dependency info.
15241520
/// 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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl server::FreeFunctions for RustAnalyzer {
5858
// FIXME: track env var accesses
5959
// https://github.com/rust-lang/rust/pull/71858
6060
}
61-
fn track_path(&mut self, _path: &str) {}
61+
fn track_path(&mut self, _path: std::path::PathBuf) {}
6262

6363
fn literal_from_str(
6464
&mut self,

0 commit comments

Comments
 (0)