Skip to content

Commit b29e299

Browse files
committed
Rollup merge of #32329 - sfackler:assert-recover-safe-pub, r=aturon
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. r? @aturon
2 parents d5dceba + 797d520 commit b29e299

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-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: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ pub trait RefRecoverSafe {}
161161
/// // });
162162
///
163163
/// // This, however, will compile due to the `AssertRecoverSafe` wrapper
164-
/// let result = panic::recover(AssertRecoverSafe::new(|| {
164+
/// let result = panic::recover(AssertRecoverSafe(|| {
165165
/// variable += 3;
166166
/// }));
167167
/// // ...
@@ -185,15 +185,15 @@ pub trait RefRecoverSafe {}
185185
/// let other_capture = 3;
186186
///
187187
/// let result = {
188-
/// let mut wrapper = AssertRecoverSafe::new(&mut variable);
188+
/// let mut wrapper = AssertRecoverSafe(&mut variable);
189189
/// panic::recover(move || {
190190
/// **wrapper += other_capture;
191191
/// })
192192
/// };
193193
/// // ...
194194
/// ```
195195
#[unstable(feature = "recover", reason = "awaiting feedback", issue = "27719")]
196-
pub struct AssertRecoverSafe<T>(T);
196+
pub struct AssertRecoverSafe<T>(pub T);
197197

198198
// Implementations of the `RecoverSafe` trait:
199199
//
@@ -230,12 +230,16 @@ impl<T> RefRecoverSafe for AssertRecoverSafe<T> {}
230230
impl<T> AssertRecoverSafe<T> {
231231
/// Creates a new `AssertRecoverSafe` wrapper around the provided type.
232232
#[unstable(feature = "recover", reason = "awaiting feedback", issue = "27719")]
233+
#[rustc_deprecated(reason = "the type's field is now public, construct it directly",
234+
since = "1.9.0")]
233235
pub fn new(t: T) -> AssertRecoverSafe<T> {
234236
AssertRecoverSafe(t)
235237
}
236238

237239
/// Consumes the `AssertRecoverSafe`, returning the wrapped value.
238240
#[unstable(feature = "recover", reason = "awaiting feedback", issue = "27719")]
241+
#[rustc_deprecated(reason = "the type's field is now public, access it directly",
242+
since = "1.9.0")]
239243
pub fn into_inner(self) -> T {
240244
self.0
241245
}

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)