Skip to content

Add new v0 demangling tags for pattern types #81

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#![no_std]
#![deny(missing_docs)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![expect(elided_lifetimes_in_paths)]
#![expect(explicit_outlives_requirements)]
#![expect(unreachable_pub)]

#[cfg(any(test, feature = "std"))]
#[macro_use]
Expand Down
26 changes: 26 additions & 0 deletions src/v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,11 @@ impl<'a, 'b, 's> Printer<'a, 'b, 's> {
b'B' => {
self.print_backref(Self::print_type)?;
}
b'W' => {
self.print_type()?;
self.print(" is ")?;
self.print_pat()?;
}
_ => {
// Go back to the tag, so `print_path` also sees it.
let _ = self.parser.as_mut().map(|p| p.next -= 1);
Expand Down Expand Up @@ -1079,6 +1084,27 @@ impl<'a, 'b, 's> Printer<'a, 'b, 's> {
Ok(())
}

fn print_pat(&mut self) -> fmt::Result {
Copy link
Member

Choose a reason for hiding this comment

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

Could you add some tests for patterns along side the other unit tests at the bottom of the file?

let tag = parse!(self, next);

match tag {
b'R' => {
self.print_const(false)?;
self.print("..=")?;
self.print_const(false)?;
}
b'O' => {
parse!(self, push_depth);
self.print_pat()?;
self.pop_depth();
}
b'N' => self.print("!null")?,
_ => invalid!(self),
}

Ok(())
}

fn print_const(&mut self, in_value: bool) -> fmt::Result {
let tag = parse!(self, next);

Expand Down