Skip to content

Commit

Permalink
Always omit zero disambiguators on crate-roots.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwoerister committed Apr 29, 2024
1 parent af38dc6 commit 5449fcf
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 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 @@ -1261,17 +1261,17 @@ mod tests {
macro_rules! t_const {
($mangled:expr, $value:expr) => {
t_nohash!(
concat!("_RIC0K", $mangled, "E"),
concat!("::<", $value, ">")
concat!("_RIC8my_crateK", $mangled, "E"),
concat!("my_crate::<", $value, ">")
)
};
}
macro_rules! t_const_suffixed {
($mangled:expr, $value:expr, $value_ty_suffix:expr) => {{
t_const!($mangled, $value);
t!(
concat!("_RIC0K", $mangled, "E"),
concat!("[0]::<", $value, $value_ty_suffix, ">")
concat!("_RIC8my_crateK", $mangled, "E"),
concat!("my_crate::<", $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");
}

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

0 comments on commit 5449fcf

Please sign in to comment.