Skip to content

alloc::sync::Weak<T, A> is missing core::fmt::Debug #131

Closed
@matthewpipie

Description

@matthewpipie

I'm fairly new to Rust so I'm not sure if this is intended, but I am running into this issue while storing a Weak inside a derive(Debug) struct. I checked the Rust source and found this line:

#[stable(feature = "arc_weak", since = "1.4.0")]
impl<T: ?Sized> fmt::Debug for Weak<T> {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "(Weak)")
    }
}

However, this only implements Debug for Weak, not Weak<T, A>.

Should this be changed to say Weak<T, A> instead? I'm happy to make a PR to rust-lang that changes it to:

#[stable(feature = "arc_weak", since = "1.4.0")]
impl<T: ?Sized, A: Allocator> fmt::Debug for Weak<T, A> {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "(Weak)")
    }
}

Additionally, though out of the scope of this issue, is there a good reason that this debug function does not try to display the Option that it implicitly contains?

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