mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
Display path not debug it
Co-Authored-By: Laurențiu Nicola <lnicola@users.noreply.github.com>
This commit is contained in:
parent
982af2286a
commit
0f5b1fef5e
2 changed files with 8 additions and 8 deletions
|
@ -17,7 +17,7 @@ fn invalid_data_err(e: impl Into<Box<dyn std::error::Error + Send + Sync>>) -> i
|
||||||
io::Error::new(io::ErrorKind::InvalidData, e)
|
io::Error::new(io::ErrorKind::InvalidData, e)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_derive_registrar_symbol(symbol: &&str) -> bool {
|
fn is_derive_registrar_symbol(symbol: &str) -> bool {
|
||||||
symbol.contains(NEW_REGISTRAR_SYMBOL)
|
symbol.contains(NEW_REGISTRAR_SYMBOL)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,13 +29,13 @@ fn find_registrar_symbol(file: &Path) -> io::Result<Option<String>> {
|
||||||
let name = match object {
|
let name = match object {
|
||||||
Object::Elf(elf) => {
|
Object::Elf(elf) => {
|
||||||
let symbols = elf.dynstrtab.to_vec().map_err(invalid_data_err)?;
|
let symbols = elf.dynstrtab.to_vec().map_err(invalid_data_err)?;
|
||||||
symbols.into_iter().find(is_derive_registrar_symbol).map(&str::to_owned)
|
symbols.into_iter().find(|s| is_derive_registrar_symbol(s)).map(&str::to_owned)
|
||||||
}
|
}
|
||||||
Object::PE(pe) => pe
|
Object::PE(pe) => pe
|
||||||
.exports
|
.exports
|
||||||
.iter()
|
.iter()
|
||||||
.flat_map(|s| s.name)
|
.flat_map(|s| s.name)
|
||||||
.find(is_derive_registrar_symbol)
|
.find(|s| is_derive_registrar_symbol(s))
|
||||||
.map(&str::to_owned),
|
.map(&str::to_owned),
|
||||||
Object::Mach(Mach::Binary(binary)) => {
|
Object::Mach(Mach::Binary(binary)) => {
|
||||||
let exports = binary.exports().map_err(invalid_data_err)?;
|
let exports = binary.exports().map_err(invalid_data_err)?;
|
||||||
|
@ -52,12 +52,12 @@ fn find_registrar_symbol(file: &Path) -> io::Result<Option<String>> {
|
||||||
&s.name
|
&s.name
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.find(is_derive_registrar_symbol)
|
.find(|s| is_derive_registrar_symbol(s))
|
||||||
.map(&str::to_owned)
|
.map(&str::to_owned)
|
||||||
}
|
}
|
||||||
_ => return Ok(None),
|
_ => return Ok(None),
|
||||||
};
|
};
|
||||||
Ok(name)
|
return Ok(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Loads dynamic library in platform dependent manner.
|
/// Loads dynamic library in platform dependent manner.
|
||||||
|
@ -95,7 +95,7 @@ struct ProcMacroLibraryLibloading {
|
||||||
impl ProcMacroLibraryLibloading {
|
impl ProcMacroLibraryLibloading {
|
||||||
fn open(file: &Path) -> io::Result<Self> {
|
fn open(file: &Path) -> io::Result<Self> {
|
||||||
let symbol_name = find_registrar_symbol(file)?.ok_or_else(|| {
|
let symbol_name = find_registrar_symbol(file)?.ok_or_else(|| {
|
||||||
invalid_data_err(format!("Cannot find registrar symbol in file {:?}", file))
|
invalid_data_err(format!("Cannot find registrar symbol in file {}", file.display()))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let lib = load_library(file).map_err(invalid_data_err)?;
|
let lib = load_library(file).map_err(invalid_data_err)?;
|
||||||
|
@ -121,7 +121,7 @@ impl Expander {
|
||||||
// already absolute
|
// already absolute
|
||||||
let lib = lib
|
let lib = lib
|
||||||
.canonicalize()
|
.canonicalize()
|
||||||
.unwrap_or_else(|err| panic!("Cannot canonicalize {:?}: {:?}", lib, err));
|
.unwrap_or_else(|err| panic!("Cannot canonicalize {}: {:?}", lib.display(), err));
|
||||||
|
|
||||||
let library = ProcMacroLibraryImpl::open(&lib).map_err(|e| e.to_string())?;
|
let library = ProcMacroLibraryImpl::open(&lib).map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ pub(crate) fn list_macros(task: &ListMacrosTask) -> ListMacrosResult {
|
||||||
|
|
||||||
fn create_expander(lib: &Path) -> dylib::Expander {
|
fn create_expander(lib: &Path) -> dylib::Expander {
|
||||||
dylib::Expander::new(lib)
|
dylib::Expander::new(lib)
|
||||||
.unwrap_or_else(|err| panic!("Cannot create expander for {}: {}", lib.display(), err))
|
.unwrap_or_else(|err| panic!("Cannot create expander for {}: {:?}", lib.display(), err))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod cli;
|
pub mod cli;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue