From 3cac3de200a99ed29583ce95705696e4b4782c76 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Fri, 6 Oct 2023 08:35:45 -0400 Subject: [PATCH] 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. --- compiler/rustc_metadata/src/creader.rs | 5 +++-- 1 file 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::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::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, @@ -677,7 +678,7 @@ fn dlsym_proc_macros( 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);