Skip to content

Commit f350a07

Browse files
committed
---
yaml --- r: 10700 b: refs/heads/snap-stage3 c: da470ff h: refs/heads/master v: v3
1 parent 77cfaf4 commit f350a07

Some content is hidden

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

64 files changed

+768
-607
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 2898dcc5d97da9427ac367542382b6239d9c0bbf
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 44d0a061be0ec9cae51c61b7bb335e8c4b8c6cf5
4+
refs/heads/snap-stage3: da470ff5b8b970c90b4dce3885a2908d477c1021
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/snap-stage3/RELEASES.txt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,47 @@
1+
Version 0.3 (June 2012) - not yet!
2+
-----------------------------------
3+
4+
* ~1500 changes, numerous bugfixes
5+
6+
* New coding conveniences
7+
* Integer-literal suffix inference
8+
* Per-module control over warnings, errors
9+
* #[cfg(windows)] and #[cfg(unix)] attributes
10+
11+
* Semantic cleanup
12+
* Resolve pass and exhaustiveness checker rewritten
13+
* Borrow-check taking over from alias-analysis
14+
* Liveness taking over from last-use, typestate
15+
* Extensive work on region pointers
16+
17+
* Experimental new language features
18+
* Slices and fixed-size, interior-allocated vectors
19+
* #!-comments for lang versioning, shell execution
20+
* More work on classes
21+
* Type reflection
22+
23+
* Removal of various obsolete features
24+
* Keywords: be, prove, syntax, note, mutable, do, bind
25+
* Constructs: do-while loops, fn binding,
26+
27+
* Compiler reorganization
28+
* Syntax-layer of compiler split into separate crate
29+
* Clang (from LLVM project) integrated into build
30+
* Typechecker split into sub-modules
31+
32+
* New library code
33+
* New time functions
34+
* Extension methods for many built-in types
35+
* Arc: atomic-refcount read-only / exclusive-use shared cells
36+
* Par: parallel map and search routines
37+
* Extensive work on libuv interface
38+
* Much vector code moved to libraries
39+
* Syntax extensions: #line, #col, #file, #mod,
40+
#stringify, #include, #include_str, #include_bin.
41+
42+
* Tool improvements
43+
* Cargo automatically resolves dependencies
44+
145
Version 0.2 (March 2012)
246
-------------------------
347

branches/snap-stage3/src/libcore/box.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
export ptr_eq;
44

