Skip to content
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

Make AssertRecoverSafe's field public #32329

Merged
merged 3 commits into from
Mar 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/librustdoc/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,10 @@ fn runtest(test: &str, cratename: &str, cfgs: Vec<String>, libs: SearchPaths,
}

match {
let b_sess = AssertRecoverSafe::new(&sess);
let b_cstore = AssertRecoverSafe::new(&cstore);
let b_cfg = AssertRecoverSafe::new(cfg.clone());
let b_control = AssertRecoverSafe::new(&control);
let b_sess = AssertRecoverSafe(&sess);
let b_cstore = AssertRecoverSafe(&cstore);
let b_cfg = AssertRecoverSafe(cfg.clone());
let b_control = AssertRecoverSafe(&control);

panic::recover(|| {
driver::compile_input(&b_sess, &b_cstore, (*b_cfg).clone(),
Expand Down
10 changes: 7 additions & 3 deletions src/libstd/panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ pub trait RefRecoverSafe {}
/// // });
///
/// // This, however, will compile due to the `AssertRecoverSafe` wrapper
/// let result = panic::recover(AssertRecoverSafe::new(|| {
/// let result = panic::recover(AssertRecoverSafe(|| {
/// variable += 3;
/// }));
/// // ...
Expand All @@ -171,15 +171,15 @@ pub trait RefRecoverSafe {}
/// let other_capture = 3;
///
/// let result = {
/// let mut wrapper = AssertRecoverSafe::new(&mut variable);
/// let mut wrapper = AssertRecoverSafe(&mut variable);
/// panic::recover(move || {
/// **wrapper += other_capture;
/// })
/// };
/// // ...
/// ```
#[unstable(feature = "recover", reason = "awaiting feedback", issue = "27719")]
pub struct AssertRecoverSafe<T>(T);
pub struct AssertRecoverSafe<T>(pub T);

// Implementations of the `RecoverSafe` trait:
//
Expand Down Expand Up @@ -216,12 +216,16 @@ impl<T> RefRecoverSafe for AssertRecoverSafe<T> {}
impl<T> AssertRecoverSafe<T> {
/// Creates a new `AssertRecoverSafe` wrapper around the provided type.
#[unstable(feature = "recover", reason = "awaiting feedback", issue = "27719")]
#[rustc_deprecated(reason = "the type's field is now public, construct it directly",
since = "1.9.0")]
pub fn new(t: T) -> AssertRecoverSafe<T> {
AssertRecoverSafe(t)
}

/// Consumes the `AssertRecoverSafe`, returning the wrapped value.
#[unstable(feature = "recover", reason = "awaiting feedback", issue = "27719")]
#[rustc_deprecated(reason = "the type's field is now public, access it directly",
since = "1.9.0")]
pub fn into_inner(self) -> T {
self.0
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/binary-heap-panic-safe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ fn test_integrity() {
{
// push the panicking item to the heap and catch the panic
let thread_result = {
let mut heap_ref = AssertRecoverSafe::new(&mut heap);
let mut heap_ref = AssertRecoverSafe(&mut heap);
panic::recover(move || {
heap_ref.push(panic_item);
})
Expand Down