Skip to content

Commit d2c4b64

Browse files
committed
Merge remote-tracking branch 'remotes/origin/incoming' into incoming
2 parents 3953bdd + b171d0e commit d2c4b64

34 files changed

+168
-102
lines changed

doc/rust.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ the following forms:
297297
num_lit : nonzero_dec [ dec_digit | '_' ] * num_suffix ?
298298
| '0' [ [ dec_digit | '_' ] + num_suffix ?
299299
| 'b' [ '1' | '0' | '_' ] + int_suffix ?
300-
| 'x' [ hex_digit | '-' ] + int_suffix ? ] ;
300+
| 'x' [ hex_digit | '_' ] + int_suffix ? ] ;
301301
302302
num_suffix : int_suffix | float_suffix ;
303303

src/libcore/cleanup.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ fn debug_mem() -> bool {
154154
#[cfg(notest)]
155155
#[lang="annihilate"]
156156
pub unsafe fn annihilate() {
157-
use rt::rt_free;
157+
use rt::local_free;
158158
use io::WriterUtil;
159159
use io;
160160
use libc;
@@ -192,7 +192,7 @@ pub unsafe fn annihilate() {
192192
stats.n_bytes_freed +=
193193
(*((*box).header.type_desc)).size
194194
+ sys::size_of::<BoxRepr>();
195-
rt_free(transmute(box));
195+
local_free(transmute(box));
196196
}
197197
}
198198

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
}

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 {

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);

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
}

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
}

src/libcore/rt.rs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,60 +36,54 @@ pub extern mod rustrt {
3636
unsafe fn rust_upcall_free(ptr: *c_char);
3737
}
3838

