Skip to content

Commit e18d364

Browse files
committed
---
yaml --- r: 136413 b: refs/heads/dist-snap c: ceb9bbf h: refs/heads/master i: 136411: b86cd91 v: v3
1 parent c277fb6 commit e18d364

File tree

152 files changed

+5736
-3115
lines changed

Some content is hidden

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

152 files changed

+5736
-3115
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 189b7332968972f34cdbbbd9b62d97ababf53059
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 7caf2ab802d7cf62662b6dd63ffe81672d45f1ad
9+
refs/heads/dist-snap: ceb9bbfbf5933f9df238fecdd14e75304439c4f4
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/mk/crates.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ CRATES := $(TARGET_CRATES) $(HOST_CRATES)
5959
TOOLS := compiletest rustdoc rustc
6060

6161
DEPS_core :=
62-
DEPS_rlibc :=
62+
DEPS_rlibc := core
6363
DEPS_unicode := core
6464
DEPS_alloc := core libc native:jemalloc
6565
DEPS_debug := std

branches/dist-snap/src/doc/guide-unsafe.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,11 +461,12 @@ fn start(_argc: int, _argv: *const *const u8) -> int {
461461
0
462462
}
463463
464-
// These functions are invoked by the compiler, but not
464+
// These functions and traits are used by the compiler, but not
465465
// for a bare-bones hello world. These are normally
466466
// provided by libstd.
467467
#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
468468
#[lang = "eh_personality"] extern fn eh_personality() {}
469+
#[lang = "sized"] trait Sized { }
469470
# // fn main() {} tricked you, rustdoc!
470471
```
471472

@@ -488,13 +489,14 @@ pub extern fn main(argc: int, argv: *const *const u8) -> int {
488489
489490
#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
490491
#[lang = "eh_personality"] extern fn eh_personality() {}
492+
#[lang = "sized"] trait Sized { }
491493
# // fn main() {} tricked you, rustdoc!
492494
```
493495

494496

495497
The compiler currently makes a few assumptions about symbols which are available
496498
in the executable to call. Normally these functions are provided by the standard
497-
library, but without it you must define your own.
499+
xlibrary, but without it you must define your own.
498500

499501
The first of these two functions, `stack_exhausted`, is invoked whenever stack
500502
overflow is detected. This function has a number of restrictions about how it
@@ -508,6 +510,12 @@ mechanisms of the compiler. This is often mapped to GCC's personality function
508510
information), but crates which do not trigger failure can be assured that this
509511
function is never called.
510512

513+
The final item in the example is a trait called `Sized`. This a trait
514+
that represents data of a known static size: it is integral to the
515+
Rust type system, and so the compiler expects the standard library to
516+
provide it. Since you are not using the standard library, you have to
517+
provide it yourself.
518+
511519
## Using libcore
512520

