Skip to content

Commit f7745f6

Browse files
committed
---
yaml --- r: 155125 b: refs/heads/try2 c: b88f867 h: refs/heads/master i: 155123: fcabee0 v: v3
1 parent 7493c03 commit f7745f6

File tree

108 files changed

+428
-504
lines changed

Some content is hidden

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

108 files changed

+428
-504
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: cdd46f8592a0ca7eb69110bff0569094951ccc67
8+
refs/heads/try2: b88f86782ecd9319e0e2c875bbf1efecd66ebf41
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/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-
$ ./main # or main.exe on Windows
155+
$ ./hello_world # or hello_world.exe on Windows
156156
Hello, world!
157157
```
158158

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

167-
These lines define a **function** in Rust. The `main` function is special:
167+
These two 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 (`main.exe` on Windows, `main` everywhere else)
235+
executable (`hello_world.exe` on Windows, `hello_world` everywhere else)
236236

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

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

branches/try2/src/liballoc/heap.rs

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
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
1112
// FIXME: #13996: mark the `allocate` and `reallocate` return value as `noalias`
13+
// and `nonnull`
1214

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

1618
/// Returns a pointer to `size` bytes of memory.
@@ -86,19 +88,18 @@ pub fn stats_print() {
8688
imp::stats_print();
8789
}
8890

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 ();
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;
9495

9596
/// The allocator for unique pointers.
9697
#[cfg(not(test))]
9798
#[lang="exchange_malloc"]
9899
#[inline]
99100
unsafe fn exchange_malloc(size: uint, align: uint) -> *mut u8 {
100101
if size == 0 {
101-
EMPTY as *mut u8
102+
&EMPTY as *const uint as *mut u8
102103
} else {
103104
allocate(size, align)
104105
}
@@ -111,6 +112,7 @@ unsafe fn exchange_free(ptr: *mut u8, size: uint, align: uint) {
111112
deallocate(ptr, size, align);
112113
}
113114

115+
// FIXME: #7496
114116
#[cfg(stage0, not(test))]
115117
#[lang="closure_exchange_malloc"]
116118
#[inline]
@@ -126,6 +128,21 @@ unsafe fn closure_exchange_malloc(drop_glue: fn(*mut u8), size: uint,
126128
alloc as *mut u8
127129
}
128130

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+
129146
// The minimum alignment guaranteed by the architecture. This value is used to
130147
// add fast paths for low alignment values. In practice, the alignment is a
131148
// constant at the call site and the branch will be optimized out.

branches/try2/src/libcollections/enum_set.rs

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

19-
#[deriving(Clone, PartialEq, Eq, Hash)]
18+
#[deriving(Clone, PartialEq, Eq, Hash, Show)]
2019
/// A specialized `Set` implementation to use enum types.
2120
pub struct EnumSet<E> {
2221
// We must maintain the invariant that no bits are set
2322
// for which no variant exists
2423
bits: uint
2524
}
2625

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-
4226
/// An interface for casting C-like enum to uint and back.
4327
pub trait CLike {
4428
/// Converts a C-like enum to a `uint`.
@@ -181,16 +165,6 @@ mod test {
181165
assert!(e.is_empty());
182166
}
183167

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-
194168
///////////////////////////////////////////////////////////////////////////
195169
// intersect
196170

branches/try2/src/libcollections/vec.rs

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

17-
use alloc::heap::{EMPTY, allocate, reallocate, deallocate};
17+
use alloc::heap::{allocate, reallocate, deallocate};
1818
use core::cmp::max;
1919
use core::default::Default;
2020
use core::fmt;
@@ -28,6 +28,10 @@ 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+
3135
/// An owned, growable vector.
3236
///
3337
/// # Examples
@@ -120,7 +124,7 @@ impl<T> Vec<T> {
120124
// non-null value which is fine since we never call deallocate on the ptr
121125
// if cap is 0. The reason for this is because the pointer of a slice
122126
// being NULL would break the null pointer optimization for enums.
123-
Vec { len: 0, cap: 0, ptr: EMPTY as *mut T }
127+
Vec { len: 0, cap: 0, ptr: &PTR_MARKER as *const _ as *mut T }
124128
}
125129

126130
/// Constructs a new, empty `Vec` with the specified capacity.
@@ -153,7 +157,7 @@ impl<T> Vec<T> {
153157
#[inline]
154158
pub fn with_capacity(capacity: uint) -> Vec<T> {
155159
if mem::size_of::<T>() == 0 {
156-
Vec { len: 0, cap: uint::MAX, ptr: EMPTY as *mut T }
160+
Vec { len: 0, cap: uint::MAX, ptr: &PTR_MARKER as *const _ as *mut T }
157161
} else if capacity == 0 {
158162
Vec::new()
159163
} else {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ lets_do_this! {
265265
BeginUnwindLangItem, "begin_unwind", begin_unwind;
266266

267267
ExchangeMallocFnLangItem, "exchange_malloc", exchange_malloc_fn;
268+
ClosureExchangeMallocFnLangItem, "closure_exchange_malloc", closure_exchange_malloc_fn;
268269
ExchangeFreeFnLangItem, "exchange_free", exchange_free_fn;
269270
MallocFnLangItem, "malloc", malloc_fn;
270271
FreeFnLangItem, "free", free_fn;

branches/try2/src/librustc/middle/trans/base.rs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -383,10 +383,14 @@ pub fn malloc_raw_dyn<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
383383
Result::new(r.bcx, PointerCast(r.bcx, r.val, llty_ptr))
384384
}
385385

386-
pub fn malloc_raw_dyn_proc<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: ty::t) -> Result<'blk, 'tcx> {
386+
pub fn malloc_raw_dyn_proc<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
387+
t: ty::t, alloc_fn: LangItem)
388+
-> Result<'blk, 'tcx> {
387389
let _icx = push_ctxt("malloc_raw_dyn_proc");
388390
let ccx = bcx.ccx();
389391

392+
let langcall = require_alloc_fn(bcx, t, alloc_fn);
393+
390394
// Grab the TypeRef type of ptr_ty.
391395
let ptr_ty = ty::mk_uniq(bcx.tcx(), t);
392396
let ptr_llty = type_of(ccx, ptr_ty);
@@ -395,15 +399,18 @@ pub fn malloc_raw_dyn_proc<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: ty::t) -> Resu
395399
let size = llsize_of(bcx.ccx(), llty);
396400
let llalign = C_uint(ccx, llalign_of_min(bcx.ccx(), llty) as uint);
397401

398-
// Allocate space and store the destructor pointer:
399-
let Result {bcx: bcx, val: llbox} = malloc_raw_dyn(bcx, ptr_llty, t, size, llalign);
400-
let dtor_ptr = GEPi(bcx, llbox, [0u, abi::box_field_drop_glue]);
401-
let drop_glue_field_ty = type_of(ccx, ty::mk_nil_ptr(bcx.tcx()));
402-
let drop_glue = PointerCast(bcx, glue::get_drop_glue(ccx, ty::mk_uniq(bcx.tcx(), t)),
403-
drop_glue_field_ty);
404-
Store(bcx, drop_glue, dtor_ptr);
405-
406-
Result::new(bcx, llbox)
402+
// Allocate space:
403+
let drop_glue = glue::get_drop_glue(ccx, ty::mk_uniq(bcx.tcx(), t));
404+
let r = callee::trans_lang_call(
405+
bcx,
406+
langcall,
407+
[
408+
PointerCast(bcx, drop_glue, Type::glue_fn(ccx, Type::i8p(ccx)).ptr_to()),
409+
size,
410+
llalign
411+
],
412+
None);
413+
Result::new(r.bcx, PointerCast(r.bcx, r.val, ptr_llty))
407414
}
408415

409416

branches/try2/src/librustc/middle/trans/closure.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use driver::config::FullDebugInfo;
1515
use llvm::ValueRef;
1616
use middle::def;
1717
use middle::freevars;
18+
use middle::lang_items::ClosureExchangeMallocFnLangItem;
1819
use middle::trans::adt;
1920
use middle::trans::base::*;
2021
use middle::trans::build::*;
@@ -145,7 +146,7 @@ fn allocate_cbox<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
145146
let cbox_ty = tuplify_box_ty(tcx, cdata_ty);
146147
match store {
147148
ty::UniqTraitStore => {
148-
malloc_raw_dyn_proc(bcx, cbox_ty)
149+
malloc_raw_dyn_proc(bcx, cbox_ty, ClosureExchangeMallocFnLangItem)
149150
}
150151
ty::RegionTraitStore(..) => {
151152
let llbox = alloc_ty(bcx, cbox_ty, "__closure");

branches/try2/src/librustc/middle/trans/glue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ fn make_drop_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v0: ValueRef, t: ty::t)
519519
let env_ptr_ty = Type::at_box(bcx.ccx(), Type::i8(bcx.ccx())).ptr_to();
520520
let env = PointerCast(bcx, env, env_ptr_ty);
521521
with_cond(bcx, IsNotNull(bcx, env), |bcx| {
522-
let dtor_ptr = GEPi(bcx, env, [0u, abi::box_field_drop_glue]);
522+
let dtor_ptr = GEPi(bcx, env, [0u, abi::box_field_tydesc]);
523523
let dtor = Load(bcx, dtor_ptr);
524524
Call(bcx, dtor, [PointerCast(bcx, box_cell_v, Type::i8p(bcx.ccx()))], None);
525525
bcx

branches/try2/src/librustc_back/abi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
pub static box_field_refcnt: uint = 0u;
12-
pub static box_field_drop_glue: uint = 1u;
12+
pub static box_field_tydesc: uint = 1u;
1313
pub static box_field_body: uint = 4u;
1414

1515
pub static tydesc_field_visit_glue: uint = 3u;

branches/try2/src/libsyntax/owned_slice.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use std::fmt;
1212
use std::default::Default;
1313
use std::hash;
1414
use std::{mem, raw, ptr, slice, vec};
15-
use std::rt::heap::EMPTY;
1615
use serialize::{Encodable, Decodable, Encoder, Decoder};
1716

1817
/// A non-growable owned slice. This would preferably become `~[T]`
@@ -82,9 +81,10 @@ impl<T> OwnedSlice<T> {
8281
}
8382

8483
pub fn as_slice<'a>(&'a self) -> &'a [T] {
84+
static PTR_MARKER: u8 = 0;
8585
let ptr = if self.data.is_null() {
8686
// length zero, i.e. this will never be read as a T.
87-
EMPTY as *const T
87+
&PTR_MARKER as *const u8 as *const T
8888
} else {
8989
self.data as *const T
9090
};

branches/try2/src/libsyntax/util/interner.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use std::cell::RefCell;
1919
use std::cmp::Equiv;
2020
use std::fmt;
2121
use std::hash::Hash;
22+
use std::mem;
2223
use std::rc::Rc;
2324

2425
pub struct Interner<T> {
@@ -191,6 +192,16 @@ impl StrInterner {
191192
(*self.vect.borrow().get(idx.uint())).clone()
192193
}
193194

195+
/// Returns this string with lifetime tied to the interner. Since
196+
/// strings may never be removed from the interner, this is safe.
197+
pub fn get_ref<'a>(&'a self, idx: Name) -> &'a str {
198+
let vect = self.vect.borrow();
199+
let s: &str = vect.get(idx.uint()).as_slice();
200+
unsafe {
201+
mem::transmute(s)
202+
}
203+
}
204+
194205
pub fn len(&self) -> uint {
195206
self.vect.borrow().len()
196207
}

branches/try2/src/snapshots.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
S 2014-09-10 6faa4f3
22
winnt-x86_64 939eb546469cb936441cff3b6f2478f562f77c46
33
winnt-i386 cfe4f8b519bb9d62588f9310a8f94bc919d5423b
4-
linux-x86_64 40e2ab1b67d0a2859f7da15e13bfd2748b50f0c7
4+
linux-x86_64 72c92895fa9a1dba7880073f2b2b5d0e3e1a2ab6
55
linux-i386 6f5464c9ab191d93bfea0894ca7c6f90c3506f2b
66
freebsd-x86_64 648f35800ba98f1121d418b6d0c13c63b7a8951b
77
macos-i386 545fc45a0071142714639c6be377e6d308c3a4e1

branches/try2/src/test/compile-fail/bad-method-typaram-kind.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
fn foo<T:'static>() {
12-
1u.bar::<T>(); //~ ERROR: does not fulfill `Send`
12+
1u.bar::<T>(); //~ ERROR `core::kinds::Send` is not implemented
1313
}
1414

1515
trait bar {

branches/try2/src/test/compile-fail/bad-sized.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ trait Trait {}
1616

1717
pub fn main() {
1818
let x: Vec<Trait + Sized> = Vec::new();
19-
//~^ ERROR instantiating a type parameter with an incompatible type `Trait+Sized`, which does not fulfill `Sized`
20-
//~^^ ERROR instantiating a type parameter with an incompatible type `Trait+Sized`, which does not fulfill `Sized`
21-
//~^^^ ERROR instantiating a type parameter with an incompatible type `Trait+Sized`, which does not fulfill `Sized`
19+
//~^ ERROR the trait `core::kinds::Sized` is not implemented
20+
//~^^ ERROR the trait `core::kinds::Sized` is not implemented
2221
let x: Vec<Box<RefCell<Trait + Sized>>> = Vec::new();
23-
//~^ ERROR instantiating a type parameter with an incompatible type `Trait+Sized`, which does not fulfill `Sized`
24-
//~^^ ERROR instantiating a type parameter with an incompatible type `Trait+Sized`, which does not fulfill `Sized`
22+
//~^ ERROR the trait `core::kinds::Sized` is not implemented
2523
}

branches/try2/src/test/compile-fail/builtin-superkinds-double-superkind.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
trait Foo : Send+Sync { }
1515

16-
impl <T: Sync> Foo for (T,) { } //~ ERROR cannot implement this trait
16+
impl <T: Sync+'static> Foo for (T,) { } //~ ERROR the trait `core::kinds::Send` is not implemented
1717

18-
impl <T: Send> Foo for (T,T) { } //~ ERROR cannot implement this trait
18+
impl <T: Send> Foo for (T,T) { } //~ ERROR the trait `core::kinds::Sync` is not implemented
1919

2020
impl <T: Send+Sync> Foo for (T,T,T) { } // (ok)
2121

branches/try2/src/test/compile-fail/builtin-superkinds-in-metadata.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ struct X<T>(T);
2121

2222
impl <T:Sync> RequiresShare for X<T> { }
2323

24-
impl <T:Sync> RequiresRequiresShareAndSend for X<T> { } //~ ERROR cannot implement this trait
24+
impl <T:Sync+'static> RequiresRequiresShareAndSend for X<T> { }
25+
//~^ ERROR the trait `core::kinds::Send` is not implemented
2526

2627
fn main() { }

branches/try2/src/test/compile-fail/builtin-superkinds-self-type.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
// to use capabilities granted by builtin kinds as supertraits.
1313

1414
trait Foo : Sync+'static {
15-
fn foo(self, mut chan: Sender<Self>) {
16-
chan.send(self); //~ ERROR does not fulfill `Send`
17-
}
15+
fn foo(self, mut chan: Sender<Self>) { }
1816
}
1917

2018
impl <T: Sync> Foo for T { }
19+
//~^ ERROR the parameter type `T` may not live long enough
20+
//~^^ ERROR the parameter type `T` may not live long enough
2121

2222
fn main() {
2323
let (tx, rx) = channel();

0 commit comments

Comments
 (0)