Auto merge of #24254 - aturon:join-handle-debug, r=alexcrichton

Make `Box<Any + Send>` implement `Debug`.

Fixes #21291
This commit is contained in:
bors 2015-04-11 05:57:55 +00:00
commit 3a8275397a
2 changed files with 27 additions and 0 deletions

View File

@ -114,6 +114,16 @@ impl fmt::Debug for Any {
}
}
// Ensure that the result of e.g. joining a thread can be printed and
// hence used with `unwrap`. May eventually no longer be needed if
// dispatch works with upcasting.
#[stable(feature = "rust1", since = "1.0.0")]
impl fmt::Debug for Any + Send {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.pad("Any")
}
}
impl Any {
/// Returns true if the boxed type is the same as `T`
#[stable(feature = "rust1", since = "1.0.0")]

View File

@ -0,0 +1,17 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Regression test for unwrapping the result of `join`, issue #21291
use std::thread;
fn main() {
thread::spawn(|| {}).join().unwrap()
}