aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_proc_macro_srv/src/dylib.rs14
-rw-r--r--crates/ra_proc_macro_srv/src/lib.rs2
2 files changed, 8 insertions, 8 deletions
diff --git a/crates/ra_proc_macro_srv/src/dylib.rs b/crates/ra_proc_macro_srv/src/dylib.rs
index f7a86a532..d202eb0fd 100644
--- a/crates/ra_proc_macro_srv/src/dylib.rs
+++ b/crates/ra_proc_macro_srv/src/dylib.rs
@@ -17,7 +17,7 @@ fn invalid_data_err(e: impl Into<Box<dyn std::error::Error + Send + Sync>>) -> i
17 io::Error::new(io::ErrorKind::InvalidData, e) 17 io::Error::new(io::ErrorKind::InvalidData, e)
18} 18}
19 19
20fn is_derive_registrar_symbol(symbol: &&str) -> bool { 20fn is_derive_registrar_symbol(symbol: &str) -> bool {
21 symbol.contains(NEW_REGISTRAR_SYMBOL) 21 symbol.contains(NEW_REGISTRAR_SYMBOL)
22} 22}
23 23
@@ -29,13 +29,13 @@ fn find_registrar_symbol(file: &Path) -> io::Result<Option<String>> {
29 let name = match object { 29 let name = match object {
30 Object::Elf(elf) => { 30 Object::Elf(elf) => {
31 let symbols = elf.dynstrtab.to_vec().map_err(invalid_data_err)?; 31 let symbols = elf.dynstrtab.to_vec().map_err(invalid_data_err)?;
32 symbols.into_iter().find(is_derive_registrar_symbol).map(&str::to_owned) 32 symbols.into_iter().find(|s| is_derive_registrar_symbol(s)).map(&str::to_owned)
33 } 33 }
34 Object::PE(pe) => pe 34 Object::PE(pe) => pe
35 .exports 35 .exports
36 .iter() 36 .iter()
37 .flat_map(|s| s.name) 37 .flat_map(|s| s.name)
38 .find(is_derive_registrar_symbol) 38 .find(|s| is_derive_registrar_symbol(s))
39 .map(&str::to_owned), 39 .map(&str::to_owned),
40 Object::Mach(Mach::Binary(binary)) => { 40 Object::Mach(Mach::Binary(binary)) => {
41 let exports = binary.exports().map_err(invalid_data_err)?; 41 let exports = binary.exports().map_err(invalid_data_err)?;
@@ -52,12 +52,12 @@ fn find_registrar_symbol(file: &Path) -> io::Result<Option<String>> {
52 &s.name 52 &s.name
53 } 53 }
54 }) 54 })
55 .find(is_derive_registrar_symbol) 55 .find(|s| is_derive_registrar_symbol(s))
56 .map(&str::to_owned) 56 .map(&str::to_owned)
57 } 57 }
58 _ => return Ok(None), 58 _ => return Ok(None),
59 }; 59 };
60 Ok(name) 60 return Ok(name);
61} 61}
62 62
63/// Loads dynamic library in platform dependent manner. 63/// Loads dynamic library in platform dependent manner.
@@ -95,7 +95,7 @@ struct ProcMacroLibraryLibloading {
95impl ProcMacroLibraryLibloading { 95impl ProcMacroLibraryLibloading {
96 fn open(file: &Path) -> io::Result<Self> { 96 fn open(file: &Path) -> io::Result<Self> {
97 let symbol_name = find_registrar_symbol(file)?.ok_or_else(|| { 97 let symbol_name = find_registrar_symbol(file)?.ok_or_else(|| {
98 invalid_data_err(format!("Cannot find registrar symbol in file {:?}", file)) 98 invalid_data_err(format!("Cannot find registrar symbol in file {}", file.display()))
99 })?; 99 })?;
100 100
101 let lib = load_library(file).map_err(invalid_data_err)?; 101 let lib = load_library(file).map_err(invalid_data_err)?;
@@ -121,7 +121,7 @@ impl Expander {
121 // already absolute 121 // already absolute
122 let lib = lib 122 let lib = lib
123 .canonicalize() 123 .canonicalize()
124 .unwrap_or_else(|err| panic!("Cannot canonicalize {:?}: {:?}", lib, err)); 124 .unwrap_or_else(|err| panic!("Cannot canonicalize {}: {:?}", lib.display(), err));
125 125
126 let library = ProcMacroLibraryImpl::open(&lib).map_err(|e| e.to_string())?; 126 let library = ProcMacroLibraryImpl::open(&lib).map_err(|e| e.to_string())?;
127 127
diff --git a/crates/ra_proc_macro_srv/src/lib.rs b/crates/ra_proc_macro_srv/src/lib.rs
index 178458703..f64e05a2d 100644
--- a/crates/ra_proc_macro_srv/src/lib.rs
+++ b/crates/ra_proc_macro_srv/src/lib.rs
@@ -42,7 +42,7 @@ pub(crate) fn list_macros(task: &ListMacrosTask) -> ListMacrosResult {
42 42
43fn create_expander(lib: &Path) -> dylib::Expander { 43fn create_expander(lib: &Path) -> dylib::Expander {
44 dylib::Expander::new(lib) 44 dylib::Expander::new(lib)
45 .unwrap_or_else(|err| panic!("Cannot create expander for {}: {}", lib.display(), err)) 45 .unwrap_or_else(|err| panic!("Cannot create expander for {}: {:?}", lib.display(), err))
46} 46}
47 47
48pub mod cli; 48pub mod cli;