Skip to content

Commit b3c50db

Browse files
committed
---
yaml --- r: 64175 b: refs/heads/snap-stage3 c: 6d4d2c9 h: refs/heads/master i: 64173: 78102b6 64171: 3860479 64167: cd81b4b 64159: 615b4a3 v: v3
1 parent 195a831 commit b3c50db

File tree

14 files changed

+42
-127
lines changed

14 files changed

+42
-127
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 6f5be9063ddbfe18ce5321817f782abcd2f55110
4+
refs/heads/snap-stage3: 6d4d2c9a33ea0b92e98c22e84e76d3116dcd7444
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/librustc/middle/trans/base.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,13 @@ pub fn malloc_raw_dyn(bcx: block,
292292

293293
if heap == heap_exchange {
294294
let llty_value = type_of::type_of(ccx, t);
295+
let llalign = llalign_of_min(ccx, llty_value);
295296

296297
// Allocate space:
297298
let r = callee::trans_lang_call(
298299
bcx,
299300
bcx.tcx().lang_items.exchange_malloc_fn(),
300-
[size],
301+
[C_i32(llalign as i32), size],
301302
None);
302303
rslt(r.bcx, PointerCast(r.bcx, r.val, llty_value.ptr_to()))
303304
} else if heap == heap_exchange_vector {

branches/snap-stage3/src/librustc/middle/typeck/mod.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -319,19 +319,16 @@ fn check_main_fn_ty(ccx: &CrateCtxt,
319319
}
320320
_ => ()
321321
}
322-
let se_ty = ty::mk_bare_fn(tcx, ty::BareFnTy {
323-
purity: ast::impure_fn,
324-
abis: abi::AbiSet::Rust(),
325-
sig: ty::FnSig {
326-
bound_lifetime_names: opt_vec::Empty,
327-
inputs: ~[],
328-
output: ty::mk_nil()
329-
}
330-
});
331-
332-
require_same_types(tcx, None, false, main_span, main_t, se_ty,
333-
|| fmt!("main function expects type: `%s`",
334-
ppaux::ty_to_str(ccx.tcx, se_ty)));
322+
let mut ok = ty::type_is_nil(fn_ty.sig.output);
323+
let num_args = fn_ty.sig.inputs.len();
324+
ok &= num_args == 0u;
325+
if !ok {
326+
tcx.sess.span_err(
327+
main_span,
328+
fmt!("Wrong type in main function: found `%s`, \
329+
expected `fn() -> ()`",
330+
ppaux::ty_to_str(tcx, main_t)));
331+
}
335332
}
336333
_ => {
337334
tcx.sess.span_bug(main_span,

branches/snap-stage3/src/libstd/bool.rs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ A quick summary:
1919
Implementations of the following traits:
2020
2121
* `FromStr`
22-
* `ToStr`
23-
* `Not`
2422
* `Ord`
2523
* `TotalOrd`
2624
* `Eq`
@@ -38,8 +36,6 @@ Finally, some inquries into the nature of truth: `is_true` and `is_false`.
3836

3937
#[cfg(not(test))]
4038
use cmp::{Eq, Ord, TotalOrd, Ordering};
41-
#[cfg(not(test))]
42-
use ops::Not;
4339
use option::{None, Option, Some};
4440
use from_str::FromStr;
4541
use to_str::ToStr;
@@ -258,27 +254,6 @@ pub fn all_values(blk: &fn(v: bool)) {
258254
#[inline]
259255
pub fn to_bit(v: bool) -> u8 { if v { 1u8 } else { 0u8 } }
260256

261-
/**
262-
* The logical complement of a boolean value.
263-
*
264-
* # Examples
265-
*
266-
* ~~~rust
267-
* rusti> !true
268-
* false
269-
* ~~~
270-
*
271-
* ~~~rust
272-
* rusti> !false
273-
* true
274-
* ~~~
275-
*/
276-
#[cfg(not(test))]
277-
impl Not<bool> for bool {
278-
#[inline]
279-
fn not(&self) -> bool { !*self }
280-
}
281-
282257
#[cfg(not(test))]
283258
impl Ord for bool {
284259
#[inline]

branches/snap-stage3/src/libstd/option.rs

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -379,13 +379,6 @@ impl<'self, A> Iterator<&'self A> for OptionIterator<'self, A> {
379379
fn next(&mut self) -> Option<&'self A> {
380380
util::replace(&mut self.opt, None)
381381
}
382-
383-
fn size_hint(&self) -> (uint, Option<uint>) {
384-
match self.opt {
385-
Some(_) => (1, Some(1)),
386-
None => (0, Some(0)),
387-
}
388-
}
389382
}
390383

391384
/// Mutable iterator over an `Option<A>`
@@ -397,13 +390,6 @@ impl<'self, A> Iterator<&'self mut A> for OptionMutIterator<'self, A> {
397390
fn next(&mut self) -> Option<&'self mut A> {
398391
util::replace(&mut self.opt, None)
399392
}
400-
401-
fn size_hint(&self) -> (uint, Option<uint>) {
402-
match self.opt {
403-
Some(_) => (1, Some(1)),
404-
None => (0, Some(0)),
405-
}
406-
}
407393
}
408394

