Skip to content

Commit c1eeee6

Browse files
committed
v0: also support preserving extra suffixes found after mangled symbol.
1 parent 23654c7 commit c1eeee6

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

src/v0.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,18 @@ pub fn demangle(s: &str) -> Result<(Demangle, &str), Invalid> {
4747
next: 0,
4848
};
4949
try!(parser.skip_path());
50-
if parser.next < parser.sym.len() {
51-
// Instantiating crate.
52-
try!(parser.skip_path());
53-
}
54-
if parser.next != parser.sym.len() {
55-
return Err(Invalid);
50+
51+
// Instantiating crate (paths always start with uppercase characters).
52+
match parser.sym.as_bytes().get(parser.next) {
53+
Some(&b'A'...b'Z') => {
54+
try!(parser.skip_path());
55+
}
56+
_ => {}
5657
}
5758

5859
Ok((Demangle {
5960
inner: inner,
60-
}, ""))
61+
}, &parser.sym[parser.next..]))
6162
}
6263

6364
impl<'s> Display for Demangle<'s> {
@@ -1071,4 +1072,13 @@ mod tests {
10711072
t_nohash!("_RC3foo.llvm.9D1C9369@@16", "foo");
10721073
t_nohash!("_RNvC9backtrace3foo.llvm.A5310EB9", "backtrace::foo");
10731074
}
1075+
1076+
#[test]
1077+
fn demangle_extra_suffix() {
1078+
// From alexcrichton/rustc-demangle#27:
1079+
t_nohash!(
1080+
"_RNvNtNtNtNtCs92dm3009vxr_4rand4rngs7adapter9reseeding4fork23FORK_HANDLER_REGISTERED.0.0",
1081+
"rand::rngs::adapter::reseeding::fork::FORK_HANDLER_REGISTERED.0.0"
1082+
);
1083+
}
10741084
}

0 commit comments

Comments
 (0)