Skip to content

Commit 666ba7f

Browse files
committed
Add support for demangling !
Closes #22
1 parent 6cee293 commit 666ba7f

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/lib.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ impl<'a> fmt::Display for Demangle<'a> {
283283
}
284284
} else if rest.starts_with('$') {
285285
macro_rules! demangle {
286-
($($pat:expr => $demangled:expr),*) => ({
286+
($($pat:expr => $demangled:expr,)*) => ({
287287
$(if rest.starts_with($pat) {
288288
try!(f.write_str($demangled));
289289
rest = &rest[$pat.len()..];
@@ -319,7 +319,8 @@ impl<'a> fmt::Display for Demangle<'a> {
319319
"$u7d$" => "}",
320320
"$u3b$" => ";",
321321
"$u2b$" => "+",
322-
"$u22$" => "\""
322+
"$u21$" => "!",
323+
"$u22$" => "\"",
323324
}
324325
} else {
325326
let idx = match rest.char_indices().find(|&(_, c)| c == '$' || c == '.') {
@@ -364,7 +365,14 @@ mod tests {
364365

365366
fn ok(sym: &str, expected: &str) -> bool {
366367
match super::try_demangle(sym) {
367-
Ok(s) => s.to_string() == expected,
368+
Ok(s) => {
369+
if s.to_string() == expected {
370+
true
371+
} else {
372+
println!("\n{}\n!=\n{}\n", s, expected);
373+
false
374+
}
375+
}
368376
Err(_) => {
369377
println!("error demangling");
370378
false
@@ -498,4 +506,12 @@ mod tests {
498506
fn handle_assoc_types() {
499507
t!("_ZN151_$LT$alloc..boxed..Box$LT$alloc..boxed..FnBox$LT$A$C$$u20$Output$u3d$R$GT$$u20$$u2b$$u20$$u27$a$GT$$u20$as$u20$core..ops..function..FnOnce$LT$A$GT$$GT$9call_once17h69e8f44b3723e1caE", "<alloc::boxed::Box<alloc::boxed::FnBox<A, Output=R> + 'a> as core::ops::function::FnOnce<A>>::call_once::h69e8f44b3723e1ca");
500508
}
509+
510+
#[test]
511+
fn handle_bang() {
512+
t!(
513+
"_ZN88_$LT$core..result..Result$LT$$u21$$C$$u20$E$GT$$u20$as$u20$std..process..Termination$GT$6report17hfc41d0da4a40b3e8E",
514+
"<core::result::Result<!, E> as std::process::Termination>::report::hfc41d0da4a40b3e8"
515+
);
516+
}
501517
}

0 commit comments

Comments
 (0)