409395
#[test]
@@ -501,39 +487,3 @@ fn test_filtered() {
501487
assert_eq!(some_stuff.get(), 42);
502488
assert!(modified_stuff.is_none());
503489
}
504-
505-
#[test]
506-
fn test_iter() {
507-
let val = 5;
508-
509-
let x = Some(val);
510-
let mut it = x.iter();
511-
512-
assert_eq!(it.size_hint(), (1, Some(1)));
513-
assert_eq!(it.next(), Some(&val));
514-
assert_eq!(it.size_hint(), (0, Some(0)));
515-
assert!(it.next().is_none());
516-
}
517-
518-
#[test]
519-
fn test_mut_iter() {
520-
let val = 5;
521-
let new_val = 11;
522-
523-
let mut x = Some(val);
524-
let mut it = x.mut_iter();
525-
526-
assert_eq!(it.size_hint(), (1, Some(1)));
527-
528-
match it.next() {
529-
Some(interior) => {
530-
assert_eq!(*interior, val);
531-
*interior = new_val;
532-
assert_eq!(x, Some(new_val));
533-
}
534-
None => assert!(false),
535-
}
536-
537-
assert_eq!(it.size_hint(), (0, Some(0)));
538-
assert!(it.next().is_none());
539-
}

branches/snap-stage3/src/libstd/ptr.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use cast;
1414
use option::{Option, Some, None};
1515
use sys;
1616
use unstable::intrinsics;
17-
use util::swap;
1817

