v0: demangle ADT const values.
diff --git a/src/v0.rs b/src/v0.rs
index a98c0b3..3e88fa6 100644
--- a/src/v0.rs
+++ b/src/v0.rs
@@ -1167,6 +1167,33 @@
}
self.print(")")?;
}
+ b'V' => {
+ open_brace_if_outside_expr(self)?;
+ self.print_path(true)?;
+ match parse!(self, next) {
+ b'U' => {}
+ b'T' => {
+ self.print("(")?;
+ self.print_sep_list(|this| this.print_const(true), ", ")?;
+ self.print(")")?;
+ }
+ b'S' => {
+ self.print(" { ")?;
+ self.print_sep_list(
+ |this| {
+ parse!(this, disambiguator);
+ let name = parse!(this, ident);
+ this.print(name)?;
+ this.print(": ")?;
+ this.print_const(true)
+ },
+ ", ",
+ )?;
+ self.print(" }")?;
+ }
+ _ => invalid!(self),
+ }
+ }
b'B' => {
self.print_backref(|this| this.print_const(in_value))?;
}
@@ -1379,6 +1406,22 @@
}
#[test]
+ fn demangle_const_adt() {
+ t_const!(
+ "VNvINtNtC4core6option6OptionjE4NoneU",
+ "{core::option::Option::<usize>::None}"
+ );
+ t_const!(
+ "VNvINtNtC4core6option6OptionjE4SomeTj0_E",
+ "{core::option::Option::<usize>::Some(0)}"
+ );
+ t_const!(
+ "VNtC3foo3BarS1sRe616263_2chc78_5sliceRAh1_h2_h3_EE",
+ "{foo::Bar { s: \"abc\", ch: 'x', slice: &[1, 2, 3] }}"
+ );
+ }
+
+ #[test]
fn demangle_exponential_explosion() {
// NOTE(eddyb) because of the prefix added by `t_nohash_type!` is
// 3 bytes long, `B2_` refers to the start of the type, not `B_`.