Skip to content

Commit 0e7a455

Browse files
committed
---
yaml --- r: 130731 b: refs/heads/master c: 198030f h: refs/heads/master i: 130729: ba6ac61 130727: 73455f1 v: v3
1 parent ab4ea98 commit 0e7a455

File tree

259 files changed

+7695
-10856
lines changed

Some content is hidden

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

259 files changed

+7695
-10856
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: 0c73e5fc5f212d30bb46b96cb45b51251217a199
2+
refs/heads/master: 198030fadfbc3849f004deb8bb9108d0a0fad19a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6faa4f33a42de32579e02a8d030db920d360e2b5
55
refs/heads/try: a2473a89da106f7dd3be86e9d52fe23f43d5bfa5

trunk/src/compiletest/runtest.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,6 +1577,10 @@ fn _arm_push_aux_shared_library(config: &Config, testfile: &Path) {
15771577

15781578
// codegen tests (vs. clang)
15791579

1580+
fn make_o_name(config: &Config, testfile: &Path) -> Path {
1581+
output_base_name(config, testfile).with_extension("o")
1582+
}
1583+
15801584
fn append_suffix_to_stem(p: &Path, suffix: &str) -> Path {
15811585
if suffix.len() == 0 {
15821586
(*p).clone()
@@ -1592,13 +1596,14 @@ fn compile_test_and_save_bitcode(config: &Config, props: &TestProps,
15921596
// FIXME (#9639): This needs to handle non-utf8 paths
15931597
let link_args = vec!("-L".to_string(),
15941598
aux_dir.as_str().unwrap().to_string());
1595-
let llvm_args = vec!("--emit=bc,obj".to_string(),
1596-
"--crate-type=lib".to_string());
1599+
let llvm_args = vec!("--emit=obj".to_string(),
1600+
"--crate-type=lib".to_string(),
1601+
"-C".to_string(),
1602+
"save-temps".to_string());
15971603
let args = make_compile_args(config,
15981604
props,
15991605
link_args.append(llvm_args.as_slice()),
1600-
|a, b| ThisDirectory(output_base_name(a, b).dir_path()),
1601-
testfile);
1606+
|a, b| ThisFile(make_o_name(a, b)), testfile);
16021607
compose_and_run_compiler(config, props, testfile, args, None)
16031608
}
16041609

trunk/src/doc/guide.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ but also working properly. And printing information to the screen is a pretty
116116
common thing to do.
117117

118118
The first thing that we need to do is make a file to put our code in. I like
119-
to make a `projects` directory in my home directory, and keep all my projects
119+
to make a projects directory in my home directory, and keep all my projects
120120
there. Rust does not care where your code lives.
121121

122122
This actually leads to one other concern we should address: this tutorial will
@@ -765,7 +765,7 @@ This is a deliberate design decision. While full-program inference is possible,
765765
languages which have it, like Haskell, often suggest that documenting your
766766
types explicitly is a best-practice. We agree that forcing functions to declare
767767
types while allowing for inference inside of function bodies is a wonderful
768-
sweet spot between full inference and no inference.
768+
compromise between full inference and no inference.
769769

770770
What about returning a value? Here's a function that adds one to an integer:
771771

trunk/src/doc/rust.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2221,8 +2221,8 @@ These types help drive the compiler's analysis
22212221
: This type does not implement "copy", even if eligible
22222222
* `no_send_bound`
22232223
: This type does not implement "send", even if eligible
2224-
* `no_sync_bound`
2225-
: This type does not implement "sync", even if eligible
2224+
* `no_share_bound`
2225+
: This type does not implement "share", even if eligible
22262226
* `eh_personality`
22272227
: ___Needs filling in___
22282228
* `exchange_free`

trunk/src/driver/driver.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
// except according to those terms.
1010

1111
#[cfg(rustdoc)]
12-
extern crate "rustdoc" as this;
12+
extern crate this = "rustdoc";
1313

1414
#[cfg(rustc)]
15-
extern crate "rustc" as this;
15+
extern crate this = "rustc";
1616

1717
fn main() { this::main() }

trunk/src/liballoc/heap.rs

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
use core::ptr::RawPtr;
1616
#[cfg(not(test))] use core::raw;
17-
#[cfg(stage0, not(test))] use util;
17+
#[cfg(not(test))] use util;
1818

1919
/// Returns a pointer to `size` bytes of memory.
2020
///
@@ -119,7 +119,7 @@ unsafe fn exchange_free(ptr: *mut u8, size: uint, align: uint) {
119119
}
120120

121121
// FIXME: #7496
122-
#[cfg(stage0, not(test))]
122+
#[cfg(not(test))]
123123
#[lang="closure_exchange_malloc"]
124124
#[inline]
125125
#[allow(deprecated)]
@@ -134,21 +134,6 @@ unsafe fn closure_exchange_malloc(drop_glue: fn(*mut u8), size: uint,
134134
alloc as *mut u8
135135
}
136136

137-
// FIXME: #7496
138-
#[cfg(not(stage0), not(test))]
139-
#[lang="closure_exchange_malloc"]
140-
#[inline]
141-
#[allow(deprecated)]
142-
unsafe fn closure_exchange_malloc(drop_glue: fn(*mut u8), size: uint,
143-
align: uint) -> *mut u8 {
144-
let p = allocate(size, align);
145-
146-
let alloc = p as *mut raw::Box<()>;
147-
(*alloc).drop_glue = drop_glue;
148-
149-
alloc as *mut u8
150-
}
151-
152137
#[cfg(jemalloc)]
153138
mod imp {
154139
use core::option::{None, Option};

trunk/src/libarena/lib.rs

Lines changed: 47 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,17 @@ use std::mem;
3939
use std::num;
4040
use std::ptr;
4141
use std::rc::Rc;
42-
use std::rt::heap::{allocate, deallocate};
42+
use std::rt::heap::allocate;
4343

4444
// The way arena uses arrays is really deeply awful. The arrays are
4545
// allocated, and have capacities reserved, but the fill for the array
4646
// will always stay at 0.
4747
#[deriving(Clone, PartialEq)]
4848
struct Chunk {
49-
data: Rc<RefCell<Vec<u8>>>,
49+
data: Rc<RefCell<Vec<u8> >>,
5050
fill: Cell<uint>,
5151
is_copy: Cell<bool>,
5252
}
53-
5453
impl Chunk {
5554
fn capacity(&self) -> uint {
5655
self.data.borrow().capacity()
@@ -358,37 +357,38 @@ pub struct TypedArena<T> {
358357
end: Cell<*const T>,
359358

360359
/// A pointer to the first arena segment.
361-
first: RefCell<*mut TypedArenaChunk<T>>,
360+
first: RefCell<TypedArenaChunkRef<T>>,
362361
}
362+
type TypedArenaChunkRef<T> = Option<Box<TypedArenaChunk<T>>>;
363363

364364
struct TypedArenaChunk<T> {
365365
/// Pointer to the next arena segment.
366-
next: *mut TypedArenaChunk<T>,
366+
next: TypedArenaChunkRef<T>,
367367

368368
/// The number of elements that this chunk can hold.
369369
capacity: uint,
370370

371371
// Objects follow here, suitably aligned.
372372
}
373373

374-
fn calculate_size<T>(capacity: uint) -> uint {
375-
let mut size = mem::size_of::<TypedArenaChunk<T>>();
376-
size = round_up(size, mem::min_align_of::<T>());
377-
let elem_size = mem::size_of::<T>();
378-
let elems_size = elem_size.checked_mul(&capacity).unwrap();
379-
size = size.checked_add(&elems_size).unwrap();
380-
size
381-
}
382-
383374
impl<T> TypedArenaChunk<T> {
384375
#[inline]
385-
unsafe fn new(next: *mut TypedArenaChunk<T>, capacity: uint)
386-
-> *mut TypedArenaChunk<T> {
387-
let size = calculate_size::<T>(capacity);
388-
let chunk = allocate(size, mem::min_align_of::<TypedArenaChunk<T>>())
389-
as *mut TypedArenaChunk<T>;
390-
(*chunk).next = next;
391-
(*chunk).capacity = capacity;
376+
fn new(next: Option<Box<TypedArenaChunk<T>>>, capacity: uint)
377+
-> Box<TypedArenaChunk<T>> {
378+
let mut size = mem::size_of::<TypedArenaChunk<T>>();
379+
size = round_up(size, mem::min_align_of::<T>());
380+
let elem_size = mem::size_of::<T>();
381+
let elems_size = elem_size.checked_mul(&capacity).unwrap();
382+
size = size.checked_add(&elems_size).unwrap();
383+
384+
let mut chunk = unsafe {
385+
let chunk = allocate(size, mem::min_align_of::<TypedArenaChunk<T>>());
386+
let mut chunk: Box<TypedArenaChunk<T>> = mem::transmute(chunk);
387+
ptr::write(&mut chunk.next, next);
388+
chunk
389+
};
390+
391+
chunk.capacity = capacity;
392392
chunk
393393
}
394394

@@ -406,13 +406,14 @@ impl<T> TypedArenaChunk<T> {
406406
}
407407

408408
// Destroy the next chunk.
409-
let next = self.next;
410-
let size = calculate_size::<T>(self.capacity);
411-
deallocate(self as *mut TypedArenaChunk<T> as *mut u8, size,
412-
mem::min_align_of::<TypedArenaChunk<T>>());
413-
if next.is_not_null() {
414-
let capacity = (*next).capacity;
415-
(*next).destroy(capacity);
409+
let next_opt = mem::replace(&mut self.next, None);
410+
match next_opt {
411+
None => {}
412+
Some(mut next) => {
413+
// We assume that the next chunk is completely filled.
414+
let capacity = next.capacity;
415+
next.destroy(capacity)
416+
}
416417
}
417418
}
418419

@@ -447,13 +448,11 @@ impl<T> TypedArena<T> {
447448
/// objects.
448449
#[inline]
449450
pub fn with_capacity(capacity: uint) -> TypedArena<T> {
450-
unsafe {
451-
let chunk = TypedArenaChunk::<T>::new(ptr::mut_null(), capacity);
452-
TypedArena {
453-
ptr: Cell::new((*chunk).start() as *const T),
454-
end: Cell::new((*chunk).end() as *const T),
455-
first: RefCell::new(chunk),
456-
}
451+
let chunk = TypedArenaChunk::<T>::new(None, capacity);
452+
TypedArena {
453+
ptr: Cell::new(chunk.start() as *const T),
454+
end: Cell::new(chunk.end() as *const T),
455+
first: RefCell::new(Some(chunk)),
457456
}
458457
}
459458

@@ -477,28 +476,26 @@ impl<T> TypedArena<T> {
477476
/// Grows the arena.
478477
#[inline(never)]
479478
fn grow(&self) {
480-
unsafe {
481-
let chunk = *self.first.borrow_mut();
482-
let new_capacity = (*chunk).capacity.checked_mul(&2).unwrap();
483-
let chunk = TypedArenaChunk::<T>::new(chunk, new_capacity);
484-
self.ptr.set((*chunk).start() as *const T);
485-
self.end.set((*chunk).end() as *const T);
486-
*self.first.borrow_mut() = chunk
487-
}
479+
let chunk = self.first.borrow_mut().take().unwrap();
480+
let new_capacity = chunk.capacity.checked_mul(&2).unwrap();
481+
let chunk = TypedArenaChunk::<T>::new(Some(chunk), new_capacity);
482+
self.ptr.set(chunk.start() as *const T);
483+
self.end.set(chunk.end() as *const T);
484+
*self.first.borrow_mut() = Some(chunk)
488485
}
489486
}
490487

491488
#[unsafe_destructor]
492489
impl<T> Drop for TypedArena<T> {
493490
fn drop(&mut self) {
494-
unsafe {
495-
// Determine how much was filled.
496-
let start = self.first.borrow().as_ref().unwrap().start() as uint;
497-
let end = self.ptr.get() as uint;
498-
let diff = (end - start) / mem::size_of::<T>();
491+
// Determine how much was filled.
492+
let start = self.first.borrow().as_ref().unwrap().start() as uint;
493+
let end = self.ptr.get() as uint;
494+
let diff = (end - start) / mem::size_of::<T>();
499495

500-
// Pass that to the `destroy` method.
501-
(**self.first.borrow_mut()).destroy(diff)
496+
// Pass that to the `destroy` method.
497+
unsafe {
498+
self.first.borrow_mut().as_mut().unwrap().destroy(diff)
502499
}
503500
}
504501
}

trunk/src/libcollections/bitv.rs

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,20 @@ fn match_words <'a,'b>(a: &'a Bitv, b: &'b Bitv) -> (MatchWords<'a>, MatchWords<
9595
static TRUE: bool = true;
9696
static FALSE: bool = false;
9797

98+
#[deriving(Clone)]
99+
struct SmallBitv {
100+
/// only the lowest nbits of this value are used. the rest is undefined.
101+
bits: uint
102+
}
103+
104+
#[deriving(Clone)]
105+
struct BigBitv {
106+
storage: Vec<uint>
107+
}
108+
109+
#[deriving(Clone)]
110+
enum BitvVariant { Big(BigBitv), Small(SmallBitv) }
111+
98112
/// The bitvector type.
99113
///
100114
/// # Example
@@ -1639,7 +1653,6 @@ impl<'a> Iterator<uint> for TwoBitPositions<'a> {
16391653
#[cfg(test)]
16401654
mod tests {
16411655
use std::prelude::*;
1642-
use std::iter::range_step;
16431656
use std::uint;
16441657
use std::rand;
16451658
use std::rand::Rng;
@@ -2033,14 +2046,12 @@ mod tests {
20332046

20342047
#[test]
20352048
fn test_bitv_iterator() {
2036-
let bools = vec![true, false, true, true];
2049+
let bools = [true, false, true, true];
20372050
let bitv: Bitv = bools.iter().map(|n| *n).collect();
20382051

2039-
assert_eq!(bitv.iter().collect::<Vec<bool>>(), bools)
2040-
2041-
let long = Vec::from_fn(10000, |i| i % 2 == 0);
2042-
let bitv: Bitv = long.iter().map(|n| *n).collect();
2043-
assert_eq!(bitv.iter().collect::<Vec<bool>>(), long)
2052+
for (act, &ex) in bitv.iter().zip(bools.iter()) {
2053+
assert_eq!(ex, act);
2054+
}
20442055
}
20452056

20462057
#[test]
@@ -2050,12 +2061,6 @@ mod tests {
20502061

20512062
let idxs: Vec<uint> = bitv.iter().collect();
20522063
assert_eq!(idxs, vec!(0, 2, 3));
2053-
2054-
let long: BitvSet = range(0u, 10000).map(|n| n % 2 == 0).collect();
2055-
let real = range_step(0, 10000, 2).collect::<Vec<uint>>();
2056-
2057-
let idxs: Vec<uint> = long.iter().collect();
2058-
assert_eq!(idxs, real);
20592064
}
20602065

20612066
#[test]
@@ -2569,7 +2574,7 @@ mod tests {
25692574
}
25702575

25712576
#[bench]
2572-
fn bench_bitv_set_big_fixed(b: &mut Bencher) {
2577+
fn bench_bitv_big(b: &mut Bencher) {
25732578
let mut r = rng();
25742579
let mut bitv = Bitv::with_capacity(BENCH_BITS, false);
25752580
b.iter(|| {
@@ -2581,19 +2586,7 @@ mod tests {
25812586
}
25822587

25832588
#[bench]
2584-
fn bench_bitv_set_big_variable(b: &mut Bencher) {
2585-
let mut r = rng();
2586-
let mut bitv = Bitv::with_capacity(BENCH_BITS, false);
2587-
b.iter(|| {
2588-
for i in range(0u, 100) {
2589-
bitv.set((r.next_u32() as uint) % BENCH_BITS, r.gen());
2590-
}
2591-
&bitv
2592-
})
2593-
}
2594-
2595-
#[bench]
2596-
fn bench_bitv_set_small(b: &mut Bencher) {
2589+
fn bench_bitv_small(b: &mut Bencher) {
25972590
let mut r = rng();
25982591
let mut bitv = Bitv::with_capacity(uint::BITS, false);
25992592
b.iter(|| {
@@ -2605,7 +2598,7 @@ mod tests {
26052598
}
26062599

26072600
#[bench]
2608-
fn bench_bitvset_small(b: &mut Bencher) {
2601+
fn bench_bitv_set_small(b: &mut Bencher) {
26092602
let mut r = rng();
26102603
let mut bitv = BitvSet::new();
26112604
b.iter(|| {
@@ -2617,7 +2610,7 @@ mod tests {
26172610
}
26182611

26192612
#[bench]
2620-
fn bench_bitvset_big(b: &mut Bencher) {
2613+
fn bench_bitv_set_big(b: &mut Bencher) {
26212614
let mut r = rng();
26222615
let mut bitv = BitvSet::new();
26232616
b.iter(|| {

trunk/src/libcollections/dlist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl<T> Rawlink<T> {
9090
/// Convert the `Rawlink` into an Option value
9191
fn resolve_immut<'a>(&self) -> Option<&'a T> {
9292
unsafe {
93-
self.p.as_ref()
93+
mem::transmute(self.p.to_option())
9494
}
9595
}
9696

0 commit comments

Comments
 (0)