Skip to content

Commit 3cac3de

Browse files
committed
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.
1 parent 5aeb6a3 commit 3cac3de

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

compiler/rustc_metadata/src/creader.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use rustc_data_structures::fx::FxHashSet;
1010
use rustc_data_structures::svh::Svh;
1111
use rustc_data_structures::sync::{FreezeReadGuard, FreezeWriteGuard};
1212
use rustc_expand::base::SyntaxExtension;
13+
use rustc_fs_util::try_canonicalize;
1314
use rustc_hir::def_id::{CrateNum, LocalDefId, StableCrateId, StableCrateIdMap, LOCAL_CRATE};
1415
use rustc_hir::definitions::Definitions;
1516
use rustc_index::IndexVec;
@@ -31,7 +32,7 @@ use std::error::Error;
3132
use std::ops::Fn;
3233
use std::path::Path;
3334
use std::time::Duration;
34-
use std::{cmp, env, iter};
35+
use std::{cmp, iter};
3536

3637
pub struct CStore {
3738
metadata_loader: Box<MetadataLoaderDyn>,
@@ -677,7 +678,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
677678
stable_crate_id: StableCrateId,
678679
) -> Result<&'static [ProcMacro], CrateError> {
679680
// Make sure the path contains a / or the linker will search for it.
680-
let path = env::current_dir().unwrap().join(path);
681+
let path = try_canonicalize(path).unwrap();
681682
let lib = load_dylib(&path, 5).map_err(|err| CrateError::DlOpen(err))?;
682683

683684
let sym_name = self.sess.generate_proc_macro_decls_symbol(stable_crate_id);

0 commit comments

Comments
 (0)