-
Notifications
You must be signed in to change notification settings - Fork 9
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
alloc::sync::Weak<T, A> is missing core::fmt::Debug #131
Comments
Is this also applicable to the Weak of Rc?
In Short: Reference Counted pointers often end up in recursive structures, so printing the contents of Weak would likely lead to recursing infinitely (until the stack overflows). The PR that removed the Debug bound explains this It also can't be readded as adding such a bound would be a breaking change. |
It appears that Rc's Weak correctly implements this:
(src: https://doc.rust-lang.org/1.80.1/src/alloc/rc.rs.html#3348 )
This makes a ton of sense, thanks! |
Made a PR! rust-lang/rust#129673 |
… r=dtolnay Add fmt::Debug to sync::Weak<T, A> Currently, `sync::Weak<T>` implements `Debug`, but `sync::Weak<T, A>` does not. This appears to be an oversight, as `rc::Weak<T, A>` implements `Debug`. (Note: `sync::Weak` is the weak for `Arc`, and `rc::Weak` is the weak for `Rc`.) This PR adds the Debug trait for `sync::Weak<T, A>`. The issue was initially brought up here: rust-lang/wg-allocators#131
… r=dtolnay Add fmt::Debug to sync::Weak<T, A> Currently, `sync::Weak<T>` implements `Debug`, but `sync::Weak<T, A>` does not. This appears to be an oversight, as `rc::Weak<T, A>` implements `Debug`. (Note: `sync::Weak` is the weak for `Arc`, and `rc::Weak` is the weak for `Rc`.) This PR adds the Debug trait for `sync::Weak<T, A>`. The issue was initially brought up here: rust-lang/wg-allocators#131
… r=dtolnay Add fmt::Debug to sync::Weak<T, A> Currently, `sync::Weak<T>` implements `Debug`, but `sync::Weak<T, A>` does not. This appears to be an oversight, as `rc::Weak<T, A>` implements `Debug`. (Note: `sync::Weak` is the weak for `Arc`, and `rc::Weak` is the weak for `Rc`.) This PR adds the Debug trait for `sync::Weak<T, A>`. The issue was initially brought up here: rust-lang/wg-allocators#131
Rollup merge of rust-lang#129673 - matthewpipie:arc-weak-debug-trait, r=dtolnay Add fmt::Debug to sync::Weak<T, A> Currently, `sync::Weak<T>` implements `Debug`, but `sync::Weak<T, A>` does not. This appears to be an oversight, as `rc::Weak<T, A>` implements `Debug`. (Note: `sync::Weak` is the weak for `Arc`, and `rc::Weak` is the weak for `Rc`.) This PR adds the Debug trait for `sync::Weak<T, A>`. The issue was initially brought up here: rust-lang/wg-allocators#131
Add fmt::Debug to sync::Weak<T, A> Currently, `sync::Weak<T>` implements `Debug`, but `sync::Weak<T, A>` does not. This appears to be an oversight, as `rc::Weak<T, A>` implements `Debug`. (Note: `sync::Weak` is the weak for `Arc`, and `rc::Weak` is the weak for `Rc`.) This PR adds the Debug trait for `sync::Weak<T, A>`. The issue was initially brought up here: rust-lang/wg-allocators#131
Merged! |
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:
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:
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?
The text was updated successfully, but these errors were encountered: