Skip to content

Commit b973aa7

Browse files
committed
---
yaml --- r: 149497 b: refs/heads/try2 c: e034a43 h: refs/heads/master i: 149495: ec3f84a v: v3
1 parent c9048ef commit b973aa7

File tree

235 files changed

+2073
-1701
lines changed

Some content is hidden

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

235 files changed

+2073
-1701
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: a8941c3e04fc7900c3e9a4e82b6a63bc9018c769
8+
refs/heads/try2: e034a43a8b1b77e76f90fe60692faf694c75c9e5
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/mk/crates.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ DEPS_flate := std native:miniz
6969
DEPS_arena := std collections
7070
DEPS_glob := std
7171
DEPS_serialize := std
72-
DEPS_term := std
72+
DEPS_term := std collections
7373
DEPS_semver := std
7474
DEPS_uuid := std serialize
7575
DEPS_sync := std

branches/try2/mk/prepare.mk

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#
1717
# It requires the following variables to be set:
1818
#
19-
# PREPARE_HOST - the host triple
19+
# PREPARE_HOST - the host triple
2020
# PREPARE_TARGETS - the target triples, space separated
2121
# PREPARE_DEST_DIR - the directory to put the image
2222

@@ -172,7 +172,10 @@ prepare-target-$(2)-host-$(3)-$(1): \
172172
$$(if $$(findstring $(2),$$(CFG_HOST)), \
173173
$$(foreach crate,$$(HOST_CRATES), \
174174
$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$$(crate)),)
175-
# Only install if this host and target combo is being prepared
175+
# Only install if this host and target combo is being prepared. Also be sure to
176+
# *not* install the rlibs for host crates because there's no need to statically
177+
# link against most of them. They just produce a large amount of extra size
178+
# bloat.
176179
$$(if $$(findstring $(1), $$(PREPARE_STAGE)),\
177180
$$(if $$(findstring $(2), $$(PREPARE_TARGETS)),\
178181
$$(if $$(findstring $(3), $$(PREPARE_HOST)),\
@@ -182,8 +185,7 @@ prepare-target-$(2)-host-$(3)-$(1): \
182185
$$(call PREPARE_LIB,$$(call CFG_RLIB_GLOB,$$(crate))))\
183186
$$(if $$(findstring $(2),$$(CFG_HOST)),\
184187
$$(foreach crate,$$(HOST_CRATES),\
185-
$$(call PREPARE_LIB,$$(call CFG_LIB_GLOB_$(2),$$(crate)))\
186-
$$(call PREPARE_LIB,$$(call CFG_RLIB_GLOB,$$(crate)))),)\
188+
$$(call PREPARE_LIB,$$(call CFG_LIB_GLOB_$(2),$$(crate)))),)\
187189
$$(call PREPARE_LIB,libmorestack.a) \
188190
$$(call PREPARE_LIB,libcompiler-rt.a),),),)
189191
endef

branches/try2/src/doc/complement-cheatsheet.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ Description C signature Equivalent
211211
---------------------- ---------------------------------------------- ------------------------------------------
212212
no parameters `void foo(void);` `fn foo();`
213213
return value `int foo(void);` `fn foo() -> c_int;`
214-
function parameters `void foo(int x, int y);` `fn foo(x: int, y: int);`
214+
function parameters `void foo(int x, int y);` `fn foo(x: c_int, y: c_int);`
215215
in-out pointers `void foo(const int* in_ptr, int* out_ptr);` `fn foo(in_ptr: *c_int, out_ptr: *mut c_int);`
216216
217217
Note: The Rust signatures should be wrapped in an `extern "ABI" { ... }` block.

branches/try2/src/doc/guide-container.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ order.
3838
Each `HashMap` instance has a random 128-bit key to use with a keyed hash,
3939
making the order of a set of keys in a given hash table randomized. Rust
4040
provides a [SipHash](https://131002.net/siphash/) implementation for any type
41-
implementing the `IterBytes` trait.
41+
implementing the `Hash` trait.
4242

4343
## Double-ended queues
4444

@@ -186,12 +186,12 @@ let mut calls = 0;
186186
let it = xs.iter().scan((), |_, x| {
187187
calls += 1;
188188
if *x < 3 { Some(x) } else { None }});
189-
189+
190190
// the iterator will only yield 1 and 2 before returning None
191191
// If we were to call it 5 times, calls would end up as 5, despite
192192
// only 2 values being yielded (and therefore 3 unique calls being
193193
// made). The fuse() adaptor can fix this.
194-
194+
195195
let mut it = it.fuse();
196196
it.next();
197197
it.next();

branches/try2/src/doc/po/ja/tutorial.md.po

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4421,15 +4421,15 @@ msgstr ""
44214421
#, fuzzy
44224422
#| msgid ""
44234423
#| "The full list of derivable traits is `Eq`, `TotalEq`, `Ord`, `TotalOrd`, "
4424-
#| "`Encodable` `Decodable`, `Clone`, `DeepClone`, `IterBytes`, `Rand`, "
4424+
#| "`Encodable` `Decodable`, `Clone`, `DeepClone`, `Hash`, `Rand`, "
44254425
#| "`Zero`, and `ToStr`."
44264426
msgid ""
44274427
"The full list of derivable traits is `Eq`, `TotalEq`, `Ord`, `TotalOrd`, "
4428-
"`Encodable` `Decodable`, `Clone`, `DeepClone`, `IterBytes`, `Rand`, "
4428+
"`Encodable` `Decodable`, `Clone`, `DeepClone`, `Hash`, `Rand`, "
44294429
"`Default`, `Zero`, and `ToStr`."
44304430
msgstr ""
44314431
"実装を自動的に導出可能なトレイトは、 `Eq`, `TotalEq`, `Ord`, `TotalOrd`, "
4432-
"`Encodable` `Decodable`, `Clone`, `DeepClone`, `IterBytes`, `Rand`, `Zero`, "
4432+
"`Encodable` `Decodable`, `Clone`, `DeepClone`, `Hash`, `Rand`, `Zero`, "
44334433
"および `ToStr` です。."
44344434

44354435
#. type: Plain text

branches/try2/src/doc/rust.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ expression context, the final namespace qualifier is omitted.
467467
Two examples of paths with type arguments:
468468

469469
~~~~
470-
# use std::hashmap::HashMap;
470+
# struct HashMap<K, V>;
471471
# fn f() {
472472
# fn id<T>(t: T) -> T { t }
473473
type T = HashMap<int,~str>; // Type arguments used in a type expression
@@ -2035,7 +2035,7 @@ Supported traits for `deriving` are:
20352035
* Comparison traits: `Eq`, `TotalEq`, `Ord`, `TotalOrd`.
20362036
* Serialization: `Encodable`, `Decodable`. These require `serialize`.
20372037
* `Clone` and `DeepClone`, to perform (deep) copies.
2038-
* `IterBytes`, to iterate over the bytes in a data type.
2038+
* `Hash`, to iterate over the bytes in a data type.
20392039
* `Rand`, to create a random instance of a data type.
20402040
* `Default`, to create an empty instance of a data type.
20412041
* `Zero`, to create an zero instance of a numeric data type.

branches/try2/src/doc/tutorial.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,7 @@ type was invalid because the size was infinite!
10261026

10271027
An *owned box* (`~`) uses a dynamic memory allocation to provide the invariant
10281028
of always being the size of a pointer, regardless of the contained type. This
1029-
can be leverage to create a valid `List` definition:
1029+
can be leveraged to create a valid `List` definition:
10301030

10311031
~~~
10321032
enum List {
@@ -1977,8 +1977,8 @@ illegal to copy and pass by value.
19771977
Generic `type`, `struct`, and `enum` declarations follow the same pattern:
19781978
19791979
~~~~
1980-
use std::hashmap::HashMap;
1981-
type Set<T> = HashMap<T, ()>;
1980+
extern crate collections;
1981+
type Set<T> = collections::HashMap<T, ()>;
19821982
19831983
struct Stack<T> {
19841984
elements: ~[T]
@@ -1988,6 +1988,7 @@ enum Option<T> {
19881988
Some(T),
19891989
None
19901990
}
1991+
# fn main() {}
19911992
~~~~
19921993
19931994
These declarations can be instantiated to valid types like `Set<int>`,
@@ -2524,7 +2525,7 @@ enum ABC { A, B, C }
25242525

25252526
The full list of derivable traits is `Eq`, `TotalEq`, `Ord`,
25262527
`TotalOrd`, `Encodable` `Decodable`, `Clone`, `DeepClone`,
2527-
`IterBytes`, `Rand`, `Default`, `Zero`, `FromPrimitive` and `Show`.
2528+
`Hash`, `Rand`, `Default`, `Zero`, `FromPrimitive` and `Show`.
25282529

25292530
# Crates and the module system
25302531

branches/try2/src/etc/combine-tests.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ def scrub(b):
5555
#[crate_id=\"run_pass_stage2#0.1\"];
5656
#[feature(globs, macro_rules, struct_variant, managed_boxes)];
5757
#[allow(warnings)];
58+
extern crate collections;
59+
extern crate extra;
5860
"""
5961
)
6062
for t in stage2_tests:

branches/try2/src/etc/generate-deriving-span-tests.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ def write_file(name, string):
119119
('Clone', [], 1), ('DeepClone', ['Clone'], 1),
120120
('Eq', [], 2), ('Ord', [], 8),
121121
('TotalEq', [], 1), ('TotalOrd', ['TotalEq'], 1),
122-
('Show', [], 1)]:
122+
('Show', [], 1),
123+
('Hash', [], 1)]:
123124
traits[trait] = (ALL, supers, errs)
124125

125126
for (trait, (types, super_traits, error_count)) in traits.items():

branches/try2/src/etc/vim/syntax/rust.vim

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ syn keyword rustTrait GenericPath Path PosixPath WindowsPath
9393
syn keyword rustTrait RawPtr
9494
syn keyword rustTrait Buffer Writer Reader Seek
9595
syn keyword rustTrait Str StrVector StrSlice OwnedStr IntoMaybeOwned
96-
syn keyword rustTrait IterBytes
9796
syn keyword rustTrait ToStr IntoStr
9897
syn keyword rustTrait Tuple1 Tuple2 Tuple3 Tuple4
9998
syn keyword rustTrait Tuple5 Tuple6 Tuple7 Tuple8

branches/try2/src/libarena/lib.rs

Lines changed: 31 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ use std::cast::{transmute, transmute_mut, transmute_mut_region};
3131
use std::cast;
3232
use std::cell::{Cell, RefCell};
3333
use std::mem;
34+
use std::ptr::read;
3435
use std::cmp;
3536
use std::num;
3637
use std::kinds::marker;
3738
use std::rc::Rc;
3839
use std::rt::global_heap;
39-
use std::unstable::intrinsics::{TyDesc, get_tydesc};
40-
use std::unstable::intrinsics;
40+
use std::intrinsics::{TyDesc, get_tydesc};
41+
use std::intrinsics;
4142
use std::vec;
4243

4344
// The way arena uses arrays is really deeply awful. The arrays are
@@ -345,37 +346,32 @@ pub struct TypedArena<T> {
345346
/// reached, a new chunk is allocated.
346347
priv end: *T,
347348

348-
/// The type descriptor of the objects in the arena. This should not be
349-
/// necessary, but is until generic destructors are supported.
350-
priv tydesc: *TyDesc,
351-
352349
/// A pointer to the first arena segment.
353-
priv first: Option<~TypedArenaChunk>,
350+
priv first: Option<~TypedArenaChunk<T>>,
354351
}
355352

356-
struct TypedArenaChunk {
353+
struct TypedArenaChunk<T> {
357354
/// Pointer to the next arena segment.
358-
next: Option<~TypedArenaChunk>,
355+
next: Option<~TypedArenaChunk<T>>,
359356

360357
/// The number of elements that this chunk can hold.
361358
capacity: uint,
362359

363360
// Objects follow here, suitably aligned.
364361
}
365362

366-
impl TypedArenaChunk {
363+
impl<T> TypedArenaChunk<T> {
367364
#[inline]
368-
fn new<T>(next: Option<~TypedArenaChunk>, capacity: uint)
369-
-> ~TypedArenaChunk {
370-
let mut size = mem::size_of::<TypedArenaChunk>();
365+
fn new(next: Option<~TypedArenaChunk<T>>, capacity: uint) -> ~TypedArenaChunk<T> {
366+
let mut size = mem::size_of::<TypedArenaChunk<T>>();
371367
size = round_up(size, mem::min_align_of::<T>());
372368
let elem_size = mem::size_of::<T>();
373369
let elems_size = elem_size.checked_mul(&capacity).unwrap();
374370
size = size.checked_add(&elems_size).unwrap();
375371

376372
let mut chunk = unsafe {
377373
let chunk = global_heap::exchange_malloc(size);
378-
let mut chunk: ~TypedArenaChunk = cast::transmute(chunk);
374+
let mut chunk: ~TypedArenaChunk<T> = cast::transmute(chunk);
379375
mem::move_val_init(&mut chunk.next, next);
380376
chunk
381377
};
@@ -387,16 +383,13 @@ impl TypedArenaChunk {
387383
/// Destroys this arena chunk. If the type descriptor is supplied, the
388384
/// drop glue is called; otherwise, drop glue is not called.
389385
#[inline]
390-
unsafe fn destroy(&mut self, len: uint, opt_tydesc: Option<*TyDesc>) {
386+
unsafe fn destroy(&mut self, len: uint) {
391387
// Destroy all the allocated objects.
392-
match opt_tydesc {
393-
None => {}
394-
Some(tydesc) => {
395-
let mut start = self.start(tydesc);
396-
for _ in range(0, len) {
397-
((*tydesc).drop_glue)(start as *i8);
398-
start = start.offset((*tydesc).size as int)
399-
}
388+
if intrinsics::needs_drop::<T>() {
389+
let mut start = self.start();
390+
for _ in range(0, len) {
391+
read(start as *T); // run the destructor on the pointer
392+
start = start.offset(mem::size_of::<T>() as int)
400393
}
401394
}
402395

@@ -406,26 +399,26 @@ impl TypedArenaChunk {
406399
None => {}
407400
Some(mut next) => {
408401
// We assume that the next chunk is completely filled.
409-
next.destroy(next.capacity, opt_tydesc)
402+
next.destroy(next.capacity)
410403
}
411404
}
412405
}
413406

414407
// Returns a pointer to the first allocated object.
415408
#[inline]
416-
fn start(&self, tydesc: *TyDesc) -> *u8 {
417-
let this: *TypedArenaChunk = self;
409+
fn start(&self) -> *u8 {
410+
let this: *TypedArenaChunk<T> = self;
418411
unsafe {
419-
cast::transmute(round_up(this.offset(1) as uint, (*tydesc).align))
412+
cast::transmute(round_up(this.offset(1) as uint, mem::min_align_of::<T>()))
420413
}
421414
}
422415

423416
// Returns a pointer to the end of the allocated space.
424417
#[inline]
425-
fn end(&self, tydesc: *TyDesc) -> *u8 {
418+
fn end(&self) -> *u8 {
426419
unsafe {
427-
let size = (*tydesc).size.checked_mul(&self.capacity).unwrap();
428-
self.start(tydesc).offset(size as int)
420+
let size = mem::size_of::<T>().checked_mul(&self.capacity).unwrap();
421+
self.start().offset(size as int)
429422
}
430423
}
431424
}
@@ -441,14 +434,10 @@ impl<T> TypedArena<T> {
441434
/// objects.
442435
#[inline]
443436
pub fn with_capacity(capacity: uint) -> TypedArena<T> {
444-
let chunk = TypedArenaChunk::new::<T>(None, capacity);
445-
let tydesc = unsafe {
446-
intrinsics::get_tydesc::<T>()
447-
};
437+
let chunk = TypedArenaChunk::<T>::new(None, capacity);
448438
TypedArena {
449-
ptr: chunk.start(tydesc) as *T,
450-
end: chunk.end(tydesc) as *T,
451-
tydesc: tydesc,
439+
ptr: chunk.start() as *T,
440+
end: chunk.end() as *T,
452441
first: Some(chunk),
453442
}
454443
}
@@ -475,9 +464,9 @@ impl<T> TypedArena<T> {
475464
fn grow(&mut self) {
476465
let chunk = self.first.take_unwrap();
477466
let new_capacity = chunk.capacity.checked_mul(&2).unwrap();
478-
let chunk = TypedArenaChunk::new::<T>(Some(chunk), new_capacity);
479-
self.ptr = chunk.start(self.tydesc) as *T;
480-
self.end = chunk.end(self.tydesc) as *T;
467+
let chunk = TypedArenaChunk::<T>::new(Some(chunk), new_capacity);
468+
self.ptr = chunk.start() as *T;
469+
self.end = chunk.end() as *T;
481470
self.first = Some(chunk)
482471
}
483472
}
@@ -486,18 +475,13 @@ impl<T> TypedArena<T> {
486475
impl<T> Drop for TypedArena<T> {
487476
fn drop(&mut self) {
488477
// Determine how much was filled.
489-
let start = self.first.get_ref().start(self.tydesc) as uint;
478+
let start = self.first.get_ref().start() as uint;
490479
let end = self.ptr as uint;
491480
let diff = (end - start) / mem::size_of::<T>();
492481

493482
// Pass that to the `destroy` method.
494483
unsafe {
495-
let opt_tydesc = if intrinsics::needs_drop::<T>() {
496-
Some(self.tydesc)
497-
} else {
498-
None
499-
};
500-
self.first.get_mut_ref().destroy(diff, opt_tydesc)
484+
self.first.get_mut_ref().destroy(diff)
501485
}
502486
}
503487
}

branches/try2/src/libcollections/enum_set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
1616
use std::num::Bitwise;
1717

18-
#[deriving(Clone, Eq, IterBytes, ToStr, Encodable, Decodable)]
18+
#[deriving(Clone, Eq, Hash, ToStr, Encodable, Decodable)]
1919
/// A specialized Set implementation to use enum types.
2020
pub struct EnumSet<E> {
2121
// We must maintain the invariant that no bits are set

0 commit comments

Comments
 (0)