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.
This commit is contained in:
Tamir Duberstein 2023-10-06 08:35:45 -04:00
parent 5aeb6a326f
commit 3cac3de200
No known key found for this signature in database

View file

@ -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<MetadataLoaderDyn>,
@ -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);