From 0031d1aff54fd6e922d7600425284513d32dec65 Mon Sep 17 00:00:00 2001 From: Giovanni <561184+wargio@users.noreply.github.com> Date: Fri, 12 Apr 2024 14:25:07 +0800 Subject: [PATCH] Update to use crate for f16/f128 and show disambiguator on non-zero (#65) --- src/rust/rust_v0.c | 8 +------- test/test_rust.c | 42 +++++++++++++++++++++--------------------- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/src/rust/rust_v0.c b/src/rust/rust_v0.c index c66dada..b5672e2 100644 --- a/src/rust/rust_v0.c +++ b/src/rust/rust_v0.c @@ -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; @@ -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); } diff --git a/test/test_rust.c b/test/test_rust.c index 4c98cf3..55a396b 100644 --- a/test/test_rust.c +++ b/test/test_rust.c @@ -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_", " as core[846817f741e54dfd]::iter::iterator::Iterator>::rposition::::{closure#0}"), mu_demangle_test("_RINbNbCskIICzLVDPPb_5alloc5alloc8box_freeDINbNiB4_5boxed5FnBoxuEp6OutputuEL_ECs1iopQbuBiw2_3std", "alloc[f15a878b47eb696b]::alloc::box_free::>"), 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::, _>>"), - mu_demangle_test("_RINtNtC3std4iter5ChainINtNtC3std4iter3ZipINtNtC3std3vec8IntoItermEINtNtC3std3vec8IntoItermEEE", "std[0]::iter::Chain::, std[0]::vec::IntoIter>>"), + 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::, _>>"), + mu_demangle_test("_RINtNtC3std4iter5ChainINtNtC3std4iter3ZipINtNtC3std3vec8IntoItermEINtNtC3std3vec8IntoItermEEE", "std::iter::Chain::, std::vec::IntoIter>>"), mu_demangle_test("_RINvCs1234_7mycrate3fooNvB4_3barNvBn_3bazE", "mycrate[3c1c0]::foo::<::bar, ::baz>"), - mu_demangle_test("_RINvNtC3std3mem8align_ofkE", "std[0]::mem::align_of::"), - mu_demangle_test("_RINvNtC3std3mem8align_offE", "std[0]::mem::align_of::"), - mu_demangle_test("_RINvNtC3std3mem8align_ofdE", "std[0]::mem::align_of::"), - mu_demangle_test("_RINvNtC3std3mem8align_ofqE", "std[0]::mem::align_of::"), - mu_demangle_test("_RINvNtC3std3mem8align_ofjE", "std[0]::mem::align_of::"), - mu_demangle_test("_RINvNtC3std3mem8align_ofjEC3bar", "std[0]::mem::align_of::"), - mu_demangle_test("_RINvNtC3std3mem8align_ofjEC3foo", "std[0]::mem::align_of::"), - mu_demangle_test("_RINvNtC3std3mem8align_ofNtNtC3std3mem12DiscriminantE", "std[0]::mem::align_of::"), - 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::"), + mu_demangle_test("_RINvNtC3std3mem8align_offE", "std::mem::align_of::"), + mu_demangle_test("_RINvNtC3std3mem8align_ofdE", "std::mem::align_of::"), + mu_demangle_test("_RINvNtC3std3mem8align_ofC4f128E", "std::mem::align_of::"), + mu_demangle_test("_RINvNtC3std3mem8align_ofjE", "std::mem::align_of::"), + mu_demangle_test("_RINvNtC3std3mem8align_ofjEC3bar", "std::mem::align_of::"), + mu_demangle_test("_RINvNtC3std3mem8align_ofjEC3foo", "std::mem::align_of::"), + mu_demangle_test("_RINvNtC3std3mem8align_ofNtNtC3std3mem12DiscriminantE", "std::mem::align_of::"), + 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", ">::bar::QUUX"), - mu_demangle_test("_RNvNvXCs1234_7mycrateINtCs1234_7mycrate3FoopENtNtC3std5clone5Clone5clone4QUUX", " as std[0]::clone::Clone>::clone::QUUX"), + mu_demangle_test("_RNvNvXCs1234_7mycrateINtCs1234_7mycrate3FoopENtNtC3std5clone5Clone5clone4QUUX", " as std::clone::Clone>::clone::QUUX"), mu_demangle_test("_RNvNvXINtC7mycrate3FoopEINtNtC3std7convert4FrompE4from3MSG", NULL), - mu_demangle_test("_RNvNvXs2_C7mycrateINtC7mycrate3FoopEINtNtC3std7convert4FrompE4from3MSG", " as std[0]::convert::From<_>>::from::MSG"), - mu_demangle_test("_RNvNvXs3_C7mycrateINtC7mycrate3FoopEINtNtC3std7convert4FrompE4from3MSG", " as std[0]::convert::From<_>>::from::MSG"), + mu_demangle_test("_RNvNvXs2_C7mycrateINtC7mycrate3FoopEINtNtC3std7convert4FrompE4from3MSG", " as std::convert::From<_>>::from::MSG"), + mu_demangle_test("_RNvNvXs3_C7mycrateINtC7mycrate3FoopEINtNtC3std7convert4FrompE4from3MSG", " 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:: fn(&'a u8, &'b u16)>"),