Skip to content

Commit edc86d6

Browse files
committed
---
yaml --- r: 61320 b: refs/heads/try c: 6a6076a h: refs/heads/master v: v3
1 parent 99c1951 commit edc86d6

Some content is hidden

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

95 files changed

+1771
-915
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2d28d645422c1617be58c8ca7ad9a457264ca850
5-
refs/heads/try: a2a8596c3dd963e7b51f11998cffc46033bf6d63
5+
refs/heads/try: 6a6076ae810d470dfb511712c303a4ee7ffedf00
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/.swo

-72 KB
Binary file not shown.

branches/try/src/compiletest/runtest.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
264264
fatal(~"gdb failed to execute");
265265
}
266266

267-
let num_check_lines = check_lines.len();
267+
let num_check_lines = vec::len(check_lines);
268268
if num_check_lines > 0 {
269269
// check if each line in props.check_lines appears in the
270270
// output (in order)
@@ -303,7 +303,7 @@ fn check_error_patterns(props: &TestProps,
303303
if str::contains(line, *next_err_pat) {
304304
debug!("found error pattern %s", *next_err_pat);
305305
next_err_idx += 1u;
306-
if next_err_idx == props.error_patterns.len() {
306+
if next_err_idx == vec::len(props.error_patterns) {
307307
debug!("found all error patterns");
308308
done = true;
309309
break;
@@ -315,8 +315,8 @@ fn check_error_patterns(props: &TestProps,
315315

316316
let missing_patterns =
317317
vec::slice(props.error_patterns, next_err_idx,
318-
props.error_patterns.len());
319-
if missing_patterns.len() == 1u {
318+
vec::len(props.error_patterns));
319+
if vec::len(missing_patterns) == 1u {
320320
fatal_ProcRes(fmt!("error pattern '%s' not found!",
321321
missing_patterns[0]), ProcRes);
322322
} else {
@@ -333,7 +333,7 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
333333

334334
// true if we found the error in question
335335
let mut found_flags = vec::from_elem(
336-
expected_errors.len(), false);
336+
vec::len(expected_errors), false);
337337

338338
if ProcRes.status == 0 {
339339
fatal(~"process did not return an error status");
@@ -377,7 +377,7 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
377377
}
378378
}
379379

380-
for uint::range(0u, found_flags.len()) |i| {
380+
for uint::range(0u, vec::len(found_flags)) |i| {
381381
if !found_flags[i] {
382382
let ee = &expected_errors[i];
383383
fatal_ProcRes(fmt!("expected %s on line %u not found: %s",

branches/try/src/libcore/core.rc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,11 @@ mod unicode;
205205
#[path = "num/cmath.rs"]
206206
mod cmath;
207207
mod stackwalk;
208+
209+
// XXX: This shouldn't be pub, and it should be reexported under 'unstable'
210+
// but name resolution doesn't work without it being pub.
208211
#[path = "rt/mod.rs"]
209-
mod rt;
212+
pub mod rt;
210213

211214
// A curious inner-module that's not exported that contains the binding
212215
// 'core' so that macro-expanded references to core::error and such

branches/try/src/libcore/either.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,14 @@ fn test_lefts() {
201201
fn test_lefts_none() {
202202
let input: ~[Either<int, int>] = ~[Right(10), Right(10)];
203203
let result = lefts(input);
204-
assert_eq!(result.len(), 0u);
204+
assert_eq!(vec::len(result), 0u);
205205
}
206206

207207
#[test]
208208
fn test_lefts_empty() {
209209
let input: ~[Either<int, int>] = ~[];
210210
let result = lefts(input);
211-
assert_eq!(result.len(), 0u);
211+
assert_eq!(vec::len(result), 0u);
212212
}
213213

214214
#[test]
@@ -222,14 +222,14 @@ fn test_rights() {
222222
fn test_rights_none() {
223223
let input: ~[Either<int, int>] = ~[Left(10), Left(10)];
224224
let result = rights(input);
225-
assert_eq!(result.len(), 0u);
225+
assert_eq!(vec::len(result), 0u);
226226
}
227227

228228
#[test]
229229
fn test_rights_empty() {
230230
let input: ~[Either<int, int>] = ~[];
231231
let result = rights(input);
232-
assert_eq!(result.len(), 0u);
232+
assert_eq!(vec::len(result), 0u);
233233
}
234234

235235
#[test]
@@ -247,22 +247,22 @@ fn test_partition() {
247247
fn test_partition_no_lefts() {
248248
let input: ~[Either<int, int>] = ~[Right(10), Right(11)];
249249
let (lefts, rights) = partition(input);
250-
assert_eq!(lefts.len(), 0u);
251-
assert_eq!(rights.len(), 2u);
250+
assert_eq!(vec::len(lefts), 0u);
251+
assert_eq!(vec::len(rights), 2u);
252252
}
253253

254254
#[test]
255255
fn test_partition_no_rights() {
256256
let input: ~[Either<int, int>] = ~[Left(10), Left(11)];
257257
let (lefts, rights) = partition(input);
258-
assert_eq!(lefts.len(), 2u);
259-
assert_eq!(rights.len(), 0u);
258+
assert_eq!(vec::len(lefts), 2u);
259+
assert_eq!(vec::len(rights), 0u);
260260
}
261261

262262
#[test]
263263
fn test_partition_empty() {
264264
let input: ~[Either<int, int>] = ~[];
265265
let (lefts, rights) = partition(input);
266-
assert_eq!(lefts.len(), 0u);
267-
assert_eq!(rights.len(), 0u);
266+
assert_eq!(vec::len(lefts), 0u);
267+
assert_eq!(vec::len(rights), 0u);
268268
}

branches/try/src/libcore/io.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -673,10 +673,10 @@ impl<T:Reader> ReaderUtil for T {
673673

674674
fn read_char(&self) -> char {
675675
let c = self.read_chars(1);
676-
if c.len() == 0 {
676+
if vec::len(c) == 0 {
677677
return -1 as char; // FIXME will this stay valid? // #2004
678678
}
679-
assert!(c.len() == 1);
679+
assert!((vec::len(c) == 1));
680680
return c[0];
681681
}
682682

@@ -1802,7 +1802,7 @@ mod tests {
18021802
fn test_readchars_empty() {
18031803
do io::with_str_reader(~"") |inp| {
18041804
let res : ~[char] = inp.read_chars(128);
1805-
assert!(res.len() == 0);
1805+
assert!((vec::len(res) == 0));
18061806
}
18071807
}
18081808

@@ -1841,10 +1841,10 @@ mod tests {
18411841
fn check_read_ln(len : uint, s: &str, ivals: &[int]) {
18421842
do io::with_str_reader(s) |inp| {
18431843
let res : ~[char] = inp.read_chars(len);
1844-
if len <= ivals.len() {
1845-
assert!(res.len() == len);
1844+
if (len <= vec::len(ivals)) {
1845+
assert!((vec::len(res) == len));
18461846
}
1847-
assert!(vec::slice(ivals, 0u, res.len()) ==
1847+
assert!(vec::slice(ivals, 0u, vec::len(res)) ==
18481848
vec::map(res, |x| *x as int));
18491849
}
18501850
}

branches/try/src/libcore/logging.rs

Lines changed: 50 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,16 @@
1010

1111
//! Logging
1212
13-
pub mod rustrt {
14-
use libc;
15-
16-
pub extern {
17-
unsafe fn rust_log_console_on();
18-
unsafe fn rust_log_console_off();
19-
unsafe fn rust_log_str(level: u32,
20-
string: *libc::c_char,
21-
size: libc::size_t);
22-
}
23-
}
13+
use option::*;
14+
use either::*;
15+
use rt;
16+
use rt::logging::{Logger, StdErrLogger};
17+
use io;
18+
use libc;
19+
use repr;
20+
use vec;
21+
use cast;
22+
use str;
2423

2524
/// Turns on logging to stdout globally
2625
pub fn console_on() {
@@ -55,8 +54,46 @@ pub fn log_type<T>(level: u32, object: &T) {
5554
let bytes = do io::with_bytes_writer |writer| {
5655
repr::write_repr(writer, object);
5756
};
57+
58+
match rt::context() {
59+
rt::OldTaskContext => {
60+
unsafe {
61+
let len = bytes.len() as libc::size_t;
62+
rustrt::rust_log_str(level, cast::transmute(vec::raw::to_ptr(bytes)), len);
63+
}
64+
}
65+
_ => {
66+
// XXX: Bad allocation
67+
let msg = str::from_bytes(bytes);
68+
newsched_log_str(msg);
69+
}
70+
}
71+
}
72+
73+
fn newsched_log_str(msg: ~str) {
5874
unsafe {
59-
let len = bytes.len() as libc::size_t;
60-
rustrt::rust_log_str(level, transmute(vec::raw::to_ptr(bytes)), len);
75+
match rt::local_services::unsafe_try_borrow_local_services() {
76+
Some(local) => {
77+
// Use the available logger
78+
(*local).logger.log(Left(msg));
79+
}
80+
None => {
81+
// There is no logger anywhere, just write to stderr
82+
let mut logger = StdErrLogger;
83+
logger.log(Left(msg));
84+
}
85+
}
86+
}
87+
}
88+
89+
pub mod rustrt {
90+
use libc;
91+
92+
pub extern {
93+
unsafe fn rust_log_console_on();
94+
unsafe fn rust_log_console_off();
95+
unsafe fn rust_log_str(level: u32,
96+
string: *libc::c_char,
97+
size: libc::size_t);
6198
}
6299
}

branches/try/src/libcore/macros.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,24 @@ macro_rules! rtdebug (
3030
($( $arg:expr),+) => ( $(let _ = $arg)*; )
3131
)
3232

33+
macro_rules! rtassert (
34+
( $arg:expr ) => ( {
35+
if !$arg {
36+
abort!("assertion failed: %s", stringify!($arg));
37+
}
38+
} )
39+
)
40+
3341
macro_rules! abort(
3442
($( $msg:expr),+) => ( {
3543
rtdebug!($($msg),+);
3644

37-
unsafe { ::libc::abort(); }
45+
do_abort();
46+
47+
// NB: This is in a fn to avoid putting the `unsafe` block in a macro,
48+
// which causes spurious 'unnecessary unsafe block' warnings.
49+
fn do_abort() -> ! {
50+
unsafe { ::libc::abort(); }
51+
}
3852
} )
3953
)

branches/try/src/libcore/os.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ pub fn self_exe_path() -> Option<Path> {
410410
KERN_PROC as c_int,
411411
KERN_PROC_PATHNAME as c_int, -1 as c_int];
412412
let mut sz = sz;
413-
sysctl(vec::raw::to_ptr(mib), mib.len() as ::libc::c_uint,
413+
sysctl(vec::raw::to_ptr(mib), vec::len(mib) as ::libc::c_uint,
414414
buf as *mut c_void, &mut sz, ptr::null(),
415415
0u as size_t) == (0 as c_int)
416416
}
@@ -722,7 +722,7 @@ pub fn list_dir(p: &Path) -> ~[~str] {
722722
use os::win32::{
723723
as_utf16_p
724724
};
725-
use unstable::exchange_alloc::{malloc_raw, free_raw};
725+
use rt::global_heap::{malloc_raw, free_raw};
726726
#[nolink]
727727
extern {
728728
unsafe fn rust_list_dir_wfd_size() -> libc::size_t;
@@ -1490,7 +1490,7 @@ mod tests {
14901490
#[ignore]
14911491
fn test_env_getenv() {
14921492
let e = env();
1493-
assert!(e.len() > 0u);
1493+
assert!(vec::len(e) > 0u);
14941494
for e.each |p| {
14951495
let (n, v) = copy *p;
14961496
debug!(copy n);
@@ -1581,7 +1581,7 @@ mod tests {
15811581
fn list_dir() {
15821582
let dirs = os::list_dir(&Path("."));
15831583
// Just assuming that we've got some contents in the current directory
1584-
assert!(dirs.len() > 0u);
1584+
assert!((vec::len(dirs) > 0u));
15851585
15861586
for dirs.each |dir| {
15871587
debug!(copy *dir);

branches/try/src/libcore/ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ pub mod ptr_tests {
441441
let arr_ptr = &arr[0];
442442
let mut ctr = 0;
443443
let mut iteration_count = 0;
444-
array_each_with_len(arr_ptr, arr.len(),
444+
array_each_with_len(arr_ptr, vec::len(arr),
445445
|e| {
446446
let actual = str::raw::from_c_str(e);
447447
let expected = copy expected_arr[ctr];

branches/try/src/libcore/rt/context.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ fn initialize_call_frame(regs: &mut Registers, fptr: *c_void, arg: *c_void, sp:
111111
let sp = align_down(sp);
112112
let sp = mut_offset(sp, -4);
113113

114-
unsafe { *sp = arg as uint; }
114+
unsafe { *sp = arg as uint };
115115
let sp = mut_offset(sp, -1);
116-
unsafe { *sp = 0; } // The final return address
116+
unsafe { *sp = 0 }; // The final return address
117117

118118
regs.esp = sp as u32;
119119
regs.eip = fptr as u32;
@@ -195,7 +195,7 @@ fn initialize_call_frame(regs: &mut Registers, fptr: *c_void, arg: *c_void, sp:
195195

196196
fn align_down(sp: *mut uint) -> *mut uint {
197197
unsafe {
198-
let sp = transmute::<*mut uint, uint>(sp);
198+
let sp: uint = transmute(sp);
199199
let sp = sp & !(16 - 1);
200200
transmute::<uint, *mut uint>(sp)
201201
}

branches/try/src/libcore/rt/io/file.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use prelude::*;
1212
use super::support::PathLike;
13-
use super::{Reader, Writer, Seek, Close};
13+
use super::{Reader, Writer, Seek};
1414
use super::SeekStyle;
1515

1616
/// # XXX
@@ -69,10 +69,6 @@ impl Seek for FileStream {
6969
fn seek(&mut self, _pos: i64, _style: SeekStyle) { fail!() }
7070
}
7171

72-
impl Close for FileStream {
73-
fn close(&mut self) { fail!() }
74-
}
75-
7672
#[test]
7773
#[ignore]
7874
fn super_simple_smoke_test_lets_go_read_some_files_and_have_a_good_time() {

0 commit comments

Comments
 (0)