Skip to content

Commit 1c14ef8

Browse files
committed
---
yaml --- r: 44811 b: refs/heads/master c: 43d43ad h: refs/heads/master i: 44809: e383483 44807: df0646b v: v3
1 parent 981b314 commit 1c14ef8

File tree

24 files changed

+119
-51
lines changed

24 files changed

+119
-51
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 6ebc761f99149b47524664b6625ee36e04449baa
2+
refs/heads/master: 43d43adf6bd2024b1ddc0e596d4bed88e1df82b1
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d9689399d091c3265f00434a69c551a61c28dc
55
refs/heads/try: ef355f6332f83371e4acf04fc4eb940ab41d78d3

trunk/src/libcore/io.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,10 @@ impl<R:Reader,C> Reader for Wrapper<R, C> {
474474

475475
pub struct FILERes {
476476
f: *libc::FILE,
477-
drop {
477+
}
478+
479+
impl Drop for FILERes {
480+
fn finalize(&self) {
478481
unsafe {
479482
libc::fclose(self.f);
480483
}
@@ -683,7 +686,10 @@ impl Writer for fd_t {
683686

684687
pub struct FdRes {
685688
fd: fd_t,
686-
drop {
689+
}
690+
691+
impl Drop for FdRes {
692+
fn finalize(&self) {
687693
unsafe {
688694
libc::close(self.fd);
689695
}

trunk/src/libcore/option.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,10 @@ fn test_unwrap_str() {
450450
fn test_unwrap_resource() {
451451
struct R {
452452
i: @mut int,
453-
drop { *(self.i) += 1; }
453+
}
454+
455+
impl ::ops::Drop for R {
456+
fn finalize(&self) { *(self.i) += 1; }
454457
}
455458

456459
fn R(i: @mut int) -> R {

trunk/src/libcore/pipes.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,10 @@ pub unsafe fn get_buffer<T>(p: *PacketHeader) -> ~Buffer<T> {
346346
struct BufferResource<T> {
347347
buffer: ~Buffer<T>,
348348
349-
drop {
349+
}
350+
351+
impl<T> ::ops::Drop for BufferResource<T> {
352+
fn finalize(&self) {
350353
unsafe {
351354
let b = move_it!(self.buffer);
352355
//let p = ptr::addr_of(*b);

trunk/src/libcore/private.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,10 @@ struct ArcData<T> {
126126

127127
struct ArcDestruct<T> {
128128
mut data: *libc::c_void,
129-
drop {
129+
}
130+
131+
impl<T> Drop for ArcDestruct<T>{
132+
fn finalize(&self) {
130133
unsafe {
131134
if self.data.is_null() {
132135
return; // Happens when destructing an unwrapper's handle.
@@ -178,7 +181,10 @@ pub unsafe fn unwrap_shared_mutable_state<T:Owned>(rc: SharedMutableState<T>)
178181
struct DeathThroes<T> {
179182
mut ptr: Option<~ArcData<T>>,
180183
mut response: Option<comm::ChanOne<bool>>,
181-
drop {
184+
}
185+
186+
impl<T> Drop for DeathThroes<T>{
187+
fn finalize(&self) {
182188
unsafe {
183189
let response = option::swap_unwrap(&mut self.response);
184190
// In case we get killed early, we need to tell the person who
@@ -311,7 +317,10 @@ type rust_little_lock = *libc::c_void;
311317
312318
struct LittleLock {
313319
l: rust_little_lock,
314-
drop {
320+
}
321+
322+
impl Drop for LittleLock {
323+
fn finalize(&self) {
315324
unsafe {
316325
rustrt::rust_destroy_little_lock(self.l);
317326
}

trunk/src/libcore/rand.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,10 @@ impl Rng {
365365

366366
struct RandRes {
367367
rng: *rust_rng,
368-
drop {
368+
}
369+
370+
impl Drop for RandRes {
371+
fn finalize(&self) {
369372
unsafe {
370373
rustrt::rand_free(self.rng);
371374
}

trunk/src/libcore/run.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,10 @@ pub fn start_program(prog: &str, args: &[~str]) -> Program {
248248
}
249249
struct ProgRes {
250250
r: ProgRepr,
251-
drop {
251+
}
252+
253+
impl Drop for ProgRes {
254+
fn finalize(&self) {
252255
unsafe {
253256
// FIXME #4943: This is bad.
254257
destroy_repr(cast::transmute(&self.r));

trunk/src/libcore/task/spawn.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,11 @@ struct TCB {
308308
mut ancestors: AncestorList,
309309
is_main: bool,
310310
notifier: Option<AutoNotify>,
311+
}
312+
313+
impl Drop for TCB {
311314
// Runs on task exit.
312-
drop {
315+
fn finalize(&self) {
313316
unsafe {
314317
// If we are failing, the whole taskgroup needs to die.
315318
if rt::rust_task_is_unwinding(self.me) {
@@ -353,7 +356,10 @@ fn TCB(me: *rust_task, tasks: TaskGroupArc, ancestors: AncestorList,
353356
struct AutoNotify {
354357
notify_chan: Chan<TaskResult>,
355358
mut failed: bool,
356-
drop {
359+
}
360+
361+
impl Drop for AutoNotify {
362+
fn finalize(&self) {
357363
let result = if self.failed { Failure } else { Success };
358364
self.notify_chan.send(result);
359365
}

trunk/src/libcore/util.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ pub fn replace<T>(dest: &mut T, src: T) -> T {
6666
/// A non-copyable dummy type.
6767
pub struct NonCopyable {
6868
i: (),
69-
drop { }
69+
}
70+
71+
impl Drop for NonCopyable {
72+
fn finalize(&self) { }
7073
}
7174

7275
pub fn NonCopyable() -> NonCopyable { NonCopyable { i: () } }

trunk/src/librustc/lib/llvm.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,7 +1458,10 @@ pub fn struct_tys(struct_ty: TypeRef) -> ~[TypeRef] {
14581458

14591459
pub struct target_data_res {
14601460
TD: TargetDataRef,
1461-
drop {
1461+
}
1462+
1463+
impl Drop for target_data_res {
1464+
fn finalize(&self) {
14621465
unsafe {
14631466
llvm::LLVMDisposeTargetData(self.TD);
14641467
}
@@ -1492,7 +1495,10 @@ pub fn mk_target_data(string_rep: ~str) -> TargetData {
14921495

14931496
pub struct pass_manager_res {
14941497
PM: PassManagerRef,
1495-
drop {
1498+
}
1499+
1500+
impl Drop for pass_manager_res {
1501+
fn finalize(&self) {
14961502
unsafe {
14971503
llvm::LLVMDisposePassManager(self.PM);
14981504
}
@@ -1525,7 +1531,10 @@ pub fn mk_pass_manager() -> PassManager {
15251531

15261532
pub struct object_file_res {
15271533
ObjectFile: ObjectFileRef,
1528-
drop {
1534+
}
1535+
1536+
impl Drop for object_file_res {
1537+
fn finalize(&self) {
15291538
unsafe {
15301539
llvm::LLVMDisposeObjectFile(self.ObjectFile);
15311540
}
@@ -1559,7 +1568,10 @@ pub fn mk_object_file(llmb: MemoryBufferRef) -> Option<ObjectFile> {
15591568

15601569
pub struct section_iter_res {
15611570
SI: SectionIteratorRef,
1562-
drop {
1571+
}
1572+
1573+
impl Drop for section_iter_res {
1574+
fn finalize(&self) {
15631575
unsafe {
15641576
llvm::LLVMDisposeSectionIterator(self.SI);
15651577
}

trunk/src/librustc/middle/trans/base.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ use syntax::{ast, ast_util, codemap, ast_map};
9090

9191
pub struct icx_popper {
9292
ccx: @CrateContext,
93-
drop {
93+
}
94+
95+
impl Drop for icx_popper {
96+
fn finalize(&self) {
9497
if self.ccx.sess.count_llvm_insns() {
9598
self.ccx.stats.llvm_insn_ctxt.pop();
9699
}

trunk/src/librustc/middle/trans/common.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,10 @@ pub struct Stats {
141141

142142
pub struct BuilderRef_res {
143143
B: BuilderRef,
144-
drop {
144+
}
145+
146+
impl Drop for BuilderRef_res {
147+
fn finalize(&self) {
145148
unsafe {
146149
llvm::LLVMDisposeBuilder(self.B);
147150
}

trunk/src/librustc/rustc.rc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,10 @@ pub fn monitor(+f: fn~(diagnostic::Emitter)) {
336336

337337
struct finally {
338338
ch: SharedChan<monitor_msg>,
339-
drop { self.ch.send(done); }
339+
}
340+
341+
impl Drop for finally {
342+
fn finalize(&self) { self.ch.send(done); }
340343
}
341344

342345
let _finally = finally { ch: ch };

trunk/src/librustc/util/common.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ pub fn indent<R>(op: fn() -> R) -> R {
3232

3333
pub struct _indenter {
3434
_i: (),
35-
drop { debug!("<<"); }
35+
}
36+
37+
impl Drop for _indenter {
38+
fn finalize(&self) { debug!("<<"); }
3639
}
3740

3841
pub fn _indenter(_i: ()) -> _indenter {

trunk/src/librustdoc/demo.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ mod blade_runner {
125125
*/
126126
struct Bored {
127127
bored: bool,
128-
drop { log(error, self.bored); }
128+
}
129+
130+
impl Drop for Bored {
131+
fn finalize(&self) { log(error, self.bored); }
129132
}
130133

131134
/**

trunk/src/libstd/sha1.rs

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,7 @@ pub fn sha1() -> Sha1 {
251251
let rr = mk_result(self);
252252
let mut s = ~"";
253253
for vec::each(rr) |b| {
254-
let hex = uint::to_str_radix(*b as uint, 16u);
255-
if hex.len() == 1 {
256-
s += "0";
257-
}
258-
s += hex;
254+
s += uint::to_str_radix(*b as uint, 16u);
259255
}
260256
return s;
261257
}
@@ -287,7 +283,6 @@ mod tests {
287283
struct Test {
288284
input: ~str,
289285
output: ~[u8],
290-
output_str: ~str,
291286
}
292287

293288
fn a_million_letter_a() -> ~str {
@@ -311,7 +306,6 @@ mod tests {
311306
0x78u8, 0x50u8, 0xC2u8, 0x6Cu8,
312307
0x9Cu8, 0xD0u8, 0xD8u8, 0x9Du8,
313308
],
314-
output_str: ~"a9993e364706816aba3e25717850c26c9cd0d89d"
315309
},
316310
Test {
317311
input:
@@ -324,7 +318,6 @@ mod tests {
324318
0xF9u8, 0x51u8, 0x29u8, 0xE5u8,
325319
0xE5u8, 0x46u8, 0x70u8, 0xF1u8,
326320
],
327-
output_str: ~"84983e441c3bd26ebaae4aa1f95129e5e54670f1"
328321
},
329322
Test {
330323
input: a_million_letter_a(),
@@ -335,7 +328,6 @@ mod tests {
335328
0xDBu8, 0xADu8, 0x27u8, 0x31u8,
336329
0x65u8, 0x34u8, 0x01u8, 0x6Fu8,
337330
],
338-
output_str: ~"34aa973cd4c4daa4f61eeb2bdbad27316534016f"
339331
},
340332
];
341333
// Examples from wikipedia
@@ -350,7 +342,6 @@ mod tests {
350342
0xbbu8, 0x76u8, 0xe7u8, 0x39u8,
351343
0x1bu8, 0x93u8, 0xebu8, 0x12u8,
352344
],
353-
output_str: ~"2fd4e1c67a2d28fced849ee1bb76e7391b93eb12",
354345
},
355346
Test {
356347
input: ~"The quick brown fox jumps over the lazy cog",
@@ -361,7 +352,6 @@ mod tests {
361352
0x0bu8, 0xd1u8, 0x7du8, 0x9bu8,
362353
0x10u8, 0x0du8, 0xb4u8, 0xb3u8,
363354
],
364-
output_str: ~"de9f2c7fd25e1b3afad3e85a0bd17d9b100db4b3",
365355
},
366356
];
367357
let tests = fips_180_1_tests + wikipedia_tests;
@@ -383,11 +373,6 @@ mod tests {
383373
sh.input_str(t.input);
384374
let out = sh.result();
385375
check_vec_eq(t.output, out);
386-
387-
let out_str = sh.result_str();
388-
assert(out_str.len() == 40);
389-
assert(out_str == t.output_str);
390-
391376
sh.reset();
392377
}
393378

@@ -404,11 +389,6 @@ mod tests {
404389
}
405390
let out = sh.result();
406391
check_vec_eq(t.output, out);
407-
408-
let out_str = sh.result_str();
409-
assert(out_str.len() == 40);
410-
assert(out_str == t.output_str);
411-
412392
sh.reset();
413393
}
414394
}

trunk/src/libstd/task_pool.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ pub struct TaskPool<T> {
2828
channels: ~[Chan<Msg<T>>],
2929
mut next_index: uint,
3030

31-
drop {
31+
}
32+
33+
impl<T> Drop for TaskPool<T> {
34+
fn finalize(&self) {
3235
for self.channels.each |channel| {
3336
channel.send(Quit);
3437
}

trunk/src/libsyntax/parse/parser.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,11 @@ pub struct Parser {
243243
/// Used to determine the path to externally loaded source files
244244
mod_path_stack: @mut ~[~str],
245245

246-
drop {} /* do not copy the parser; its state is tied to outside state */
246+
}
247+
248+
impl Drop for Parser {
249+
/* do not copy the parser; its state is tied to outside state */
250+
fn finalize(&self) {}
247251
}
248252

249253
pub impl Parser {

trunk/src/test/auxiliary/moves_based_on_type_lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212

1313
pub struct S {
1414
x: int,
15-
drop {
15+
}
16+
17+
impl Drop for S {
18+
fn finalize(&self) {
1619
io::println("goodbye");
1720
}
1821
}

trunk/src/test/compile-fail/use-after-move-self-based-on-type.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
struct S {
22
x: int,
3-
drop {}
3+
}
4+
5+
impl Drop for S {
6+
fn finalize(&self) {}
47
}
58

69
impl S {

0 commit comments

Comments
 (0)