Skip to content

Commit 8a8c21f

Browse files
committed
---
yaml --- r: 144574 b: refs/heads/try2 c: a2ffcea h: refs/heads/master v: v3
1 parent 3331fde commit 8a8c21f

File tree

13 files changed

+81
-150
lines changed

13 files changed

+81
-150
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: 8e3efc112f8eb61716c5e8c3fea8f2ef03d88498
8+
refs/heads/try2: a2ffceaedd5d80a83bafd3e930541c1d32424604
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/etc/emacs/rust-mode.el

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
;; Url: https://github.com/mozilla/rust
66

77
(eval-when-compile (require 'cl))
8-
(eval-when-compile (require 'misc))
98

109
;; Syntax definitions and helpers
1110
(defvar rust-mode-syntax-table
@@ -58,39 +57,19 @@
5857
;; A closing brace is 1 level unindended
5958
((looking-at "}") (* rust-indent-offset (- level 1)))
6059

61-
; Doc comments in /** style with leading * indent to line up the *s
62-
((and (nth 4 (syntax-ppss)) (looking-at "*"))
63-
(+ 1 (* rust-indent-offset level)))
64-
6560
;; If we're in any other token-tree / sexp, then:
6661
;; - [ or ( means line up with the opening token
6762
;; - { means indent to either nesting-level * rust-indent-offset,
6863
;; or one further indent from that if either current line
6964
;; begins with 'else', or previous line didn't end in
70-
;; semi, comma or brace (other than whitespace and line
71-
;; comments) , and wasn't an attribute. But if we have
72-
;; something after the open brace and ending with a comma,
73-
;; treat it as fields and align them. PHEW.
65+
;; semi, comma or brace, and wasn't an attribute. PHEW.
7466
((> level 0)
7567
(let ((pt (point)))
7668
(rust-rewind-irrelevant)
7769
(backward-up-list)
78-
(cond
79-
((and
80-
(looking-at "[[(]")
81-
; We don't want to indent out to the open bracket if the
82-
; open bracket ends the line
83-
(save-excursion
84-
(forward-char)
85-
(not (looking-at "[[:space:]]*\\(?://.*\\)?$"))))
86-
(+ 1 (current-column)))
87-
;; Check for fields on the same line as the open curly brace:
88-
((looking-at "{[[:blank:]]*[^}\n]*,[[:space:]]*$")
70+
(if (looking-at "[[(]")
71+
(+ 1 (current-column))
8972
(progn
90-
(forward-char)
91-
(forward-to-word 1)
92-
(current-column)))
93-
(t (progn
9473
(goto-char pt)
9574
(back-to-indentation)
9675
(if (looking-at "\\<else\\>")
@@ -100,12 +79,12 @@
10079
(beginning-of-line)
10180
(rust-rewind-irrelevant)
10281
(end-of-line)
103-
(if (looking-back "[,;{}(][[:space:]]*\\(?://.*\\)?")
82+
(if (looking-back "[{};,]")
10483
(* rust-indent-offset level)
10584
(back-to-indentation)
10685
(if (looking-at "#")
10786
(* rust-indent-offset level)
108-
(* rust-indent-offset (+ 1 level)))))))))))
87+
(* rust-indent-offset (+ 1 level))))))))))
10988

11089
;; Otherwise we're in a column-zero definition
11190
(t 0))))))

branches/try2/src/libextra/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ fn get_concurrency() -> uint {
745745
let opt_n: Option<uint> = FromStr::from_str(s);
746746
match opt_n {
747747
Some(n) if n > 0 => n,
748-
_ => fail!("RUST_TEST_TASKS is `%s`, should be a positive integer.", s)
748+
_ => fail!("RUST_TEST_TASKS is `%s`, should be a non-negative integer.", s)
749749
}
750750
}
751751
None => {

branches/try2/src/librustc/middle/resolve.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2585,13 +2585,11 @@ impl Resolver {
25852585
debug!("(resolving glob import) ... for value target");
25862586
dest_import_resolution.value_target =
25872587
Some(Target(containing_module, name_bindings));
2588-
dest_import_resolution.value_id = id;
25892588
}
25902589
if name_bindings.defined_in_public_namespace(TypeNS) {
25912590
debug!("(resolving glob import) ... for type target");
25922591
dest_import_resolution.type_target =
25932592
Some(Target(containing_module, name_bindings));
2594-
dest_import_resolution.type_id = id;
25952593
}
25962594
};
25972595

branches/try2/src/libstd/io.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ pub trait ReaderUtil {
619619

620620
impl<T:Reader> ReaderUtil for T {
621621

622-
fn read_bytes(&self,len: uint) -> ~[u8] {
622+
fn read_bytes(&self, len: uint) -> ~[u8] {
623623
let mut bytes = vec::with_capacity(len);
624624
unsafe { vec::raw::set_len(&mut bytes, len); }
625625

branches/try2/src/libstd/rt/args.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,10 @@ pub fn clone() -> Option<~[~str]> {
5555
mod imp {
5656
use libc;
5757
use option::{Option, Some, None};
58-
use iterator::Iterator;
58+
use iterator::{Iterator, range};
5959
use str;
6060
use unstable::finally::Finally;
6161
use util;
62-
use vec;
6362

6463
pub unsafe fn init(argc: int, argv: **u8) {
6564
let args = load_argc_and_argv(argc, argv);
@@ -112,9 +111,11 @@ mod imp {
112111

113112
// Copied from `os`.
114113
unsafe fn load_argc_and_argv(argc: int, argv: **u8) -> ~[~str] {
115-
do vec::from_fn(argc as uint) |i| {
116-
str::raw::from_c_str(*(argv as **libc::c_char).offset(i as int))
114+
let mut args = ~[];
115+
for i in range(0u, argc as uint) {
116+
args.push(str::raw::from_c_str(*(argv as **libc::c_char).offset(i as int)));
117117
}
118+
args
118119
}
119120

120121
#[cfg(stage0)]

branches/try2/src/libstd/rt/local_ptr.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,20 +121,27 @@ pub unsafe fn borrow<T>(f: &fn(&mut T)) {
121121
/// For the Scheduler pointer to be aliased
122122
pub unsafe fn unsafe_borrow<T>() -> *mut T {
123123
let key = tls_key();
124-
let void_ptr = tls::get(key);
124+
let mut void_ptr: *mut c_void = tls::get(key);
125125
if void_ptr.is_null() {
126126
rtabort!("thread-local pointer is null. bogus!");
127127
}
128-
void_ptr as *mut T
128+
let ptr: *mut *mut c_void = &mut void_ptr;
129+
let ptr: *mut ~T = ptr as *mut ~T;
130+
let ptr: *mut T = &mut **ptr;
131+
return ptr;
129132
}
130133

131134
pub unsafe fn try_unsafe_borrow<T>() -> Option<*mut T> {
132135
let key = tls_key();
133-
let void_ptr = tls::get(key);
136+
let mut void_ptr: *mut c_void = tls::get(key);
134137
if void_ptr.is_null() {
135-
None
136-
} else {
137-
Some(void_ptr as *mut T)
138+
return None;
139+
}
140+
{
141+
let ptr: *mut *mut c_void = &mut void_ptr;
142+
let ptr: *mut ~T = ptr as *mut ~T;
143+
let ptr: *mut T = &mut **ptr;
144+
return Some(ptr);
138145
}
139146
}
140147

branches/try2/src/libstd/rt/mod.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Several modules in `core` are clients of `rt`:
5959
use cell::Cell;
6060
use clone::Clone;
6161
use container::Container;
62-
use iterator::Iterator;
62+
use iterator::{Iterator, range};
6363
use option::{Option, None, Some};
6464
use ptr::RawPtr;
6565
use rt::local::Local;
@@ -71,8 +71,7 @@ use rt::work_queue::WorkQueue;
7171
use rt::uv::uvio::UvEventLoop;
7272
use unstable::atomics::{AtomicInt, SeqCst};
7373
use unstable::sync::UnsafeArc;
74-
use vec;
75-
use vec::{OwnedVector, MutableVector, ImmutableVector};
74+
use vec::{OwnedVector, MutableVector};
7675

7776
/// The global (exchange) heap.
7877
pub mod global_heap;
@@ -252,21 +251,25 @@ fn run_(main: ~fn(), use_main_sched: bool) -> int {
252251

253252
// Create a work queue for each scheduler, ntimes. Create an extra
254253
// for the main thread if that flag is set. We won't steal from it.
255-
let work_queues: ~[WorkQueue<~Task>] = vec::from_fn(nscheds, |_| WorkQueue::new());
254+
let mut work_queues = ~[];
255+
for _ in range(0u, nscheds) {
256+
let work_queue: WorkQueue<~Task> = WorkQueue::new();
257+
work_queues.push(work_queue);
258+
}
256259

257260
// The schedulers.
258261
let mut scheds = ~[];
259262
// Handles to the schedulers. When the main task ends these will be
260263
// sent the Shutdown message to terminate the schedulers.
261264
let mut handles = ~[];
262265

263-
for work_queue in work_queues.iter() {
266+
for i in range(0u, nscheds) {
264267
rtdebug!("inserting a regular scheduler");
265268

266269
// Every scheduler is driven by an I/O event loop.
267270
let loop_ = ~UvEventLoop::new();
268271
let mut sched = ~Scheduler::new(loop_,
269-
work_queue.clone(),
272+
work_queues[i].clone(),
270273
work_queues.clone(),
271274
sleepers.clone());
272275
let handle = sched.make_handle();
@@ -355,8 +358,9 @@ fn run_(main: ~fn(), use_main_sched: bool) -> int {
355358
}
356359

357360
// Run each remaining scheduler in a thread.
358-
for sched in scheds.move_rev_iter() {
361+
while !scheds.is_empty() {
359362
rtdebug!("creating regular schedulers");
363+
let sched = scheds.pop();
360364
let sched_cell = Cell::new(sched);
361365
let thread = do Thread::start {
362366
let mut sched = sched_cell.take();

branches/try2/src/libstd/rt/util.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use container::Container;
1212
use from_str::FromStr;
1313
use libc;
14-
use option::{Some, None, Option};
14+
use option::{Some, None};
1515
use os;
1616
use str::StrSlice;
1717
use unstable::atomics::{AtomicInt, INIT_ATOMIC_INT, SeqCst};
@@ -57,13 +57,7 @@ pub fn limit_thread_creation_due_to_osx_and_valgrind() -> bool {
5757
/// either `RUST_THREADS` or `num_cpus`.
5858
pub fn default_sched_threads() -> uint {
5959
match os::getenv("RUST_THREADS") {
60-
Some(nstr) => {
61-
let opt_n: Option<uint> = FromStr::from_str(nstr);
62-
match opt_n {
63-
Some(n) if n > 0 => n,
64-
_ => rtabort!("`RUST_THREADS` is `%s`, should be a positive integer", nstr)
65-
}
66-
}
60+
Some(nstr) => FromStr::from_str(nstr).unwrap(),
6761
None => {
6862
if limit_thread_creation_due_to_osx_and_valgrind() {
6963
1

branches/try2/src/libstd/str.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,46 @@ pub fn with_capacity(capacity: uint) -> ~str {
907907
}
908908
}
909909

910+
/// As char_len but for a slice of a string
911+
///
912+
/// # Arguments
913+
///
914+
/// * s - A valid string
915+
/// * start - The position inside `s` where to start counting in bytes
916+
/// * end - The position where to stop counting
917+
///
918+
/// # Return value
919+
///
920+
/// The number of Unicode characters in `s` between the given indices.
921+
pub fn count_chars(s: &str, start: uint, end: uint) -> uint {
922+
assert!(s.is_char_boundary(start));
923+
assert!(s.is_char_boundary(end));
924+
let mut i = start;
925+
let mut len = 0u;
926+
while i < end {
927+
let next = s.char_range_at(i).next;
928+
len += 1u;
929+
i = next;
930+
}
931+
return len;
932+
}
933+
934+
/// Counts the number of bytes taken by the first `n` chars in `s`
935+
/// starting from `start`.
936+
pub fn count_bytes<'b>(s: &'b str, start: uint, n: uint) -> uint {
937+
assert!(s.is_char_boundary(start));
938+
let mut end = start;
939+
let mut cnt = n;
940+
let l = s.len();
941+
while cnt > 0u {
942+
assert!(end < l);
943+
let next = s.char_range_at(end).next;
944+
cnt -= 1u;
945+
end = next;
946+
}
947+
end - start
948+
}
949+
910950
// https://tools.ietf.org/html/rfc3629
911951
static UTF8_CHAR_WIDTH: [u8, ..256] = [
912952
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,

branches/try2/src/libstd/unstable/sync.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ use vec;
2626
/// An atomically reference counted pointer.
2727
///
2828
/// Enforces no shared-memory safety.
29-
#[unsafe_no_drop_flag]
3029
pub struct UnsafeArc<T> {
3130
data: *mut ArcData<T>,
3231
}
@@ -222,9 +221,8 @@ impl<T: Send> Clone for UnsafeArc<T> {
222221
impl<T> Drop for UnsafeArc<T>{
223222
fn drop(&self) {
224223
unsafe {
225-
// Happens when destructing an unwrapper's handle and from `#[unsafe_no_drop_flag]`
226224
if self.data.is_null() {
227-
return
225+
return; // Happens when destructing an unwrapper's handle.
228226
}
229227
let mut data: ~ArcData<T> = cast::transmute(self.data);
230228
// Must be acquire+release, not just release, to make sure this
@@ -442,12 +440,6 @@ mod tests {
442440
use super::{Exclusive, UnsafeArc, atomically};
443441
use task;
444442
use util;
445-
use sys::size_of;
446-
447-
#[test]
448-
fn test_size() {
449-
assert_eq!(size_of::<UnsafeArc<[int, ..10]>>(), size_of::<*[int, ..10]>());
450-
}
451443

452444
#[test]
453445
fn test_atomically() {

0 commit comments

Comments
 (0)