Skip to content

Commit f0fe4bb

Browse files
committed
Address feedback
1 parent e46620a commit f0fe4bb

File tree

2 files changed

+14
-41
lines changed

2 files changed

+14
-41
lines changed

src/libcore/finally.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@
3232
//! # }
3333
//! ```
3434
35-
#![deprecated = "this was an unsightly interface. just implement Drop"]
35+
#![deprecated = "It is unclear if this module is more robust than implementing \
36+
Drop on a custom type, and this module is being removed with no \
37+
replacement. Use a custom Drop implementation to regain existing \
38+
functionality."]
39+
#![allow(deprecated)]
3640

3741
use ops::{Drop, FnMut, FnOnce};
3842

src/test/run-pass/backtrace.rs

+9-40
Original file line numberDiff line numberDiff line change
@@ -19,41 +19,6 @@ use std::io::process::Command;
1919
use std::str;
2020
use std::ops::{Drop, FnMut, FnOnce};
2121

22-
pub trait Finally<T> {
23-
fn finally<F>(&mut self, dtor: F) -> T where F: FnMut();
24-
}
25-
26-
impl<T, F> Finally<T> for F where F: FnMut() -> T {
27-
fn finally<G>(&mut self, mut dtor: G) -> T where G: FnMut() {
28-
try_finally(&mut (), self, |_, f| (*f)(), |_| dtor())
29-
}
30-
}
31-
32-
pub fn try_finally<T, U, R, F, G>(mutate: &mut T, drop: U, try_fn: F, finally_fn: G) -> R where
33-
F: FnOnce(&mut T, U) -> R,
34-
G: FnMut(&mut T),
35-
{
36-
let f = Finallyalizer {
37-
mutate: mutate,
38-
dtor: finally_fn,
39-
};
40-
try_fn(&mut *f.mutate, drop)
41-
}
42-
43-
struct Finallyalizer<'a, A:'a, F> where F: FnMut(&mut A) {
44-
mutate: &'a mut A,
45-
dtor: F,
46-
}
47-
48-
#[unsafe_destructor]
49-
impl<'a, A, F> Drop for Finallyalizer<'a, A, F> where F: FnMut(&mut A) {
50-
#[inline]
51-
fn drop(&mut self) {
52-
(self.dtor)(self.mutate);
53-
}
54-
}
55-
56-
5722
#[inline(never)]
5823
fn foo() {
5924
let _v = vec![1i, 2, 3];
@@ -64,11 +29,15 @@ fn foo() {
6429

6530
#[inline(never)]
6631
fn double() {
67-
(|&mut:| {
68-
panic!("once");
69-
}).finally(|| {
70-
panic!("twice");
71-
})
32+
struct Double;
33+
34+
impl Drop for Double {
35+
fn drop(&mut self) { panic!("twice") }
36+
}
37+
38+
let _d = Double;
39+
40+
panic!("once");
7241
}
7342

7443
fn runtest(me: &str) {

0 commit comments

Comments
 (0)