Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always omit zero disambiguators on crate-roots #69

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ impl<'a, 'b, 's> Printer<'a, 'b, 's> {

self.print(name)?;
if let Some(out) = &mut self.out {
if !out.alternate() {
if !out.alternate() && dis != 0 {
out.write_str("[")?;
fmt::LowerHex::fmt(&dis, out)?;
out.write_str("]")?;
Expand Down Expand Up @@ -1271,7 +1271,7 @@ mod tests {
t_const!($mangled, $value);
t!(
concat!("_RIC0K", $mangled, "E"),
concat!("[0]::<", $value, $value_ty_suffix, ">")
concat!("::<", $value, $value_ty_suffix, ">")
);
}};
}
Expand All @@ -1281,6 +1281,12 @@ mod tests {
t_nohash!("_RNvC6_123foo3bar", "123foo::bar");
}

#[test]
fn demangle_crate_with_zero_disambiguator() {
t!("_RC4f128", "f128");
t_nohash!("_RC4f128", "f128");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these tests fail without the change? When I was trying to work on this it seemed like these simple tests wouldn't emit [0] even as-is, and I was struggling to write a test that replicates the behavior from rust-lang/rust#123816 (comment). Hence my messy branch at https://github.com/tgross35/rustc-demangle/blob/b29eead5e3337030843b978736748a3f1c142416/src/v0.rs#L1284-L1295

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The t! line should fail, the other one should already pass.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified again that it fails without the change:

thread 'v0::tests::demangle_crate_with_zero_disambiguator' panicked at src/v0.rs:1286:9:
assertion `left == right` failed
  left: "f128[0]"
 right: "f128"

}

#[test]
fn demangle_utf8_idents() {
t_nohash!(
Expand Down
Loading