Skip to content

Commit db1d3a1

Browse files
committed
---
yaml --- r: 44824 b: refs/heads/master c: 3953bdd h: refs/heads/master v: v3
1 parent 28ff4fd commit db1d3a1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+2968
-2428
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: 833ad6018e0fcb4f1fda1ca54feb8256bad27513
2+
refs/heads/master: 3953bdd812d73a51f9a7be4a1c57c60d56c6aa1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d9689399d091c3265f00434a69c551a61c28dc
55
refs/heads/try: ef355f6332f83371e4acf04fc4eb940ab41d78d3

trunk/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

trunk/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::local_free;
157+
use rt::rt_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-
local_free(transmute(box));
195+
rt_free(transmute(box));
196196
}
197197
}
198198

trunk/src/libcore/core.rc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012 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
//
@@ -41,7 +41,7 @@ Implicitly, all crates behave as if they included the following prologue:
4141
url = "https://github.com/mozilla/rust/tree/master/src/libcore")];
4242

4343
#[comment = "The Rust core library"];
44-
#[license = "MIT/APL2"];
44+
#[license = "MIT"];
4545
#[crate_type = "lib"];
4646

4747

trunk/src/libcore/io.rs

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

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

687684
pub struct FdRes {
688685
fd: fd_t,
689-
}
690-
691-
impl Drop for FdRes {
692-
fn finalize(&self) {
686+
drop {
693687
unsafe {
694688
libc::close(self.fd);
695689
}

trunk/src/libcore/option.rs

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

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

trunk/src/libcore/pipes.rs

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

trunk/src/libcore/private.rs

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

127127
struct ArcDestruct<T> {
128128
mut data: *libc::c_void,
129-
}
130-
131-
impl<T> Drop for ArcDestruct<T>{
132-
fn finalize(&self) {
129+
drop {
133130
unsafe {
134131
if self.data.is_null() {
135132
return; // Happens when destructing an unwrapper's handle.
@@ -181,10 +178,7 @@ pub unsafe fn unwrap_shared_mutable_state<T:Owned>(rc: SharedMutableState<T>)
181178
struct DeathThroes<T> {
182179
mut ptr: Option<~ArcData<T>>,
183180
mut response: Option<comm::ChanOne<bool>>,
184-
}
185-
186-
impl<T> Drop for DeathThroes<T>{
187-
fn finalize(&self) {
181+
drop {
188182
unsafe {
189183
let response = option::swap_unwrap(&mut self.response);
190184
// In case we get killed early, we need to tell the person who
@@ -317,10 +311,7 @@ type rust_little_lock = *libc::c_void;
317311
318312
struct LittleLock {
319313
l: rust_little_lock,
320-
}
321-
322-
impl Drop for LittleLock {
323-
fn finalize(&self) {
314+
drop {
324315
unsafe {
325316
rustrt::rust_destroy_little_lock(self.l);
326317
}

trunk/src/libcore/rand.rs

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

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

trunk/src/libcore/rt.rs

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

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

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

54-
pub unsafe fn fail_borrowed() {
56+
pub unsafe fn rt_fail_borrowed() {
5557
let msg = "borrowed";
5658
do str::as_buf(msg) |msg_p, _| {
5759
do str::as_buf("???") |file_p, _| {
58-
fail_(msg_p as *c_char, file_p as *c_char, 0);
60+
rt_fail_(msg_p as *c_char, file_p as *c_char, 0);
5961
}
6062
}
6163
}
6264

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

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

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

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

@@ -106,7 +112,7 @@ pub unsafe fn return_to_mut(a: *u8) {
106112
pub unsafe fn check_not_borrowed(a: *u8) {
107113
let a: *mut BoxRepr = transmute(a);
108114
if ((*a).header.ref_count & FROZEN_BIT) != 0 {
109-
fail_borrowed();
115+
rt_fail_borrowed();
110116
}
111117
}
112118

trunk/src/libcore/run.rs

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

trunk/src/libcore/task/spawn.rs

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

trunk/src/libcore/to_str.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012 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,6 +137,15 @@ 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+
140149
#[cfg(test)]
141150
#[allow(non_implicitly_copyable_typarams)]
142151
mod tests {
@@ -161,12 +170,19 @@ mod tests {
161170
}
162171

163172
#[test]
173+
#[ignore]
164174
fn test_vectors() {
165175
let x: ~[int] = ~[];
166-
assert x.to_str() == ~"[]";
167-
assert (~[1]).to_str() == ~"[1]";
168-
assert (~[1, 2, 3]).to_str() == ~"[1, 2, 3]";
176+
assert x.to_str() == ~"~[]";
177+
assert (~[1]).to_str() == ~"~[1]";
178+
assert (~[1, 2, 3]).to_str() == ~"~[1, 2, 3]";
169179
assert (~[~[], ~[1], ~[1, 1]]).to_str() ==
170-
~"[[], [1], [1, 1]]";
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)";
171187
}
172188
}

trunk/src/libcore/util.rs

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

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

0 commit comments

Comments
 (0)