Skip to content

Commit

Permalink
Update to use crate for f16/f128 and show disambiguator on non-zero (#65
Browse files Browse the repository at this point in the history
)
  • Loading branch information
wargio authored Apr 12, 2024
1 parent 498e007 commit 0031d1a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 28 deletions.
8 changes: 1 addition & 7 deletions src/rust/rust_v0.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,18 +195,12 @@ static bool rust_v0_parse_basic_type(rust_v0_t *v0, char tag) {
case 'j':
rust_v0_print(v0, "usize");
break;
case 'k':
rust_v0_print(v0, "f16");
break;
case 'f':
rust_v0_print(v0, "f32");
break;
case 'd':
rust_v0_print(v0, "f64");
break;
case 'q':
rust_v0_print(v0, "f128");
break;
case 'z': // never
rust_v0_putc(v0, '!');
break;
Expand Down Expand Up @@ -795,7 +789,7 @@ static bool rust_v0_parse_path(rust_v0_t *v0, bool is_type, bool no_trail) {
goto end;
}
rust_v0_print_substr(v0, &crate);
if (!v0->hide_disambiguator) {
if (!v0->hide_disambiguator && disambiguator) {
// https://doc.rust-lang.org/rustc/symbol-mangling/v0.html#path-crate-root
rust_v0_printf(v0, "[%" PFMT64x "]", disambiguator);
}
Expand Down
42 changes: 21 additions & 21 deletions test/test_rust.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,38 +61,38 @@ mu_demangle_tests(rust,
NULL),

// v0 mangling tests.
mu_demangle_test("_RNvC6_123foo3bar", "123foo[0]::bar"),
mu_demangle_test("_RNvC6_123foo3bar", "123foo::bar"),
mu_demangle_test("_RNCNCNgCs6DXkGYLi8lr_2cc5spawn00B5_", "cc[4d6468d6c9fd4bb3]::spawn::{closure#0}::{closure#0}"),
mu_demangle_test("_RNCINkXs25_NgCsbmNqQUJIY6D_4core5sliceINyB9_4IterhENuNgNoBb_4iter8iterator8Iterator9rpositionNCNgNpB9_6memchr7memrchrs_0E0Bb_", "<core[846817f741e54dfd]::slice::Iter<u8> as core[846817f741e54dfd]::iter::iterator::Iterator>::rposition::<core[846817f741e54dfd]::slice::memchr::memrchr::{closure#1}>::{closure#0}"),
mu_demangle_test("_RINbNbCskIICzLVDPPb_5alloc5alloc8box_freeDINbNiB4_5boxed5FnBoxuEp6OutputuEL_ECs1iopQbuBiw2_3std", "alloc[f15a878b47eb696b]::alloc::box_free::<dyn alloc[f15a878b47eb696b]::boxed::FnBox<(), Output = ()>>"),
mu_demangle_test("_RNvNtNtNtNtCs92dm3009vxr_4rand4rngs7adapter9reseeding4fork23FORK_HANDLER_REGISTERED.0.0", "rand[693ea8e72247470f]::rngs::adapter::reseeding::fork::FORK_HANDLER_REGISTERED (.0.0)"),
mu_demangle_test("_RC3foo.llvm.9D1C9369", "foo[0] (.llvm.9D1C9369)"),
mu_demangle_test("_RC3foo.llvm.9D1C9369@@16", "foo[0] (.llvm.9D1C9369@@16)"),
mu_demangle_test("_RNvC9backtrace3foo.llvm.A5310EB9", "backtrace[0]::foo (.llvm.A5310EB9)"),
mu_demangle_test("_RINtNtC3std4iter5ChainINtB2_3ZipINtNtB4_3vec8IntoItermEBt_EE", "std[0]::iter::Chain::<std[0]::iter::Zip<std[0]::vec::IntoIter<u32>, _>>"),
mu_demangle_test("_RINtNtC3std4iter5ChainINtNtC3std4iter3ZipINtNtC3std3vec8IntoItermEINtNtC3std3vec8IntoItermEEE", "std[0]::iter::Chain::<std[0]::iter::Zip<std[0]::vec::IntoIter<u32>, std[0]::vec::IntoIter<u32>>>"),
mu_demangle_test("_RC3foo.llvm.9D1C9369", "foo (.llvm.9D1C9369)"),
mu_demangle_test("_RC3foo.llvm.9D1C9369@@16", "foo (.llvm.9D1C9369@@16)"),
mu_demangle_test("_RNvC9backtrace3foo.llvm.A5310EB9", "backtrace::foo (.llvm.A5310EB9)"),
mu_demangle_test("_RINtNtC3std4iter5ChainINtB2_3ZipINtNtB4_3vec8IntoItermEBt_EE", "std::iter::Chain::<std::iter::Zip<std::vec::IntoIter<u32>, _>>"),
mu_demangle_test("_RINtNtC3std4iter5ChainINtNtC3std4iter3ZipINtNtC3std3vec8IntoItermEINtNtC3std3vec8IntoItermEEE", "std::iter::Chain::<std::iter::Zip<std::vec::IntoIter<u32>, std::vec::IntoIter<u32>>>"),
mu_demangle_test("_RINvCs1234_7mycrate3fooNvB4_3barNvBn_3bazE", "mycrate[3c1c0]::foo::<::bar, ::baz>"),
mu_demangle_test("_RINvNtC3std3mem8align_ofkE", "std[0]::mem::align_of::<f16>"),
mu_demangle_test("_RINvNtC3std3mem8align_offE", "std[0]::mem::align_of::<f32>"),
mu_demangle_test("_RINvNtC3std3mem8align_ofdE", "std[0]::mem::align_of::<f64>"),
mu_demangle_test("_RINvNtC3std3mem8align_ofqE", "std[0]::mem::align_of::<f128>"),
mu_demangle_test("_RINvNtC3std3mem8align_ofjE", "std[0]::mem::align_of::<usize>"),
mu_demangle_test("_RINvNtC3std3mem8align_ofjEC3bar", "std[0]::mem::align_of::<usize>"),
mu_demangle_test("_RINvNtC3std3mem8align_ofjEC3foo", "std[0]::mem::align_of::<usize>"),
mu_demangle_test("_RINvNtC3std3mem8align_ofNtNtC3std3mem12DiscriminantE", "std[0]::mem::align_of::<std[0]::mem::Discriminant>"),
mu_demangle_test("_RINvNtC3std3mem8align_ofQTReuEE", "std[0]::mem::align_of::<&mut (&str, ())>"),
mu_demangle_test("_RINvNtC3std3mem8align_ofRcE", "std[0]::mem::align_of::<&char>"),
mu_demangle_test("_RINxC3std3fooTNyB4_3BarBe_EBd_E", "std[0]::foo::<(::Bar, i16), u64>"),
mu_demangle_test("_RINvNtC3std3mem8align_ofC3f16E", "std::mem::align_of::<f16>"),
mu_demangle_test("_RINvNtC3std3mem8align_offE", "std::mem::align_of::<f32>"),
mu_demangle_test("_RINvNtC3std3mem8align_ofdE", "std::mem::align_of::<f64>"),
mu_demangle_test("_RINvNtC3std3mem8align_ofC4f128E", "std::mem::align_of::<f128>"),
mu_demangle_test("_RINvNtC3std3mem8align_ofjE", "std::mem::align_of::<usize>"),
mu_demangle_test("_RINvNtC3std3mem8align_ofjEC3bar", "std::mem::align_of::<usize>"),
mu_demangle_test("_RINvNtC3std3mem8align_ofjEC3foo", "std::mem::align_of::<usize>"),
mu_demangle_test("_RINvNtC3std3mem8align_ofNtNtC3std3mem12DiscriminantE", "std::mem::align_of::<std::mem::Discriminant>"),
mu_demangle_test("_RINvNtC3std3mem8align_ofQTReuEE", "std::mem::align_of::<&mut (&str, ())>"),
mu_demangle_test("_RINvNtC3std3mem8align_ofRcE", "std::mem::align_of::<&char>"),
mu_demangle_test("_RINxC3std3fooTNyB4_3BarBe_EBd_E", "std::foo::<(::Bar, i16), u64>"),
mu_demangle_test("_RNvMINtC7mycrate3FoomE3foo", NULL),
mu_demangle_test("_RNvNtCs1234_7mycrate3foo3bar", "mycrate[3c1c0]::foo::bar"),
mu_demangle_test("_RNvNtNtC7mycrateu8gdel_5qa6escher4bach", "mycrate[0]::gödel::escher::bach"),
mu_demangle_test("_RNvNtNtC7mycrateu8gdel_5qa6escher4bach", "mycrate::gödel::escher::bach"),
mu_demangle_test("_RNvNtNtCs1234_7mycrate3foo3bar3baz", "mycrate[3c1c0]::foo::bar::baz"),
mu_demangle_test("_RNvNvCs1234_7mycrate4QUUX3FOO", "mycrate[3c1c0]::QUUX::FOO"),
mu_demangle_test("_RNvNvMCs1234_7mycrateINtCs1234_7mycrate3FoopE3bar4QUUX", "<mycrate[3c1c0]::Foo<_>>::bar::QUUX"),
mu_demangle_test("_RNvNvXCs1234_7mycrateINtCs1234_7mycrate3FoopENtNtC3std5clone5Clone5clone4QUUX", "<mycrate[3c1c0]::Foo<_> as std[0]::clone::Clone>::clone::QUUX"),
mu_demangle_test("_RNvNvXCs1234_7mycrateINtCs1234_7mycrate3FoopENtNtC3std5clone5Clone5clone4QUUX", "<mycrate[3c1c0]::Foo<_> as std::clone::Clone>::clone::QUUX"),
mu_demangle_test("_RNvNvXINtC7mycrate3FoopEINtNtC3std7convert4FrompE4from3MSG", NULL),
mu_demangle_test("_RNvNvXs2_C7mycrateINtC7mycrate3FoopEINtNtC3std7convert4FrompE4from3MSG", "<mycrate[0]::Foo<_> as std[0]::convert::From<_>>::from::MSG"),
mu_demangle_test("_RNvNvXs3_C7mycrateINtC7mycrate3FoopEINtNtC3std7convert4FrompE4from3MSG", "<mycrate[0]::Foo<_> as std[0]::convert::From<_>>::from::MSG"),
mu_demangle_test("_RNvNvXs2_C7mycrateINtC7mycrate3FoopEINtNtC3std7convert4FrompE4from3MSG", "<mycrate::Foo<_> as std::convert::From<_>>::from::MSG"),
mu_demangle_test("_RNvNvXs3_C7mycrateINtC7mycrate3FoopEINtNtC3std7convert4FrompE4from3MSG", "<mycrate::Foo<_> as std::convert::From<_>>::from::MSG"),
mu_demangle_test("_RNvXINtC7mycrate3FoomEINtC7mycrate3BaryE3foo", NULL),
mu_demangle_test("_RNvXmNtC7mycrate3Foo3foo", NULL),
mu_demangle_test("_RINvCs7qp2U7fqm6G_7mycrate7exampleFG0_RL1_hRL0_tEuEB2_", "mycrate[567e63b0a19c5b38]::example::<for<'a, 'b> fn(&'a u8, &'b u16)>"),
Expand Down

0 comments on commit 0031d1a

Please sign in to comment.