Skip to content

Commit 74d00bd

Browse files
committed
Make AssertRecoverSafe's field public
It's basically the very definition of a newtype, so we might as well make things easy on people and let them construct and access it directly.
1 parent b12b4e4 commit 74d00bd

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

src/librustdoc/test.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,10 @@ fn runtest(test: &str, cratename: &str, cfgs: Vec<String>, libs: SearchPaths,
257257
}
258258

259259
match {
260-
let b_sess = AssertRecoverSafe::new(&sess);
261-
let b_cstore = AssertRecoverSafe::new(&cstore);
262-
let b_cfg = AssertRecoverSafe::new(cfg.clone());
263-
let b_control = AssertRecoverSafe::new(&control);
260+
let b_sess = AssertRecoverSafe(&sess);
261+
let b_cstore = AssertRecoverSafe(&cstore);
262+
let b_cfg = AssertRecoverSafe(cfg.clone());
263+
let b_control = AssertRecoverSafe(&control);
264264

265265
panic::recover(|| {
266266
driver::compile_input(&b_sess, &b_cstore, (*b_cfg).clone(),

src/libstd/panic.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ pub trait RefRecoverSafe {}
147147
/// // });
148148
///
149149
/// // This, however, will compile due to the `AssertRecoverSafe` wrapper
150-
/// let result = panic::recover(AssertRecoverSafe::new(|| {
150+
/// let result = panic::recover(AssertRecoverSafe(|| {
151151
/// variable += 3;
152152
/// }));
153153
/// // ...
@@ -171,15 +171,15 @@ pub trait RefRecoverSafe {}
171171
/// let other_capture = 3;
172172
///
173173
/// let result = {
174-
/// let mut wrapper = AssertRecoverSafe::new(&mut variable);
174+
/// let mut wrapper = AssertRecoverSafe(&mut variable);
175175
/// panic::recover(move || {
176176
/// **wrapper += other_capture;
177177
/// })
178178
/// };
179179
/// // ...
180180
/// ```
181181
#[unstable(feature = "recover", reason = "awaiting feedback", issue = "27719")]
182-
pub struct AssertRecoverSafe<T>(T);
182+
pub struct AssertRecoverSafe<T>(pub T);
183183

184184
// Implementations of the `RecoverSafe` trait:
185185
//
@@ -216,12 +216,14 @@ impl<T> RefRecoverSafe for AssertRecoverSafe<T> {}
216216
impl<T> AssertRecoverSafe<T> {
217217
/// Creates a new `AssertRecoverSafe` wrapper around the provided type.
218218
#[unstable(feature = "recover", reason = "awaiting feedback", issue = "27719")]
219+
#[rustc_deprecated(reason = "the type's field is now public, construct it directly")]
219220
pub fn new(t: T) -> AssertRecoverSafe<T> {
220221
AssertRecoverSafe(t)
221222
}
222223

223224
/// Consumes the `AssertRecoverSafe`, returning the wrapped value.
224225
#[unstable(feature = "recover", reason = "awaiting feedback", issue = "27719")]
226+
#[rustc_deprecated(reason = "the type's field is now public, access it directly")]
225227
pub fn into_inner(self) -> T {
226228
self.0
227229
}

src/test/run-pass/binary-heap-panic-safe.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ fn test_integrity() {
7070
{
7171
// push the panicking item to the heap and catch the panic
7272
let thread_result = {
73-
let mut heap_ref = AssertRecoverSafe::new(&mut heap);
73+
let mut heap_ref = AssertRecoverSafe(&mut heap);
7474
panic::recover(move || {
7575
heap_ref.push(panic_item);
7676
})

0 commit comments

Comments
 (0)