Don’t forward demangling errors in Display impl#296
Conversation
|
Can you provide a testcase that shows the issue you're talking about? I don't think I understand the problem. |
|
Yeah, I should have really provided that. Apologies. I dug through the WebAssembly file that triggered the problem for me, and the problematic function name in this case was pub fn main() {
let func_name = "RD4";
let sym = cpp_demangle::Symbol::new(func_name).expect("new");
// sym.demangle(&Default::default()) // <- would return an error
println!("{}", sym);
}The program above will panic with the following message: As stated in the docs of
So even if demanging fails, |
|
Ok, thanks. Looks like this assertion was added in rust-lang/rust#125012 |
|
We decided to get rid of the Display impl entirely so this PR has been obsoleted. |
In the
Displayimplementation ofSymbolthe potential error after demangling is turned into astd::fmt::Error.I’d like to propose to not do that, as this will lead to panics in many cases (even just a simple
format!("{my_symbol}"). This PR changes theDisplay::fmtimplementation to output"<Demangling failed>"in case where the demanging failed, avoiding the panic scenario.