5-
pure fn ptr_eq<T>(a: @T, b: @T) -> bool unchecked {
5+
pure fn ptr_eq<T>(a: @T, b: @T) -> bool {
66
#[doc = "Determine if two shared boxes point to the same object"];
7-
ptr::addr_of(*a) == ptr::addr_of(*b)
7+
unsafe { ptr::addr_of(*a) == ptr::addr_of(*b) }
88
}
99

1010
#[test]

branches/snap-stage3/src/libcore/char.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ fn test_to_digit() {
231231
}
232232

233233
#[test]
234-
fn test_is_ascii() unsafe {
234+
fn test_is_ascii() {
235235
assert str::all("banana", char::is_ascii);
236236
assert ! str::all("ประเทศไทย中华Việt Nam", char::is_ascii);
237237
}

branches/snap-stage3/src/libcore/comm.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,13 @@ fn recv_<T: send>(p: *rust_port) -> T {
210210
ret res;
211211
}
212212

213-
fn peek_(p: *rust_port) -> bool unsafe {
213+
fn peek_(p: *rust_port) -> bool {
214214
rustrt::rust_port_size(p) != 0u as libc::size_t
215215
}
216216

217217
#[doc = "Receive on one of two ports"]
218218
fn select2<A: send, B: send>(p_a: port<A>, p_b: port<B>)
219-
-> either<A, B> unsafe {
219+
-> either<A, B> {
220220
let ports = [(**p_a).po, (**p_b).po];
221221
let n_ports = 2 as libc::size_t;
222222
let yield = 0u, yieldp = ptr::addr_of(yield);
@@ -440,7 +440,7 @@ fn test_recv_chan_wrong_task() {
440440
let po = port();
441441
let ch = chan(po);
442442
send(ch, "flower");
443-
assert result::is_failure(task::try {||
443+
assert result::is_err(task::try {||
444444
recv_chan(ch)
445445
})
446446
}

branches/snap-stage3/src/libcore/core.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import option::extensions;
1111
import option_iter::extensions;
1212
import ptr::extensions;
1313
import rand::extensions;
14+
import result::extensions;
1415

1516
export path, option, some, none, unreachable;
1617
export extensions;

branches/snap-stage3/src/libcore/extfmt.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ mod ct {
8181
enum piece { piece_string(str), piece_conv(conv), }
8282
type error_fn = fn@(str) -> ! ;
8383

84-
fn parse_fmt_string(s: str, error: error_fn) -> [piece] unsafe {
84+
fn parse_fmt_string(s: str, error: error_fn) -> [piece] {
8585
let mut pieces: [piece] = [];
8686
let lim = str::len(s);
8787
let mut buf = "";
@@ -225,7 +225,7 @@ mod ct {
225225
} else { {count: count_implied, next: i} };
226226
}
227227
fn parse_type(s: str, i: uint, lim: uint, error: error_fn) ->
228-
{ty: ty, next: uint} unsafe {
228+
{ty: ty, next: uint} {
229229
if i >= lim { error("missing type in conversion"); }
230230
let tstr = str::slice(s, i, i+1u);
231231
// TODO: Do we really want two signed types here?
@@ -314,7 +314,7 @@ mod rt {
314314
let mut s = str::from_char(c);
315315
ret pad(cv, s, pad_nozero);
316316
}
317-
fn conv_str(cv: conv, s: str) -> str unsafe {
317+
fn conv_str(cv: conv, s: str) -> str {
318318
// For strings, precision is the maximum characters
319319
// displayed
320320
let mut unpadded = alt cv.precision {
@@ -378,7 +378,7 @@ mod rt {
378378
};
379379
}
380380
enum pad_mode { pad_signed, pad_unsigned, pad_nozero, pad_float }
381-
fn pad(cv: conv, &s: str, mode: pad_mode) -> str unsafe {
381+
fn pad(cv: conv, &s: str, mode: pad_mode) -> str {
382382
let uwidth : uint = alt cv.width {
383383
count_implied { ret s; }
384384
count_is(width) {

branches/snap-stage3/src/libcore/int-template.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ fn parse_buf(buf: [u8], radix: uint) -> option<T> {
9393
fn from_str(s: str) -> option<T> { parse_buf(str::bytes(s), 10u) }
9494

9595
#[doc = "Convert to a string in a given base"]
96-
fn to_str(n: T, radix: uint) -> str unsafe {
96+
fn to_str(n: T, radix: uint) -> str {
9797
to_str_bytes(n, radix) {|slice|
9898
vec::unpack_slice(slice) {|p, len|
99-
str::unsafe::from_buf_len(p, len)
99+
unsafe { str::unsafe::from_buf_len(p, len) }
100100
}
101101
}
102102
}

branches/snap-stage3/src/libcore/io.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,13 @@ fn convert_whence(whence: seek_style) -> i32 {
192192
}
193193

194194
impl of reader for *libc::FILE {
195-
fn read_bytes(len: uint) -> [u8] unsafe {
195+
fn read_bytes(len: uint) -> [u8] {
196196
let mut buf : [mut u8] = [mut];
197197
vec::reserve(buf, len);
198198
vec::as_mut_buf(buf) {|b|
199199
let read = libc::fread(b as *mut c_void, 1u as size_t,
200200
len as size_t, self);
201-
vec::unsafe::set_len(buf, read as uint);
201+
unsafe { vec::unsafe::set_len(buf, read as uint) };
202202
}
203203
ret vec::from_mut(buf);
204204
}
@@ -333,7 +333,7 @@ impl <T: writer, C> of writer for {base: T, cleanup: C} {
333333
}
334334

335335
impl of writer for *libc::FILE {
336-
fn write(v: [const u8]/&) unsafe {
336+
fn write(v: [const u8]/&) {
337337
vec::unpack_const_slice(v) {|vbuf, len|
338338
let nout = libc::fwrite(vbuf as *c_void, len as size_t,
339339
1u as size_t, self);
@@ -361,7 +361,7 @@ fn FILE_writer(f: *libc::FILE, cleanup: bool) -> writer {
361361
}
362362

363363
impl of writer for fd_t {
364-
fn write(v: [const u8]/&) unsafe {
364+
fn write(v: [const u8]/&) {
365365
let mut count = 0u;
366366
vec::unpack_const_slice(v) {|vbuf, len|
367367
while count < len {

branches/snap-stage3/src/libcore/option.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,23 @@ pure fn iter<T>(opt: option<T>, f: fn(T)) {
7070
alt opt { none { } some(t) { f(t); } }
7171
}
7272

73-
pure fn unwrap<T>(-opt: option<T>) -> T unsafe {
73+
pure fn unwrap<T>(-opt: option<T>) -> T {
7474
#[doc = "
7575
Moves a value out of an option type and returns it.
7676
7777
Useful primarily for getting strings, vectors and unique pointers out of
7878
option types without copying them.
7979
"];
8080

81-
let addr = alt opt {
82-
some(x) { ptr::addr_of(x) }
83-
none { fail "option none" }
84-
};
85-
let liberated_value = unsafe::reinterpret_cast(*addr);
86-
unsafe::forget(opt);
87-
ret liberated_value;
81+
unsafe {
82+
let addr = alt opt {
83+
some(x) { ptr::addr_of(x) }
84+
none { fail "option none" }
85+
};
86+
let liberated_value = unsafe::reinterpret_cast(*addr);
87+
unsafe::forget(opt);
88+
ret liberated_value;
89+
}
8890
}
8991

9092
impl extensions<T> for option<T> {

branches/snap-stage3/src/libcore/os.rs

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -180,19 +180,21 @@ mod global_env {
180180
}
181181
}
182182

183-
fn global_env_task(msg_po: comm::port<msg>) unsafe {
184-
priv::weaken_task {|weak_po|
185-
loop {
186-
alt comm::select2(msg_po, weak_po) {
187-
either::left(msg_getenv(n, resp_ch)) {
188-
comm::send(resp_ch, impl::getenv(n))
189-
}
190-
either::left(msg_setenv(n, v, resp_ch)) {
191-
comm::send(resp_ch, impl::setenv(n, v))
192-
}
193-
either::right(_) {
194-
break;
195-
}
183+
fn global_env_task(msg_po: comm::port<msg>) {
184+
unsafe {
185+
priv::weaken_task {|weak_po|
186+
loop {
187+
alt comm::select2(msg_po, weak_po) {
188+
either::left(msg_getenv(n, resp_ch)) {
189+
comm::send(resp_ch, impl::getenv(n))
190+
}
191+
either::left(msg_setenv(n, v, resp_ch)) {
192+
comm::send(resp_ch, impl::setenv(n, v))
193+
}
194+
either::right(_) {
195+
break;
196+
}
197+
}
196198
}
197199
}
198200
}
@@ -201,18 +203,20 @@ mod global_env {
201203
mod impl {
202204

203205
#[cfg(unix)]
204-
fn getenv(n: str) -> option<str> unsafe {
205-
let s = str::as_c_str(n, libc::getenv);
206-
ret if unsafe::reinterpret_cast(s) == 0 {
207-
option::none::<str>
208-
} else {
209-
let s = unsafe::reinterpret_cast(s);
210-
option::some::<str>(str::unsafe::from_buf(s))
211-
};
206+
fn getenv(n: str) -> option<str> {
207+
unsafe {
208+
let s = str::as_c_str(n, libc::getenv);
209+
ret if unsafe::reinterpret_cast(s) == 0 {
210+
option::none::<str>
211+
} else {
212+
let s = unsafe::reinterpret_cast(s);
213+
option::some::<str>(str::unsafe::from_buf(s))
214+
};
215+
}
212216
}
213217

214218
#[cfg(windows)]
215-
fn getenv(n: str) -> option<str> unsafe {
219+
fn getenv(n: str) -> option<str> {
216220
import libc::types::os::arch::extra::*;
217221
import libc::funcs::extra::kernel32::*;
218222
import win32::*;
@@ -362,21 +366,23 @@ fn dll_filename(base: str) -> str {
362366
fn self_exe_path() -> option<path> {
363367

364368
#[cfg(target_os = "freebsd")]
365-
fn load_self() -> option<path> unsafe {
366-
import libc::funcs::bsd44::*;
367-
import libc::consts::os::extra::*;
368-
fill_charp_buf() {|buf, sz|
369-
let mib = [CTL_KERN as c_int,
370-
KERN_PROC as c_int,
371-
KERN_PROC_PATHNAME as c_int, -1 as c_int];
372-
sysctl(vec::unsafe::to_ptr(mib), vec::len(mib) as c_uint,
373-
buf as *mut c_void, ptr::mut_addr_of(sz),
374-
ptr::null(), 0u as size_t) == (0 as c_int)
369+
fn load_self() -> option<path> {
370+
unsafe {
371+
import libc::funcs::bsd44::*;
372+
import libc::consts::os::extra::*;
373+
fill_charp_buf() {|buf, sz|
374+
let mib = [CTL_KERN as c_int,
375+
KERN_PROC as c_int,
376+
KERN_PROC_PATHNAME as c_int, -1 as c_int];
377+
sysctl(vec::unsafe::to_ptr(mib), vec::len(mib) as c_uint,
378+
buf as *mut c_void, ptr::mut_addr_of(sz),
379+
ptr::null(), 0u as size_t) == (0 as c_int)
380+
}
375381
}
376382
}
377383

378384
#[cfg(target_os = "linux")]
379-
fn load_self() -> option<path> unsafe {
385+
fn load_self() -> option<path> {
380386
import libc::funcs::posix01::unistd::readlink;
381387
fill_charp_buf() {|buf, sz|
382388
as_c_charp("/proc/self/exe") { |proc_self_buf|
@@ -386,17 +392,18 @@ fn self_exe_path() -> option<path> {
386392
}
387393

388394
#[cfg(target_os = "macos")]
389-
fn load_self() -> option<path> unsafe {
395+
fn load_self() -> option<path> {
390396
// FIXME: remove imports when export globs work properly. #1238
391397
import libc::funcs::extra::*;
398+
392399
fill_charp_buf() {|buf, sz|
393400
_NSGetExecutablePath(buf, ptr::mut_addr_of(sz as u32))
394401
== (0 as c_int)
395402
}
396403
}
397404

398405
#[cfg(windows)]
399-
fn load_self() -> option<path> unsafe {
406+
fn load_self() -> option<path> {
400407
// FIXME: remove imports when export globs work properly. #1238
401408
import libc::types::os::arch::extra::*;
402409
import libc::funcs::extra::kernel32::*;
@@ -525,14 +532,14 @@ fn make_dir(p: path, mode: c_int) -> bool {
525532
ret mkdir(p, mode);
526533

527534
#[cfg(windows)]
528-
fn mkdir(p: path, _mode: c_int) -> bool unsafe {
535+
fn mkdir(p: path, _mode: c_int) -> bool {
529536
// FIXME: remove imports when export globs work properly. #1238
530537
import libc::types::os::arch::extra::*;
531538
import libc::funcs::extra::kernel32::*;
532539
import win32::*;
533540
// FIXME: turn mode into something useful? #2623
534541
as_utf16_p(p) {|buf|
535-
CreateDirectoryW(buf, unsafe::reinterpret_cast(0))
542+
CreateDirectoryW(buf, unsafe { unsafe::reinterpret_cast(0) })
536543
!= (0 as BOOL)
537544
}
538545
}
@@ -645,7 +652,7 @@ fn copy_file(from: path, to: path) -> bool {
645652
}
646653

647654
#[cfg(unix)]
648-
fn do_copy_file(from: path, to: path) -> bool unsafe {
655+
fn do_copy_file(from: path, to: path) -> bool {
649656
let istream = as_c_charp(from) {|fromp|
650657
as_c_charp("rb") {|modebuf|
651658
libc::fopen(fromp, modebuf)

branches/snap-stage3/src/libcore/path.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,20 @@ Given paths `pre` and `post, removes any trailing path separator on `pre` and
105105
any leading path separator on `post`, and returns the concatenation of the two
106106
with a single path separator between them.
107107
"]
108-
fn connect(pre: path, post: path) -> path unsafe {
108+
fn connect(pre: path, post: path) -> path {
109109
let mut pre_ = pre;
110110
let mut post_ = post;
111111
let sep = consts::path_sep as u8;
112112
let pre_len = str::len(pre);
113113
let post_len = str::len(post);
114-
if pre_len > 1u && pre[pre_len-1u] == sep { str::unsafe::pop_byte(pre_); }
115-
if post_len > 1u && post[0] == sep { str::unsafe::shift_byte(post_); }
114+
unsafe {
115+
if pre_len > 1u && pre[pre_len-1u] == sep {
116+
str::unsafe::pop_byte(pre_);
117+
}
118+
if post_len > 1u && post[0] == sep {
119+
str::unsafe::shift_byte(post_);
120+
}
121+
}
116122
ret pre_ + path_sep() + post_;
117123
}
118124

0 commit comments

Comments
 (0)