Skip to content

Commit 832975b

Browse files
committed
---
yaml --- r: 138590 b: refs/heads/try2 c: 2f858de h: refs/heads/master v: v3
1 parent 5a5f69d commit 832975b

Some content is hidden

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

70 files changed

+824
-1254
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: c705440ee3f98a01c0e840202f320ed7998221d6
8+
refs/heads/try2: 2f858de1c39f3fd8bdc77a6517e12a6458c54f03
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/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

branches/try2/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

branches/try2/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
}

branches/try2/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 {

branches/try2/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);

branches/try2/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
}

branches/try2/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
}

branches/try2/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

branches/try2/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));

branches/try2/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
}

branches/try2/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
}

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

branches/try2/src/librustc/front/test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,14 @@ fn is_bench_fn(i: @ast::item) -> bool {
200200
vec::len(attr::find_attrs_by_name(i.attrs, ~"bench")) > 0u;
201201

202202
fn has_test_signature(i: @ast::item) -> bool {
203-
match i.node {
204-
ast::item_fn(ref decl, _, ref generics, _) => {
203+
match /*bad*/copy i.node {
204+
ast::item_fn(decl, _, tps, _) => {
205205
let input_cnt = vec::len(decl.inputs);
206206
let no_output = match decl.output.node {
207207
ast::ty_nil => true,
208208
_ => false
209209
};
210-
let tparm_cnt = generics.ty_params.len();
210+
let tparm_cnt = vec::len(tps);
211211
// NB: inadequate check, but we're running
212212
// well before resolve, can't get too deep.
213213
input_cnt == 1u

branches/try2/src/librustc/lib/llvm.rs

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

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

14961493
pub struct pass_manager_res {
14971494
PM: PassManagerRef,
1498-
}
1499-
1500-
impl Drop for pass_manager_res {
1501-
fn finalize(&self) {
1495+
drop {
15021496
unsafe {
15031497
llvm::LLVMDisposePassManager(self.PM);
15041498
}
@@ -1531,10 +1525,7 @@ pub fn mk_pass_manager() -> PassManager {
15311525

15321526
pub struct object_file_res {
15331527
ObjectFile: ObjectFileRef,
1534-
}
1535-
1536-
impl Drop for object_file_res {
1537-
fn finalize(&self) {
1528+
drop {
15381529
unsafe {
15391530
llvm::LLVMDisposeObjectFile(self.ObjectFile);
15401531
}
@@ -1568,10 +1559,7 @@ pub fn mk_object_file(llmb: MemoryBufferRef) -> Option<ObjectFile> {
15681559

15691560
pub struct section_iter_res {
15701561
SI: SectionIteratorRef,
1571-
}
1572-
1573-
impl Drop for section_iter_res {
1574-
fn finalize(&self) {
1562+
drop {
15751563
unsafe {
15761564
llvm::LLVMDisposeSectionIterator(self.SI);
15771565
}

0 commit comments

Comments
 (0)