@@ -20,7 +20,7 @@ use rustc::hir::map::Definitions;
2020use rustc:: hir:: def_id:: LOCAL_CRATE ;
2121
2222use std:: ops:: Deref ;
23- use std:: path:: PathBuf ;
23+ use std:: path:: { Path , PathBuf } ;
2424use std:: { cmp, fs} ;
2525
2626use syntax:: ast;
@@ -229,13 +229,14 @@ impl<'a> CrateLoader<'a> {
229229 let dependencies: Vec < CrateNum > = cnum_map. iter ( ) . cloned ( ) . collect ( ) ;
230230
231231 let raw_proc_macros = crate_root. proc_macro_data . map ( |_| {
232- if self . sess . opts . debugging_opts . dual_proc_macros {
233- let host_lib = host_lib. as_ref ( ) . unwrap ( ) ;
234- self . dlsym_proc_macros ( host_lib. dylib . as_ref ( ) . map ( |p| p. 0 . clone ( ) ) ,
235- & host_lib. metadata . get_root ( ) , span)
236- } else {
237- self . dlsym_proc_macros ( dylib. clone ( ) . map ( |p| p. 0 ) , & crate_root, span)
238- }
232+ let temp_root;
233+ let ( dlsym_dylib, dlsym_root) = match & host_lib {
234+ Some ( host_lib) =>
235+ ( & host_lib. dylib , { temp_root = host_lib. metadata . get_root ( ) ; & temp_root } ) ,
236+ None => ( & dylib, & crate_root) ,
237+ } ;
238+ let dlsym_dylib = dlsym_dylib. as_ref ( ) . expect ( "no dylib for a proc-macro crate" ) ;
239+ self . dlsym_proc_macros ( & dlsym_dylib. 0 , dlsym_root. disambiguator , span)
239240 } ) ;
240241
241242 let interpret_alloc_index: Vec < u32 > = crate_root. interpret_alloc_index
@@ -567,25 +568,21 @@ impl<'a> CrateLoader<'a> {
567568 }
568569
569570 fn dlsym_proc_macros ( & self ,
570- dylib : Option < PathBuf > ,
571- root : & CrateRoot < ' _ > ,
571+ path : & Path ,
572+ disambiguator : CrateDisambiguator ,
572573 span : Span
573574 ) -> & ' static [ ProcMacro ] {
574575 use std:: env;
575576 use crate :: dynamic_lib:: DynamicLibrary ;
576577
577- let path = match dylib {
578- Some ( dylib) => dylib,
579- None => span_bug ! ( span, "proc-macro crate not dylib" ) ,
580- } ;
581578 // Make sure the path contains a / or the linker will search for it.
582579 let path = env:: current_dir ( ) . unwrap ( ) . join ( path) ;
583580 let lib = match DynamicLibrary :: open ( Some ( & path) ) {
584581 Ok ( lib) => lib,
585582 Err ( err) => self . sess . span_fatal ( span, & err) ,
586583 } ;
587584
588- let sym = self . sess . generate_proc_macro_decls_symbol ( root . disambiguator ) ;
585+ let sym = self . sess . generate_proc_macro_decls_symbol ( disambiguator) ;
589586 let decls = unsafe {
590587 let sym = match lib. symbol ( & sym) {
591588 Ok ( f) => f,
0 commit comments