1918
#[cfg(not(test))] use cmp::{Eq, Ord};
2019
use uint;
@@ -178,9 +177,9 @@ pub unsafe fn swap_ptr<T>(x: *mut T, y: *mut T) {
178177
let t: *mut T = &mut tmp;
179178

180179
// Perform the swap
181-
copy_nonoverlapping_memory(t, x, 1);
182-
copy_memory(x, y, 1); // `x` and `y` may overlap
183-
copy_nonoverlapping_memory(y, t, 1);
180+
copy_memory(t, x, 1);
181+
copy_memory(x, y, 1);
182+
copy_memory(y, t, 1);
184183

185184
// y and t now point to the same thing, but we need to completely forget `tmp`
186185
// because it's no longer relevant.
@@ -193,7 +192,7 @@ pub unsafe fn swap_ptr<T>(x: *mut T, y: *mut T) {
193192
*/
194193
#[inline]
195194
pub unsafe fn replace_ptr<T>(dest: *mut T, mut src: T) -> T {
196-
swap(cast::transmute(dest), &mut src); // cannot overlap
195+
swap_ptr(dest, &mut src);
197196
src
198197
}
199198

@@ -203,7 +202,8 @@ pub unsafe fn replace_ptr<T>(dest: *mut T, mut src: T) -> T {
203202
#[inline(always)]
204203
pub unsafe fn read_ptr<T>(src: *mut T) -> T {
205204
let mut tmp: T = intrinsics::uninit();
206-
copy_nonoverlapping_memory(&mut tmp, src, 1);
205+
let t: *mut T = &mut tmp;
206+
copy_memory(t, src, 1);
207207
tmp
208208
}
209209

branches/snap-stage3/src/libstd/repr.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,13 @@ impl ReprVisitor {
206206
inner: *TyDesc)
207207
-> bool {
208208
let mut p = ptr;
209-
let end = ptr::offset(p, len);
210209
let (sz, al) = unsafe { ((*inner).size, (*inner).align) };
211210
self.writer.write_char('[');
212211
let mut first = true;
213-
while (p as uint) < (end as uint) {
212+
let mut left = len;
213+
// unit structs have 0 size, and don't loop forever.
214+
let dec = if sz == 0 {1} else {sz};
215+
while left > 0 {
214216
if first {
215217
first = false;
216218
} else {
@@ -219,6 +221,7 @@ impl ReprVisitor {
219221
self.write_mut_qualifier(mtbl);
220222
self.visit_ptr_inner(p as *c_void, inner);
221223
p = align(ptr::offset(p, sz) as uint, al) as *u8;
224+
left -= dec;
222225
}
223226
self.writer.write_char(']');
224227
true
@@ -635,4 +638,7 @@ fn test_repr() {
635638
"(10, ~\"hello\")");
636639
exact_test(&(10_u64, ~"hello"),
637640
"(10, ~\"hello\")");
641+
642+
struct Foo;
643+
exact_test(&(~[Foo, Foo, Foo]), "~[{}, {}, {}]");
638644
}

branches/snap-stage3/src/libstd/rt/global_heap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ pub unsafe fn exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char {
7676
box as *c_char
7777
}
7878

79-
/// The allocator for unique pointers without contained managed pointers.
79+
// FIXME #4942: Make these signatures agree with exchange_alloc's signatures
8080
#[cfg(not(stage0), not(test))]
8181
#[lang="exchange_malloc"]
8282
#[inline]
83-
pub unsafe fn exchange_malloc(size: uintptr_t) -> *c_char {
83+
pub unsafe fn exchange_malloc(_align: u32, size: uintptr_t) -> *c_char {
8484
malloc_raw(size as uint) as *c_char
8585
}
8686

branches/snap-stage3/src/libstd/vec.rs

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use option::{None, Option, Some};
2727
use ptr::to_unsafe_ptr;
2828
use ptr;
2929
use ptr::RawPtr;
30-
use rt::global_heap::{malloc_raw, realloc_raw};
30+
use rt::global_heap::realloc_raw;
3131
use sys;
3232
use sys::size_of;
3333
use uint;
@@ -101,31 +101,12 @@ pub fn to_owned<T:Copy>(t: &[T]) -> ~[T] {
101101
}
102102

103103
/// Creates a new vector with a capacity of `capacity`
104-
#[cfg(stage0)]
105104
pub fn with_capacity<T>(capacity: uint) -> ~[T] {
106105
let mut vec = ~[];
107106
vec.reserve(capacity);
108107
vec
109108
}
110109

111-
/// Creates a new vector with a capacity of `capacity`
112-
#[cfg(not(stage0))]
113-
pub fn with_capacity<T>(capacity: uint) -> ~[T] {
114-
unsafe {
115-
if contains_managed::<T>() {
116-
let mut vec = ~[];
117-
vec.reserve(capacity);
118-
vec
119-
} else {
120-
let alloc = capacity * sys::nonzero_size_of::<T>();
121-
let ptr = malloc_raw(alloc + size_of::<raw::VecRepr>()) as *mut raw::VecRepr;
122-
(*ptr).unboxed.alloc = alloc;
123-
(*ptr).unboxed.fill = 0;
124-
cast::transmute(ptr)
125-
}
126-
}
127-
}
128-
129110
/**
130111
* Builds a vector by calling a provided function with an argument
131112
* function that pushes an element to the back of a vector.
@@ -1790,7 +1771,7 @@ impl<'self,T> MutableVector<'self, T> for &'self mut [T] {
17901771

17911772
}
17921773

1793-
/// Trait for &[T] where T is Cloneable
1774+
/// Trait for ~[T] where T is Cloneable
17941775
pub trait MutableCloneableVector<T> {
17951776
/// Copies as many elements from `src` as it can into `self`
17961777
/// (the shorter of self.len() and src.len()). Returns the number of elements copied.

branches/snap-stage3/src/libsyntax/diagnostic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ fn print_diagnostic(topic: &str, lvl: level, msg: &str) {
213213
}
214214

215215
print_maybe_colored(fmt!("%s: ", diagnosticstr(lvl)), diagnosticcolor(lvl));
216-
print_maybe_colored(fmt!("%s\n", msg), term::color::BRIGHT_WHITE);
216+
stderr.write_str(fmt!("%s\n", msg));
217217
}
218218

219219
pub fn collect(messages: @mut ~[~str])

branches/snap-stage3/src/test/compile-fail/bad-main.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
fn main(x: int) { } //~ ERROR: main function expects type
11+
// error-pattern:expected `fn()
12+
13+
fn main(x: int) { }
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -8,4 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
extern fn main() {} //~ ERROR: main function expects type
11+
// error-pattern:binary operation + cannot be applied to type `*int`
12+
13+
fn die() -> *int { (0 as *int) + (0 as *int) }
14+
fn main() { }

branches/snap-stage3/src/test/compile-fail/main-wrong-type-2.rs

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

1111
fn main() -> char {
12-
//~^ ERROR: main function expects type
12+
//~^ ERROR Wrong type in main function: found `extern "Rust" fn() -> char`
1313
}

branches/snap-stage3/src/test/compile-fail/main-wrong-type.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ struct S {
1414
}
1515

1616
fn main(foo: S) {
17-
//~^ ERROR: main function expects type
17+
//~^ ERROR Wrong type in main function: found `extern "Rust" fn(S)`
1818
}

0 commit comments

Comments
 (0)