513521
> **Note**: the core library's structure is unstable, and it is recommended to
@@ -686,6 +694,7 @@ fn main(argc: int, argv: *const *const u8) -> int {
686694
687695
#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
688696
#[lang = "eh_personality"] extern fn eh_personality() {}
697+
#[lang = "sized"] trait Sized {}
689698
```
690699

691700
Note the use of `abort`: the `exchange_malloc` lang item is assumed to

branches/dist-snap/src/doc/guide.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ Save the file, and then type this into your terminal window:
152152

153153
```{bash}
154154
$ rustc main.rs
155-
$ ./hello_world # or hello_world.exe on Windows
155+
$ ./main # or main.exe on Windows
156156
Hello, world!
157157
```
158158

@@ -164,7 +164,7 @@ fn main() {
164164
}
165165
```
166166

167-
These two lines define a **function** in Rust. The `main` function is special:
167+
These lines define a **function** in Rust. The `main` function is special:
168168
it's the beginning of every Rust program. The first line says "I'm declaring a
169169
function named `main`, which takes no arguments and returns nothing." If there
170170
were arguments, they would go inside the parentheses (`(` and `)`), and because
@@ -232,10 +232,10 @@ main.exe main.rs
232232
```
233233

234234
There are now two files: our source code, with the `.rs` extension, and the
235-
executable (`hello_world.exe` on Windows, `hello_world` everywhere else)
235+
executable (`main.exe` on Windows, `main` everywhere else)
236236

237237
```{bash}
238-
$ ./hello_world # or hello_world.exe on Windows
238+
$ ./main # or main.exe on Windows
239239
```
240240

241241
This prints out our `Hello, world!` text to our terminal.

branches/dist-snap/src/liballoc/heap.rs

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// FIXME: #13994: port to the sized deallocation API when available
1211
// FIXME: #13996: mark the `allocate` and `reallocate` return value as `noalias`
13-
// and `nonnull`
1412

15-
#[cfg(not(test))] use core::raw;
13+
#[cfg(stage0, not(test))] use core::raw;
1614
#[cfg(stage0, not(test))] use util;
1715

1816
/// Returns a pointer to `size` bytes of memory.
@@ -88,18 +86,19 @@ pub fn stats_print() {
8886
imp::stats_print();
8987
}
9088

91-
// The compiler never calls `exchange_free` on Box<ZeroSizeType>, so zero-size
92-
// allocations can point to this `static`. It would be incorrect to use a null
93-
// pointer, due to enums assuming types like unique pointers are never null.
94-
pub static mut EMPTY: uint = 12345;
89+
/// An arbitrary non-null address to represent zero-size allocations.
90+
///
91+
/// This preserves the non-null invariant for types like `Box<T>`. The address may overlap with
92+
/// non-zero-size memory allocations.
93+
pub static EMPTY: *mut () = 0x1 as *mut ();
9594

9695
/// The allocator for unique pointers.
9796
#[cfg(not(test))]
9897
#[lang="exchange_malloc"]
9998
#[inline]
10099
unsafe fn exchange_malloc(size: uint, align: uint) -> *mut u8 {
101100
if size == 0 {
102-
&EMPTY as *const uint as *mut u8
101+
EMPTY as *mut u8
103102
} else {
104103
allocate(size, align)
105104
}
@@ -112,7 +111,6 @@ unsafe fn exchange_free(ptr: *mut u8, size: uint, align: uint) {
112111
deallocate(ptr, size, align);
113112
}
114113

115-
// FIXME: #7496
116114
#[cfg(stage0, not(test))]
117115
#[lang="closure_exchange_malloc"]
118116
#[inline]
@@ -128,21 +126,6 @@ unsafe fn closure_exchange_malloc(drop_glue: fn(*mut u8), size: uint,
128126
alloc as *mut u8
129127
}
130128

131-
// FIXME: #7496
132-
#[cfg(not(stage0), not(test))]
133-
#[lang="closure_exchange_malloc"]
134-
#[inline]
135-
#[allow(deprecated)]
136-
unsafe fn closure_exchange_malloc(drop_glue: fn(*mut u8), size: uint,
137-
align: uint) -> *mut u8 {
138-
let p = allocate(size, align);
139-
140-
let alloc = p as *mut raw::Box<()>;
141-
(*alloc).drop_glue = drop_glue;
142-
143-
alloc as *mut u8
144-
}
145-
146129
// The minimum alignment guaranteed by the architecture. This value is used to
147130
// add fast paths for low alignment values. In practice, the alignment is a
148131
// constant at the call site and the branch will be optimized out.
@@ -255,7 +238,6 @@ mod imp {
255238
#[cfg(not(jemalloc), unix)]
256239
mod imp {
257240
use core::cmp;
258-
use core::mem;
259241
use core::ptr;
260242
use libc;
261243
use libc_heap;

branches/dist-snap/src/libcollections/enum_set.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,31 @@
1414
//! representation to hold C-like enum variants.
1515
1616
use core::prelude::*;
17+
use core::fmt;
1718

18-
#[deriving(Clone, PartialEq, Eq, Hash, Show)]
19+
#[deriving(Clone, PartialEq, Eq, Hash)]
1920
/// A specialized `Set` implementation to use enum types.
2021
pub struct EnumSet<E> {
2122
// We must maintain the invariant that no bits are set
2223
// for which no variant exists
2324
bits: uint
2425
}
2526

27+
impl<E:CLike+fmt::Show> fmt::Show for EnumSet<E> {
28+
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
29+
try!(write!(fmt, "{{"));
30+
let mut first = true;
31+
for e in self.iter() {
32+
if !first {
33+
try!(write!(fmt, ", "));
34+
}
35+
try!(write!(fmt, "{}", e));
36+
first = false;
37+
}
38+
write!(fmt, "}}")
39+
}
40+
}
41+
2642
/// An interface for casting C-like enum to uint and back.
2743
pub trait CLike {
2844
/// Converts a C-like enum to a `uint`.
@@ -165,6 +181,16 @@ mod test {
165181
assert!(e.is_empty());
166182
}
167183

184+
#[test]
185+
fn test_show() {
186+
let mut e = EnumSet::empty();
187+
assert_eq!("{}", e.to_string().as_slice());
188+
e.add(A);
189+
assert_eq!("{A}", e.to_string().as_slice());
190+
e.add(C);
191+
assert_eq!("{A, C}", e.to_string().as_slice());
192+
}
193+
168194
///////////////////////////////////////////////////////////////////////////
169195
// intersect
170196

branches/dist-snap/src/libcollections/vec.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
1515
use core::prelude::*;
1616

17-
use alloc::heap::{allocate, reallocate, deallocate};
17+
use alloc::heap::{EMPTY, allocate, reallocate, deallocate};
1818
use core::cmp::max;
1919
use core::default::Default;
2020
use core::fmt;
@@ -28,10 +28,6 @@ use {Mutable, MutableSeq};
2828
use slice::{MutableOrdSlice, MutableSliceAllocating, CloneableVector};
2929
use slice::{Items, MutItems};
3030

31-
32-
#[doc(hidden)]
33-
pub static PTR_MARKER: u8 = 0;
34-
3531
/// An owned, growable vector.
3632
///
3733
/// # Examples
@@ -124,7 +120,7 @@ impl<T> Vec<T> {
124120
// non-null value which is fine since we never call deallocate on the ptr
125121
// if cap is 0. The reason for this is because the pointer of a slice
126122
// being NULL would break the null pointer optimization for enums.
127-
Vec { len: 0, cap: 0, ptr: &PTR_MARKER as *const _ as *mut T }
123+
Vec { len: 0, cap: 0, ptr: EMPTY as *mut T }
128124
}
129125

130126
/// Constructs a new, empty `Vec` with the specified capacity.
@@ -157,7 +153,7 @@ impl<T> Vec<T> {
157153
#[inline]
158154
pub fn with_capacity(capacity: uint) -> Vec<T> {
159155
if mem::size_of::<T>() == 0 {
160-
Vec { len: 0, cap: uint::MAX, ptr: &PTR_MARKER as *const _ as *mut T }
156+
Vec { len: 0, cap: uint::MAX, ptr: EMPTY as *mut T }
161157
} else if capacity == 0 {
162158
Vec::new()
163159
} else {
@@ -1664,6 +1660,8 @@ impl<T> DoubleEndedIterator<T> for MoveItems<T> {
16641660
}
16651661
}
16661662

1663+
impl<T> ExactSize<T> for MoveItems<T> {}
1664+
16671665
#[unsafe_destructor]
16681666
impl<T> Drop for MoveItems<T> {
16691667
fn drop(&mut self) {

branches/dist-snap/src/librlibc/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@
3535
// LLVM to optimize these function calls to themselves!
3636
#![no_builtins]
3737

38+
#[phase(plugin, link)] extern crate core;
39+
3840
#[cfg(test)] extern crate native;
3941
#[cfg(test)] extern crate test;
4042
#[cfg(test)] extern crate debug;
4143

4244
#[cfg(test)] #[phase(plugin, link)] extern crate std;
43-
#[cfg(test)] #[phase(plugin, link)] extern crate core;
4445

4546
// Require the offset intrinsics for LLVM to properly optimize the
4647
// implementations below. If pointer arithmetic is done through integers the

branches/dist-snap/src/librustc/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ pub mod middle {
108108
pub mod save;
109109
pub mod stability;
110110
pub mod subst;
111+
pub mod traits;
111112
pub mod trans;
112113
pub mod ty;
113114
pub mod ty_fold;

branches/dist-snap/src/librustc/lint/builtin.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,17 +1470,17 @@ impl LintPass for Stability {
14701470
def_id
14711471
}
14721472
typeck::MethodParam(typeck::MethodParam {
1473-
trait_id: trait_id,
1473+
trait_ref: ref trait_ref,
14741474
method_num: index,
14751475
..
1476-
})
1477-
| typeck::MethodObject(typeck::MethodObject {
1478-
trait_id: trait_id,
1476+
}) |
1477+
typeck::MethodObject(typeck::MethodObject {
1478+
trait_ref: ref trait_ref,
14791479
method_num: index,
14801480
..
14811481
}) => {
14821482
match ty::trait_item(cx.tcx,
1483-
trait_id,
1483+
trait_ref.def_id,
14841484
index) {
14851485
ty::MethodTraitItem(method) => {
14861486
method.def_id

branches/dist-snap/src/librustc/metadata/common.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,10 @@ pub enum astencode_tag { // Reserves 0x40 -- 0x5f
140140
tag_table_unboxed_closures = 0x54,
141141
tag_table_upvar_borrow_map = 0x55,
142142
tag_table_capture_modes = 0x56,
143+
tag_table_object_cast_map = 0x57,
143144
}
144145
static first_astencode_tag: uint = tag_ast as uint;
145-
static last_astencode_tag: uint = tag_table_capture_modes as uint;
146+
static last_astencode_tag: uint = tag_table_object_cast_map as uint;
146147
impl astencode_tag {
147148
pub fn from_uint(value : uint) -> Option<astencode_tag> {
148149
let is_a_tag = first_astencode_tag <= value && value <= last_astencode_tag;

0 commit comments

Comments
 (0)