39-
#[rt(fail_)]
4039
#[lang="fail_"]
41-
pub fn rt_fail_(expr: *c_char, file: *c_char, line: size_t) -> ! {
40+
pub fn fail_(expr: *c_char, file: *c_char, line: size_t) -> ! {
4241
sys::begin_unwind_(expr, file, line);
4342
}
4443

45-
#[rt(fail_bounds_check)]
4644
#[lang="fail_bounds_check"]
47-
pub unsafe fn rt_fail_bounds_check(file: *c_char, line: size_t,
48-
index: size_t, len: size_t) {
45+
pub unsafe fn fail_bounds_check(file: *c_char, line: size_t,
46+
index: size_t, len: size_t) {
4947
let msg = fmt!("index out of bounds: the len is %d but the index is %d",
5048
len as int, index as int);
5149
do str::as_buf(msg) |p, _len| {
52-
rt_fail_(p as *c_char, file, line);
50+
fail_(p as *c_char, file, line);
5351
}
5452
}
5553

56-
pub unsafe fn rt_fail_borrowed() {
54+
pub unsafe fn fail_borrowed() {
5755
let msg = "borrowed";
5856
do str::as_buf(msg) |msg_p, _| {
5957
do str::as_buf("???") |file_p, _| {
60-
rt_fail_(msg_p as *c_char, file_p as *c_char, 0);
58+
fail_(msg_p as *c_char, file_p as *c_char, 0);
6159
}
6260
}
6361
}
6462

6563
// FIXME #4942: Make these signatures agree with exchange_alloc's signatures
66-
#[rt(exchange_malloc)]
6764
#[lang="exchange_malloc"]
68-
pub unsafe fn rt_exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char {
65+
pub unsafe fn exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char {
6966
transmute(exchange_alloc::malloc(transmute(td), transmute(size)))
7067
}
7168

7269
// NB: Calls to free CANNOT be allowed to fail, as throwing an exception from
7370
// inside a landing pad may corrupt the state of the exception handler. If a
7471
// problem occurs, call exit instead.
75-
#[rt(exchange_free)]
7672
#[lang="exchange_free"]
77-
pub unsafe fn rt_exchange_free(ptr: *c_char) {
73+
pub unsafe fn exchange_free(ptr: *c_char) {
7874
exchange_alloc::free(transmute(ptr))
7975
}
8076

81-
#[rt(malloc)]
8277
#[lang="malloc"]
83-
pub unsafe fn rt_malloc(td: *c_char, size: uintptr_t) -> *c_char {
78+
pub unsafe fn local_malloc(td: *c_char, size: uintptr_t) -> *c_char {
8479
return rustrt::rust_upcall_malloc(td, size);
8580
}
8681

8782
// NB: Calls to free CANNOT be allowed to fail, as throwing an exception from
8883
// inside a landing pad may corrupt the state of the exception handler. If a
8984
// problem occurs, call exit instead.
90-
#[rt(free)]
9185
#[lang="free"]
92-
pub unsafe fn rt_free(ptr: *c_char) {
86+
pub unsafe fn local_free(ptr: *c_char) {
9387
rustrt::rust_upcall_free(ptr);
9488
}
9589

@@ -112,7 +106,7 @@ pub unsafe fn return_to_mut(a: *u8) {
112106
pub unsafe fn check_not_borrowed(a: *u8) {
113107
let a: *mut BoxRepr = transmute(a);
114108
if ((*a).header.ref_count & FROZEN_BIT) != 0 {
115-
rt_fail_borrowed();
109+
fail_borrowed();
116110
}
117111
}
118112

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));

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
}

src/libcore/to_str.rs

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -137,15 +137,6 @@ impl<A:ToStr> ToStr for @[A] {
137137
}
138138
}
139139
140-
impl<A:ToStr> ToStr for @A {
141-
#[inline(always)]
142-
pure fn to_str(&self) -> ~str { ~"@" + (**self).to_str() }
143-
}
144-
impl<A:ToStr> ToStr for ~A {
145-
#[inline(always)]
146-
pure fn to_str(&self) -> ~str { ~"~" + (**self).to_str() }
147-
}
148-
149140
#[cfg(test)]
150141
#[allow(non_implicitly_copyable_typarams)]
151142
mod tests {
@@ -170,19 +161,12 @@ mod tests {
170161
}
171162

172163
#[test]
173-
#[ignore]
174164
fn test_vectors() {
175165
let x: ~[int] = ~[];
176-
assert x.to_str() == ~"~[]";
177-
assert (~[1]).to_str() == ~"~[1]";
178-
assert (~[1, 2, 3]).to_str() == ~"~[1, 2, 3]";
166+
assert x.to_str() == ~"[]";
167+
assert (~[1]).to_str() == ~"[1]";
168+
assert (~[1, 2, 3]).to_str() == ~"[1, 2, 3]";
179169
assert (~[~[], ~[1], ~[1, 1]]).to_str() ==
180-
~"~[~[], ~[1], ~[1, 1]]";
181-
}
182-
183-
#[test]
184-
fn test_pointer_types() {
185-
assert (@1).to_str() == ~"@1";
186-
assert (~(true, false)).to_str() == ~"~(true, false)";
170+
~"[[], [1], [1, 1]]";
187171
}
188172
}

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: () } }

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
}

src/librustc/middle/trans/_match.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ pub fn compare_values(cx: block,
10541054
let scratch_rhs = alloca(cx, val_ty(rhs));
10551055
Store(cx, rhs, scratch_rhs);
10561056
let did = cx.tcx().lang_items.uniq_str_eq_fn();
1057-
let bcx = callee::trans_rtcall_or_lang_call(cx, did,
1057+
let bcx = callee::trans_lang_call(cx, did,
10581058
~[scratch_lhs,
10591059
scratch_rhs],
10601060
expr::SaveIn(
@@ -1069,7 +1069,7 @@ pub fn compare_values(cx: block,
10691069
let scratch_result = scratch_datum(cx, ty::mk_bool(cx.tcx()),
10701070
false);
10711071
let did = cx.tcx().lang_items.str_eq_fn();
1072-
let bcx = callee::trans_rtcall_or_lang_call(cx, did,
1072+
let bcx = callee::trans_lang_call(cx, did,
10731073
~[lhs, rhs],
10741074
expr::SaveIn(
10751075
scratch_result.val));

src/librustc/middle/trans/base.rs

Lines changed: 5 additions & 2 deletions
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
}
@@ -304,7 +307,7 @@ pub fn malloc_raw_dyn(bcx: block,
304307
// Allocate space:
305308
let tydesc = PointerCast(bcx, static_ti.tydesc, T_ptr(T_i8()));
306309
let rval = alloca(bcx, T_ptr(T_i8()));
307-
let bcx = callee::trans_rtcall_or_lang_call(
310+
let bcx = callee::trans_lang_call(
308311
bcx,
309312
langcall,
310313
~[tydesc, size],

0 commit comments

Comments
 (0)