about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTamir Duberstein <tamird@gmail.com>2023-10-06 08:35:45 -0400
committerTamir Duberstein <tamird@gmail.com>2023-10-06 09:54:12 -0400
commit3cac3de200a99ed29583ce95705696e4b4782c76 (patch)
tree6c14b1cbc38f9120afac5b00aeaac1001a8403a5
parent5aeb6a326f2fa941061b60c9286665847fe0401e (diff)
downloadrust-3cac3de200a99ed29583ce95705696e4b4782c76.tar.gz
rust-3cac3de200a99ed29583ce95705696e4b4782c76.zip
rustc_metadata: use try_canonicalize
This is simpler and avoids unnecessary calls to `env::current_dir`.

rustc_plugin is left unchanged to avoid conflicts with #116412.

Updates #116426.
-rw-r--r--compiler/rustc_metadata/src/creader.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/rustc_metadata/src/creader.rs b/compiler/rustc_metadata/src/creader.rs
index 69221475356..14bbe65d5f1 100644
--- a/compiler/rustc_metadata/src/creader.rs
+++ b/compiler/rustc_metadata/src/creader.rs
@@ -10,6 +10,7 @@ use rustc_data_structures::fx::FxHashSet;
 use rustc_data_structures::svh::Svh;
 use rustc_data_structures::sync::{FreezeReadGuard, FreezeWriteGuard};
 use rustc_expand::base::SyntaxExtension;
+use rustc_fs_util::try_canonicalize;
 use rustc_hir::def_id::{CrateNum, LocalDefId, StableCrateId, StableCrateIdMap, LOCAL_CRATE};
 use rustc_hir::definitions::Definitions;
 use rustc_index::IndexVec;
@@ -31,7 +32,7 @@ use std::error::Error;
 use std::ops::Fn;
 use std::path::Path;
 use std::time::Duration;
-use std::{cmp, env, iter};
+use std::{cmp, iter};
 
 pub struct CStore {
     metadata_loader: Box<MetadataLoaderDyn>,
@@ -677,7 +678,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
         stable_crate_id: StableCrateId,
     ) -> Result<&'static [ProcMacro], CrateError> {
         // Make sure the path contains a / or the linker will search for it.
-        let path = env::current_dir().unwrap().join(path);
+        let path = try_canonicalize(path).unwrap();
         let lib = load_dylib(&path, 5).map_err(|err| CrateError::DlOpen(err))?;
 
         let sym_name = self.sess.generate_proc_macro_decls_symbol(stable_crate_id);