Skip to content

Commit

Permalink
Auto merge of #24254 - aturon:join-handle-debug, r=alexcrichton
Browse files Browse the repository at this point in the history
Make `Box<Any + Send>` implement `Debug`.

Fixes #21291
  • Loading branch information
bors committed Apr 11, 2015
2 parents c87ec1e + 76d468a commit 3a82753
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/libcore/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
17 changes: 17 additions & 0 deletions src/test/run-pass/issue-21291.rs
Original file line number Diff line number Diff line change
@@ -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()
}

0 comments on commit 3a82753

Please sign in to comment.