Skip to content

Commit 15713c1

Browse files
committed
---
yaml --- r: 156459 b: refs/heads/snap-stage3 c: 7d0cc44 h: refs/heads/master i: 156457: d44fdb7 156455: 5a042e6 v: v3
1 parent d9f5e86 commit 15713c1

File tree

18 files changed

+112
-25
lines changed

18 files changed

+112
-25
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: c29a7520e7fb4a5b4d4eccfc594e05793ef6688d
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 96445a533e8ea40701e2a9bbd25347141e63c115
4+
refs/heads/snap-stage3: 7d0cc44f873ac338b400b20bcb62618aa5d36b70
55
refs/heads/try: 6601b0501e31d08d3892a2d5a7d8a57ab120bf75
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3095,10 +3095,10 @@ And try to run the test:
30953095

30963096
```{notrust,ignore}
30973097
$ cargo test
3098-
Compiling testing v0.0.1 (file:///home/youg/projects/testing)
3099-
/home/youg/projects/testing/tests/lib.rs:3:18: 3:38 error: unresolved name `add_three_times_four`.
3100-
/home/youg/projects/testing/tests/lib.rs:3 let result = add_three_times_four(5i);
3101-
^~~~~~~~~~~~~~~~~~~~
3098+
Compiling testing v0.0.1 (file:///home/you/projects/testing)
3099+
/home/you/projects/testing/tests/lib.rs:3:18: 3:38 error: unresolved name `add_three_times_four`.
3100+
/home/you/projects/testing/tests/lib.rs:3 let result = add_three_times_four(5i);
3101+
^~~~~~~~~~~~~~~~~~~~
31023102
error: aborting due to previous error
31033103
Build failed, waiting for other jobs to finish...
31043104
Could not compile `testing`.

branches/snap-stage3/src/libcore/num/f32.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,11 @@ impl Float for f32 {
259259

260260
#[inline]
261261
fn sqrt(self) -> f32 {
262-
unsafe { intrinsics::sqrtf32(self) }
262+
if self < 0.0 {
263+
NAN
264+
} else {
265+
unsafe { intrinsics::sqrtf32(self) }
266+
}
263267
}
264268

265269
#[inline]

branches/snap-stage3/src/libcore/num/f64.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,11 @@ impl Float for f64 {
266266

267267
#[inline]
268268
fn sqrt(self) -> f64 {
269-
unsafe { intrinsics::sqrtf64(self) }
269+
if self < 0.0 {
270+
NAN
271+
} else {
272+
unsafe { intrinsics::sqrtf64(self) }
273+
}
270274
}
271275

272276
#[inline]
@@ -377,4 +381,3 @@ impl Float for f64 {
377381
self * (value / 180.0)
378382
}
379383
}
380-

branches/snap-stage3/src/libcore/num/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,6 +1501,8 @@ pub trait Float: Signed + Primitive {
15011501
fn frac_1_sqrt2() -> Self;
15021502

15031503
/// Take the square root of a number.
1504+
///
1505+
/// Returns NaN if `self` is not a non-negative number.
15041506
fn sqrt(self) -> Self;
15051507
/// Take the reciprocal (inverse) square root of a number, `1/sqrt(x)`.
15061508
fn rsqrt(self) -> Self;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ pub enum ObligationCauseCode {
7777
AssignmentLhsSized, // L = X implies that L is Sized
7878
StructInitializerSized, // S { ... } must be Sized
7979
VariableType(ast::NodeId), // Type of each variable must be Sized
80+
ReturnType, // Return type must be Sized
8081
RepeatVec, // [T,..n] --> T must be Copy
8182

8283
// Captures of variable the given id by a closure (span is the

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -555,16 +555,12 @@ fn check_fn<'a, 'tcx>(ccx: &'a CrateCtxt<'a, 'tcx>,
555555

556556
// Remember return type so that regionck can access it later.
557557
let fn_sig_tys: Vec<ty::t> =
558-
arg_tys.iter()
559-
.chain([ret_ty].iter())
560-
.map(|&ty| ty)
561-
.collect();
558+
arg_tys.iter().chain([ret_ty].iter()).map(|&ty| ty).collect();
562559
debug!("fn-sig-map: fn_id={} fn_sig_tys={}",
563560
fn_id,
564561
fn_sig_tys.repr(tcx));
565-
inherited.fn_sig_map
566-
.borrow_mut()
567-
.insert(fn_id, fn_sig_tys);
562+
563+
inherited.fn_sig_map.borrow_mut().insert(fn_id, fn_sig_tys);
568564

569565
{
570566
let mut visit = GatherLocalsVisitor { fcx: &fcx, };
@@ -591,6 +587,7 @@ fn check_fn<'a, 'tcx>(ccx: &'a CrateCtxt<'a, 'tcx>,
591587

592588
visit.visit_block(body);
593589
}
590+
fcx.require_type_is_sized(ret_ty, decl.output.span, traits::ReturnType);
594591

595592
check_block_with_expected(&fcx, body, ExpectHasType(ret_ty));
596593

branches/snap-stage3/src/librustc/middle/typeck/check/vtable2.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,15 +366,20 @@ fn note_obligation_cause(fcx: &FnCtxt,
366366
traits::RepeatVec => {
367367
tcx.sess.span_note(
368368
obligation.cause.span,
369-
format!(
370-
"the `Copy` trait is required because the \
371-
repeated element will be copied").as_slice());
369+
"the `Copy` trait is required because the \
370+
repeated element will be copied");
372371
}
373372
traits::VariableType(_) => {
374373
tcx.sess.span_note(
375374
obligation.cause.span,
376375
"all local variables must have a statically known size");
377376
}
377+
traits::ReturnType => {
378+
tcx.sess.span_note(
379+
obligation.cause.span,
380+
"the return type of a function must have a \
381+
statically known size");
382+
}
378383
traits::AssignmentLhsSized => {
379384
tcx.sess.span_note(
380385
obligation.cause.span,

branches/snap-stage3/src/libstd/io/buffered.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ impl<R: Reader> Buffer for BufferedReader<R> {
104104

105105
impl<R: Reader> Reader for BufferedReader<R> {
106106
fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
107+
if self.pos == self.cap && buf.len() >= self.buf.capacity() {
108+
return self.inner.read(buf);
109+
}
107110
let nread = {
108111
let available = try!(self.fill_buf());
109112
let nread = cmp::min(available.len(), buf.len());
@@ -409,13 +412,19 @@ mod test {
409412

410413
#[test]
411414
fn test_buffered_reader() {
412-
let inner = MemReader::new(vec!(0, 1, 2, 3, 4));
415+
let inner = MemReader::new(vec!(5, 6, 7, 0, 1, 2, 3, 4));
413416
let mut reader = BufferedReader::with_capacity(2, inner);
414417

415418
let mut buf = [0, 0, 0];
416419
let nread = reader.read(buf);
420+
assert_eq!(Ok(3), nread);
421+
let b: &[_] = &[5, 6, 7];
422+
assert_eq!(buf.as_slice(), b);
423+
424+
let mut buf = [0, 0];
425+
let nread = reader.read(buf);
417426
assert_eq!(Ok(2), nread);
418-
let b: &[_] = &[0, 1, 0];
427+
let b: &[_] = &[0, 1];
419428
assert_eq!(buf.as_slice(), b);
420429

421430
let mut buf = [0];

branches/snap-stage3/src/libstd/num/f32.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,4 +764,15 @@ mod tests {
764764
assert_eq!(NEG_INFINITY.integer_decode(), (8388608u64, 105i16, -1i8));
765765
assert_eq!(NAN.integer_decode(), (12582912u64, 105i16, 1i8));
766766
}
767+
768+
#[test]
769+
fn test_sqrt_domain() {
770+
assert!(NAN.sqrt().is_nan());
771+
assert!(NEG_INFINITY.sqrt().is_nan());
772+
assert!((-1.0f32).sqrt().is_nan());
773+
assert_eq!((-0.0f32).sqrt(), -0.0);
774+
assert_eq!(0.0f32.sqrt(), 0.0);
775+
assert_eq!(1.0f32.sqrt(), 1.0);
776+
assert_eq!(INFINITY.sqrt(), INFINITY);
777+
}
767778
}

branches/snap-stage3/src/libstd/num/f64.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,4 +766,15 @@ mod tests {
766766
assert_eq!(NEG_INFINITY.integer_decode(), (4503599627370496, 972, -1));
767767
assert_eq!(NAN.integer_decode(), (6755399441055744u64, 972i16, 1i8));
768768
}
769+
770+
#[test]
771+
fn test_sqrt_domain() {
772+
assert!(NAN.sqrt().is_nan());
773+
assert!(NEG_INFINITY.sqrt().is_nan());
774+
assert!((-1.0f64).sqrt().is_nan());
775+
assert_eq!((-0.0f64).sqrt(), -0.0);
776+
assert_eq!(0.0f64.sqrt(), 0.0);
777+
assert_eq!(1.0f64.sqrt(), 1.0);
778+
assert_eq!(INFINITY.sqrt(), INFINITY);
779+
}
769780
}

branches/snap-stage3/src/libsyntax/print/pprust.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2680,8 +2680,9 @@ impl<'a> State<'a> {
26802680
ast_util::int_ty_to_string(st, Some(i as i64)).as_slice())
26812681
}
26822682
ast::SignedIntLit(st, ast::Minus) => {
2683+
let istr = ast_util::int_ty_to_string(st, Some(-(i as i64)));
26832684
word(&mut self.s,
2684-
ast_util::int_ty_to_string(st, Some(-(i as i64))).as_slice())
2685+
format!("-{}", istr).as_slice())
26852686
}
26862687
ast::UnsignedIntLit(ut) => {
26872688
word(&mut self.s, ast_util::uint_ty_to_string(ut, Some(i)).as_slice())
@@ -2930,4 +2931,12 @@ mod test {
29302931
let varstr = variant_to_string(&var);
29312932
assert_eq!(&varstr,&"pub principal_skinner".to_string());
29322933
}
2934+
2935+
#[test]
2936+
fn test_signed_int_to_string() {
2937+
let pos_int = ast::LitInt(42, ast::SignedIntLit(ast::TyI32, ast::Plus));
2938+
let neg_int = ast::LitInt((-42) as u64, ast::SignedIntLit(ast::TyI32, ast::Minus));
2939+
assert_eq!(format!("-{}", lit_to_string(&codemap::dummy_spanned(pos_int))),
2940+
lit_to_string(&codemap::dummy_spanned(neg_int)));
2941+
}
29332942
}

branches/snap-stage3/src/test/auxiliary/lang-item-public.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
#![no_std]
1212
#![feature(lang_items)]
1313

14+
#[lang="sized"]
15+
pub trait Sized for Sized? {}
16+
1417
#[lang="fail"]
1518
fn fail(_: &(&'static str, &'static str, uint)) -> ! { loop {} }
1619

branches/snap-stage3/src/test/compile-fail/issue-17025.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ enum A {
1313
C([Box<A>]),
1414
}
1515

16-
fn c(c:char) -> A {
17-
B(c) //~ ERROR cannot move a value of type A: the size of A cannot be statically determined
16+
fn c(c:char) {
17+
B(c);
18+
//~^ ERROR cannot move a value of type A: the size of A cannot be statically determined
1819
}
1920

2021
pub fn main() {}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
12+
13+
pub trait AbstractRenderer {}
14+
15+
fn _create_render(_: &()) ->
16+
AbstractRenderer
17+
//~^ ERROR: the trait `core::kinds::Sized` is not implemented
18+
{
19+
match 0u {
20+
_ => unimplemented!()
21+
}
22+
}
23+
24+
fn main() {
25+
}

branches/snap-stage3/src/test/compile-fail/issue-5883.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ struct Struct {
1414
r: A+'static
1515
}
1616

17-
fn new_struct(r: A+'static) -> Struct {
17+
fn new_struct(r: A+'static)
18+
-> Struct { //~^ ERROR the trait `core::kinds::Sized` is not implemented
1819
//~^ ERROR the trait `core::kinds::Sized` is not implemented
1920
Struct { r: r }
2021
//~^ ERROR the trait `core::kinds::Sized` is not implemented

branches/snap-stage3/src/test/compile-fail/privacy4.rs

Lines changed: 3 additions & 1 deletion
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-
#![feature(globs)]
11+
#![feature(globs, lang_items)]
1212
#![no_std] // makes debugging this test *a lot* easier (during resolve)
1313

14+
#[lang = "sized"] pub trait Sized for Sized? {}
15+
1416
// Test to make sure that private items imported through globs remain private
1517
// when they're used.
1618

branches/snap-stage3/src/test/compile-fail/required-lang-item.rs

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

11+
#![feature(lang_items)]
1112
#![no_std]
1213

14+
#[lang="sized"] pub trait Sized for Sized? {}
15+
1316
// error-pattern:requires `start` lang_item
1417

1518
fn main() {}

0 commit comments

Comments
 (0)