@@ -11,7 +11,7 @@ use rustc_span::symbol::{sym, Ident};
1111
1212use std:: env;
1313use std:: mem;
14- use std:: path:: PathBuf ;
14+ use std:: path:: Path ;
1515
1616/// Pointer to a registrar function.
1717type PluginRegistrarFn = fn ( & mut Registry < ' _ > ) ;
@@ -51,7 +51,7 @@ fn load_plugin(
5151 ident : Ident ,
5252) {
5353 let lib = locator:: find_plugin_registrar ( sess, metadata_loader, ident. span , ident. name ) ;
54- let fun = dylink_registrar ( lib) . unwrap_or_else ( |err| {
54+ let fun = dylink_registrar ( & lib) . unwrap_or_else ( |err| {
5555 // This is fatal: there are almost certainly macros we need inside this crate, so
5656 // continuing would spew "macro undefined" errors.
5757 sess. emit_fatal ( LoadPluginError { span : ident. span , msg : err. to_string ( ) } ) ;
@@ -60,11 +60,19 @@ fn load_plugin(
6060}
6161
6262/// Dynamically link a registrar function into the compiler process.
63- fn dylink_registrar ( lib_path : PathBuf ) -> Result < PluginRegistrarFn , libloading:: Error > {
63+ fn dylink_registrar ( lib_path : & Path ) -> Result < PluginRegistrarFn , libloading:: Error > {
6464 // Make sure the path contains a / or the linker will search for it.
65- let lib_path = env:: current_dir ( ) . unwrap ( ) . join ( & lib_path) ;
65+ //
66+ // FIXME(https://github.com/rust-lang/rust/issues/92750): use std::path::absolute.
67+ let buf;
68+ let lib_path = if lib_path. is_absolute ( ) {
69+ lib_path
70+ } else {
71+ buf = env:: current_dir ( ) . unwrap ( ) . join ( lib_path) ;
72+ & buf
73+ } ;
6674
67- let lib = unsafe { Library :: new ( & lib_path) } ?;
75+ let lib = unsafe { Library :: new ( lib_path) } ?;
6876
6977 let registrar_sym = unsafe { lib. get :: < PluginRegistrarFn > ( b"__rustc_plugin_registrar" ) } ?;
7078
0 commit comments