Remove T: Debug bound on mpsc Debug impls (#866)

Following from https://github.com/tokio-rs/tokio/pull/865, this PR
removes `#[derive(Debug)]` on `mpsc` sender and receiver types in favor
of explicit `impl fmt::Debug` blocks that don't have a `T: fmt::Debug`
bound.
This commit is contained in:
Jon Gjengset
2019-01-23 18:04:00 -05:00
committed by GitHub
parent c6f9a069a5
commit c6f8bdb249
5 changed files with 100 additions and 32 deletions
+20 -22
View File
@@ -92,33 +92,31 @@ fn send_recv_unbounded() {
}
#[test]
fn clone_sender_no_t_clone_buffer() {
#[derive(Debug, PartialEq, Eq)]
struct NotClone;
let (mut tx, mut rx) = mpsc::channel(100);
tx.try_send(NotClone).unwrap();
tx.clone().try_send(NotClone).unwrap();
fn no_t_bounds_buffer() {
struct NoImpls;
let (tx, mut rx) = mpsc::channel(100);
let val = assert_ready!(rx.poll());
assert_eq!(val, Some(NotClone));
let val = assert_ready!(rx.poll());
assert_eq!(val, Some(NotClone));
// sender should be Debug even though T isn't Debug
println!("{:?}", tx);
// same with Receiver
println!("{:?}", rx);
// and sender should be Clone even though T isn't Clone
assert!(tx.clone().try_send(NoImpls).is_ok());
assert!(assert_ready!(rx.poll()).is_some());
}
#[test]
fn clone_sender_no_t_clone_unbounded() {
#[derive(Debug, PartialEq, Eq)]
struct NotClone;
let (mut tx, mut rx) = mpsc::unbounded_channel();
tx.try_send(NotClone).unwrap();
tx.clone().try_send(NotClone).unwrap();
fn no_t_bounds_unbounded() {
struct NoImpls;
let (tx, mut rx) = mpsc::unbounded_channel();
let val = assert_ready!(rx.poll());
assert_eq!(val, Some(NotClone));
let val = assert_ready!(rx.poll());
assert_eq!(val, Some(NotClone));
// sender should be Debug even though T isn't Debug
println!("{:?}", tx);
// same with Receiver
println!("{:?}", rx);
// and sender should be Clone even though T isn't Clone
assert!(tx.clone().try_send(NoImpls).is_ok());
assert!(assert_ready!(rx.poll()).is_some());
}
#[test]