Skip to content

Remove impl Display for Symbol #233

Open
@Ninja3047

Description

@Ninja3047

When I run the following program, to_string seems to panic, while the unwrap succeeds. I'm not sure if this is intentional or not.

use cpp_demangle::Symbol;

fn main() {
    let n = Symbol::new("RC4").unwrap();
    let b = n.to_string();
}

Upon further inspection, the fmt function from the Display trait throws the following error when compiled with logging which causes the to_string implementation to panic.

Error getting leaf name: reference to a leaf name in a context where there is no current leaf name

When demangling it without using to_string, demangle correctly returns the Error

use cpp_demangle::Symbol;

fn main() {
    let n = Symbol::new("RC4").unwrap();
    let options = DemangleOptions::default();
    if let Err(e) = n.demangle(&options) {
        println!("{}", e);
    }
}

And prints the following:

an error occurred when formatting an argument

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions