Auto merge of #30894 - antrik:debug-mpsc, r=brson
Minimal fix for https://github.com/rust-lang/rust/issues/30563 This covers all the public structs I think; except for Iter and IntoIter, which I don't know if or how they should be handled.
This commit is contained in:
commit
7561466948
2 changed files with 69 additions and 0 deletions
|
@ -635,6 +635,13 @@ impl<T> Drop for Sender<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[stable(feature = "mpsc_debug", since = "1.7.0")]
|
||||||
|
impl<T> fmt::Debug for Sender<T> {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
write!(f, "Sender {{ .. }}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// SyncSender
|
// SyncSender
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -693,6 +700,13 @@ impl<T> Drop for SyncSender<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[stable(feature = "mpsc_debug", since = "1.7.0")]
|
||||||
|
impl<T> fmt::Debug for SyncSender<T> {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
write!(f, "SyncSender {{ .. }}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Receiver
|
// Receiver
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -987,6 +1001,13 @@ impl<T> Drop for Receiver<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[stable(feature = "mpsc_debug", since = "1.7.0")]
|
||||||
|
impl<T> fmt::Debug for Receiver<T> {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
write!(f, "Receiver {{ .. }}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl<T> fmt::Debug for SendError<T> {
|
impl<T> fmt::Debug for SendError<T> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
@ -2199,4 +2220,22 @@ mod sync_tests {
|
||||||
repro()
|
repro()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn fmt_debug_sender() {
|
||||||
|
let (tx, _) = channel::<i32>();
|
||||||
|
assert_eq!(format!("{:?}", tx), "Sender { .. }");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn fmt_debug_recv() {
|
||||||
|
let (_, rx) = channel::<i32>();
|
||||||
|
assert_eq!(format!("{:?}", rx), "Receiver { .. }");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn fmt_debug_sync_sender() {
|
||||||
|
let (tx, _) = sync_channel::<i32>(1);
|
||||||
|
assert_eq!(format!("{:?}", tx), "SyncSender { .. }");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,8 @@
|
||||||
issue = "27800")]
|
issue = "27800")]
|
||||||
|
|
||||||
|
|
||||||
|
use fmt;
|
||||||
|
|
||||||
use core::cell::{Cell, UnsafeCell};
|
use core::cell::{Cell, UnsafeCell};
|
||||||
use core::marker;
|
use core::marker;
|
||||||
use core::ptr;
|
use core::ptr;
|
||||||
|
@ -350,6 +352,20 @@ impl Iterator for Packets {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[stable(feature = "mpsc_debug", since = "1.7.0")]
|
||||||
|
impl fmt::Debug for Select {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
write!(f, "Select {{ .. }}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[stable(feature = "mpsc_debug", since = "1.7.0")]
|
||||||
|
impl<'rx, T:Send+'rx> fmt::Debug for Handle<'rx, T> {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
write!(f, "Handle {{ .. }}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
@ -762,4 +778,18 @@ mod tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn fmt_debug_select() {
|
||||||
|
let sel = Select::new();
|
||||||
|
assert_eq!(format!("{:?}", sel), "Select { .. }");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn fmt_debug_handle() {
|
||||||
|
let (_, rx) = channel::<i32>();
|
||||||
|
let sel = Select::new();
|
||||||
|
let mut handle = sel.handle(&rx);
|
||||||
|
assert_eq!(format!("{:?}", handle), "Handle { .. }");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue