@@ -11,7 +11,7 @@ use rustc_span::symbol::{sym, Ident};
11
11
12
12
use std:: env;
13
13
use std:: mem;
14
- use std:: path:: PathBuf ;
14
+ use std:: path:: Path ;
15
15
16
16
/// Pointer to a registrar function.
17
17
type PluginRegistrarFn = fn ( & mut Registry < ' _ > ) ;
@@ -51,7 +51,7 @@ fn load_plugin(
51
51
ident : Ident ,
52
52
) {
53
53
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| {
55
55
// This is fatal: there are almost certainly macros we need inside this crate, so
56
56
// continuing would spew "macro undefined" errors.
57
57
sess. emit_fatal ( LoadPluginError { span : ident. span , msg : err. to_string ( ) } ) ;
@@ -60,11 +60,19 @@ fn load_plugin(
60
60
}
61
61
62
62
/// 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 > {
64
64
// 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
+ } ;
66
74
67
- let lib = unsafe { Library :: new ( & lib_path) } ?;
75
+ let lib = unsafe { Library :: new ( lib_path) } ?;
68
76
69
77
let registrar_sym = unsafe { lib. get :: < PluginRegistrarFn > ( b"__rustc_plugin_registrar" ) } ?;
70
78
0 commit comments