diff options
| author | bors <bors@rust-lang.org> | 2014-09-09 20:16:19 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-09-09 20:16:19 +0000 |
| commit | 651106462c357b71a4ca2c02ba2bfedfc38b0035 (patch) | |
| tree | 79cd7984fb470f273f5907c579a2db5f71296c7e /src/test | |
| parent | b625d43f8fd2e9a800ca8a419f7d3f5f52604205 (diff) | |
| parent | e5abe15ff55212c60fc4acc9bfc2bc79038507b8 (diff) | |
| download | rust-651106462c357b71a4ca2c02ba2bfedfc38b0035.tar.gz rust-651106462c357b71a4ca2c02ba2bfedfc38b0035.zip | |
auto merge of #17127 : alexcrichton/rust/rollup, r=alexcrichton
Diffstat (limited to 'src/test')
37 files changed, 362 insertions, 96 deletions
diff --git a/src/test/bench/shootout-chameneos-redux.rs b/src/test/bench/shootout-chameneos-redux.rs index 0c76d14852e..05ecb9def9b 100644 --- a/src/test/bench/shootout-chameneos-redux.rs +++ b/src/test/bench/shootout-chameneos-redux.rs @@ -1,12 +1,42 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. +// The Computer Language Benchmarks Game +// http://benchmarksgame.alioth.debian.org/ // -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. +// contributed by the Rust Project Developers + +// Copyright (c) 2012-2014 The Rust Project Developers +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// +// - Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// - Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in +// the documentation and/or other materials provided with the +// distribution. +// +// - Neither the name of "The Computer Language Benchmarks Game" nor +// the name of "The Computer Language Shootout Benchmarks" nor the +// names of its contributors may be used to endorse or promote +// products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +// OF THE POSSIBILITY OF SUCH DAMAGE. // no-pretty-expanded diff --git a/src/test/bench/shootout-nbody.rs b/src/test/bench/shootout-nbody.rs index 5a077b37747..9e30a512477 100644 --- a/src/test/bench/shootout-nbody.rs +++ b/src/test/bench/shootout-nbody.rs @@ -1,12 +1,42 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. +// The Computer Language Benchmarks Game +// http://benchmarksgame.alioth.debian.org/ // -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. +// contributed by the Rust Project Developers + +// Copyright (c) 2011-2014 The Rust Project Developers +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// +// - Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// - Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in +// the documentation and/or other materials provided with the +// distribution. +// +// - Neither the name of "The Computer Language Benchmarks Game" nor +// the name of "The Computer Language Shootout Benchmarks" nor the +// names of its contributors may be used to endorse or promote +// products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +// OF THE POSSIBILITY OF SUCH DAMAGE. static PI: f64 = 3.141592653589793; static SOLAR_MASS: f64 = 4.0 * PI * PI; diff --git a/src/test/bench/shootout-reverse-complement.rs b/src/test/bench/shootout-reverse-complement.rs index fdd711d22c7..52defe6a276 100644 --- a/src/test/bench/shootout-reverse-complement.rs +++ b/src/test/bench/shootout-reverse-complement.rs @@ -1,12 +1,42 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. +// The Computer Language Benchmarks Game +// http://benchmarksgame.alioth.debian.org/ // -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. +// contributed by the Rust Project Developers + +// Copyright (c) 2013-2014 The Rust Project Developers +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// +// - Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// - Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in +// the documentation and/or other materials provided with the +// distribution. +// +// - Neither the name of "The Computer Language Benchmarks Game" nor +// the name of "The Computer Language Shootout Benchmarks" nor the +// names of its contributors may be used to endorse or promote +// products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +// OF THE POSSIBILITY OF SUCH DAMAGE. // ignore-pretty very bad with line comments // ignore-android doesn't terminate? diff --git a/src/test/compile-fail/borrowck-for-loop-head-linkage.rs b/src/test/compile-fail/borrowck-for-loop-head-linkage.rs new file mode 100644 index 00000000000..600c0ac801b --- /dev/null +++ b/src/test/compile-fail/borrowck-for-loop-head-linkage.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let mut vector = vec![1u, 2]; + for &x in vector.iter() { + let cap = vector.capacity(); + vector.grow(cap, &0u); //~ ERROR cannot borrow + *vector.get_mut(1u) = 5u; //~ ERROR cannot borrow + } +} + diff --git a/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs b/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs index d87557a46f7..d3c6a280e8c 100644 --- a/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs +++ b/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs @@ -25,7 +25,7 @@ pub fn main() { ); let x: &[Foo] = x.as_slice(); match x { - [_, ..tail] => { + [_, tail..] => { match tail { [Foo { string: a }, //~ ERROR cannot move out of dereference of `&`-pointer Foo { string: b }] => { diff --git a/src/test/compile-fail/borrowck-vec-pattern-element-loan.rs b/src/test/compile-fail/borrowck-vec-pattern-element-loan.rs index 53ebaa38fdd..d256b033298 100644 --- a/src/test/compile-fail/borrowck-vec-pattern-element-loan.rs +++ b/src/test/compile-fail/borrowck-vec-pattern-element-loan.rs @@ -8,11 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(advanced_slice_patterns)] + fn a<'a>() -> &'a [int] { let vec = vec!(1, 2, 3, 4); let vec: &[int] = vec.as_slice(); //~ ERROR does not live long enough let tail = match vec { - [_, ..tail] => tail, + [_, tail..] => tail, _ => fail!("a") }; tail @@ -22,7 +24,7 @@ fn b<'a>() -> &'a [int] { let vec = vec!(1, 2, 3, 4); let vec: &[int] = vec.as_slice(); //~ ERROR does not live long enough let init = match vec { - [..init, _] => init, + [init.., _] => init, _ => fail!("b") }; init @@ -32,7 +34,7 @@ fn c<'a>() -> &'a [int] { let vec = vec!(1, 2, 3, 4); let vec: &[int] = vec.as_slice(); //~ ERROR does not live long enough let slice = match vec { - [_, ..slice, _] => slice, + [_, slice.., _] => slice, _ => fail!("c") }; slice diff --git a/src/test/compile-fail/borrowck-vec-pattern-loan-from-mut.rs b/src/test/compile-fail/borrowck-vec-pattern-loan-from-mut.rs index 393ec8b0b1b..cc1dbc81955 100644 --- a/src/test/compile-fail/borrowck-vec-pattern-loan-from-mut.rs +++ b/src/test/compile-fail/borrowck-vec-pattern-loan-from-mut.rs @@ -12,7 +12,7 @@ fn a() { let mut v = vec!(1, 2, 3); let vb: &mut [int] = v.as_mut_slice(); match vb { - [_a, ..tail] => { + [_a, tail..] => { v.push(tail[0] + tail[1]); //~ ERROR cannot borrow } _ => {} diff --git a/src/test/compile-fail/borrowck-vec-pattern-move-tail.rs b/src/test/compile-fail/borrowck-vec-pattern-move-tail.rs index 7b092d16eec..cb8762f44fb 100644 --- a/src/test/compile-fail/borrowck-vec-pattern-move-tail.rs +++ b/src/test/compile-fail/borrowck-vec-pattern-move-tail.rs @@ -11,7 +11,7 @@ fn main() { let mut a = [1i, 2, 3, 4]; let t = match a { - [1, 2, ..tail] => tail, + [1, 2, tail..] => tail, _ => unreachable!() }; a[0] = 0; //~ ERROR cannot assign to `a[..]` because it is borrowed diff --git a/src/test/compile-fail/borrowck-vec-pattern-nesting.rs b/src/test/compile-fail/borrowck-vec-pattern-nesting.rs index 4a56f982106..2eec7887856 100644 --- a/src/test/compile-fail/borrowck-vec-pattern-nesting.rs +++ b/src/test/compile-fail/borrowck-vec-pattern-nesting.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(advanced_slice_patterns)] fn a() { let mut vec = [box 1i, box 2, box 3]; @@ -22,7 +23,7 @@ fn b() { let mut vec = vec!(box 1i, box 2, box 3); let vec: &mut [Box<int>] = vec.as_mut_slice(); match vec { - [.._b] => { + [_b..] => { vec[0] = box 4; //~ ERROR cannot assign } } @@ -33,7 +34,7 @@ fn c() { let vec: &mut [Box<int>] = vec.as_mut_slice(); match vec { [_a, //~ ERROR cannot move out - .._b] => { //~^ NOTE attempting to move value to here + _b..] => { //~^ NOTE attempting to move value to here // Note: `_a` is *moved* here, but `b` is borrowing, // hence illegal. @@ -50,7 +51,7 @@ fn d() { let mut vec = vec!(box 1i, box 2, box 3); let vec: &mut [Box<int>] = vec.as_mut_slice(); match vec { - [.._a, //~ ERROR cannot move out + [_a.., //~ ERROR cannot move out _b] => {} //~ NOTE attempting to move value to here _ => {} } diff --git a/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs b/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs index 57a276bec81..2c9cf7d1b65 100644 --- a/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs +++ b/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs @@ -12,7 +12,7 @@ fn a<'a>() -> &'a int { let vec = vec!(1, 2, 3, 4); let vec: &[int] = vec.as_slice(); //~ ERROR `vec` does not live long enough let tail = match vec { - [_a, ..tail] => &tail[0], + [_a, tail..] => &tail[0], _ => fail!("foo") }; tail diff --git a/src/test/compile-fail/feature-gate-advanced-slice-features.rs b/src/test/compile-fail/feature-gate-advanced-slice-features.rs new file mode 100644 index 00000000000..97d593d310e --- /dev/null +++ b/src/test/compile-fail/feature-gate-advanced-slice-features.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let x = [ 1i, 2, 3, 4, 5 ]; + match x { + [ xs.., 4, 5 ] => {} //~ ERROR multiple-element slice matches + [ 1, xs.., 5 ] => {} //~ ERROR multiple-element slice matches + [ 1, 2, xs.. ] => {} // OK without feature gate + } +} + diff --git a/src/test/compile-fail/generic-lifetime-trait-impl.rs b/src/test/compile-fail/generic-lifetime-trait-impl.rs new file mode 100644 index 00000000000..8b52324848b --- /dev/null +++ b/src/test/compile-fail/generic-lifetime-trait-impl.rs @@ -0,0 +1,30 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This code used to produce an ICE on the definition of trait Bar +// with the following message: +// +// Type parameter out of range when substituting in region 'a (root +// type=fn(Self) -> 'astr) (space=FnSpace, index=0) +// +// Regression test for issue #16218. + +trait Bar<'a> {} + +trait Foo<'a> { + fn bar<'a, T: Bar<'a>>(self) -> &'a str; +} + +impl<'a> Foo<'a> for &'a str { + fn bar<T: Bar<'a>>(self) -> &'a str { fail!() } //~ ERROR lifetime +} + +fn main() { +} diff --git a/src/test/compile-fail/issue-12369.rs b/src/test/compile-fail/issue-12369.rs index 7d800899e52..4522b536ffd 100644 --- a/src/test/compile-fail/issue-12369.rs +++ b/src/test/compile-fail/issue-12369.rs @@ -13,7 +13,7 @@ fn main() { let v: int = match sl.as_slice() { [] => 0, [a,b,c] => 3, - [a, ..rest] => a, - [10,a, ..rest] => 10 //~ ERROR: unreachable pattern + [a, rest..] => a, + [10,a, rest..] => 10 //~ ERROR: unreachable pattern }; } diff --git a/src/test/compile-fail/issue-12567.rs b/src/test/compile-fail/issue-12567.rs index d5a8339ba19..26866cbbc60 100644 --- a/src/test/compile-fail/issue-12567.rs +++ b/src/test/compile-fail/issue-12567.rs @@ -11,10 +11,10 @@ fn match_vecs<'a, T>(l1: &'a [T], l2: &'a [T]) { match (l1, l2) { ([], []) => println!("both empty"), - ([], [hd, ..tl]) | ([hd, ..tl], []) => println!("one empty"), + ([], [hd, tl..]) | ([hd, tl..], []) => println!("one empty"), //~^ ERROR: cannot move out of dereference //~^^ ERROR: cannot move out of dereference - ([hd1, ..tl1], [hd2, ..tl2]) => println!("both nonempty"), + ([hd1, tl1..], [hd2, tl2..]) => println!("both nonempty"), //~^ ERROR: cannot move out of dereference //~^^ ERROR: cannot move out of dereference } diff --git a/src/test/compile-fail/lint-type-overflow.rs b/src/test/compile-fail/lint-type-overflow.rs index c8179c3adb0..81b186a2998 100644 --- a/src/test/compile-fail/lint-type-overflow.rs +++ b/src/test/compile-fail/lint-type-overflow.rs @@ -49,6 +49,7 @@ fn main() { let x = -2147483649_i32; //~ error: literal out of range for its type let x = 9223372036854775808_i64; //~ error: literal out of range for its type + let x = -9223372036854775808_i64; // should be OK let x = 18446744073709551615_i64; //~ error: literal out of range for its type let x = -3.40282348e+38_f32; //~ error: literal out of range for its type diff --git a/src/test/compile-fail/match-vec-invalid.rs b/src/test/compile-fail/match-vec-invalid.rs index 389e26aa400..51e83c14aa0 100644 --- a/src/test/compile-fail/match-vec-invalid.rs +++ b/src/test/compile-fail/match-vec-invalid.rs @@ -11,7 +11,7 @@ fn main() { let a = Vec::new(); match a { - [1, ..tail, ..tail] => {}, //~ ERROR: unexpected token: `..` + [1, tail.., tail..] => {}, //~ ERROR: expected `,`, found `..` _ => () } } diff --git a/src/test/compile-fail/match-vec-unreachable.rs b/src/test/compile-fail/match-vec-unreachable.rs index a94b0709646..a85ce660e8b 100644 --- a/src/test/compile-fail/match-vec-unreachable.rs +++ b/src/test/compile-fail/match-vec-unreachable.rs @@ -31,7 +31,7 @@ fn main() { let x: Vec<char> = vec!('a', 'b', 'c'); let x: &[char] = x.as_slice(); match x { - ['a', 'b', 'c', .._tail] => {} + ['a', 'b', 'c', _tail..] => {} ['a', 'b', 'c'] => {} //~ ERROR unreachable pattern _ => {} } diff --git a/src/test/compile-fail/non-exhaustive-match.rs b/src/test/compile-fail/non-exhaustive-match.rs index 4de4af87712..ae5f40d4874 100644 --- a/src/test/compile-fail/non-exhaustive-match.rs +++ b/src/test/compile-fail/non-exhaustive-match.rs @@ -38,14 +38,14 @@ fn main() { let vec = vec!(Some(42i), None, Some(21i)); let vec: &[Option<int>] = vec.as_slice(); match vec { //~ ERROR non-exhaustive patterns: `[]` not covered - [Some(..), None, ..tail] => {} - [Some(..), Some(..), ..tail] => {} + [Some(..), None, tail..] => {} + [Some(..), Some(..), tail..] => {} [None] => {} } let vec = vec!(1i); let vec: &[int] = vec.as_slice(); match vec { - [_, ..tail] => (), + [_, tail..] => (), [] => () } let vec = vec!(0.5f32); @@ -59,10 +59,10 @@ fn main() { let vec = vec!(Some(42i), None, Some(21i)); let vec: &[Option<int>] = vec.as_slice(); match vec { - [Some(..), None, ..tail] => {} - [Some(..), Some(..), ..tail] => {} - [None, None, ..tail] => {} - [None, Some(..), ..tail] => {} + [Some(..), None, tail..] => {} + [Some(..), Some(..), tail..] => {} + [None, None, tail..] => {} + [None, Some(..), tail..] => {} [Some(_)] => {} [None] => {} [] => {} diff --git a/src/test/compile-fail/non-exhaustive-pattern-witness.rs b/src/test/compile-fail/non-exhaustive-pattern-witness.rs index 6dc5ad8b606..b7ff3a18fcf 100644 --- a/src/test/compile-fail/non-exhaustive-pattern-witness.rs +++ b/src/test/compile-fail/non-exhaustive-pattern-witness.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(struct_variant)] +#![feature(advanced_slice_patterns, struct_variant)] struct Foo { first: bool, @@ -63,7 +63,7 @@ fn vectors_with_nested_enums() { [Second(true), First] => (), [Second(true), Second(true)] => (), [Second(false), _] => (), - [_, _, ..tail, _] => () + [_, _, tail.., _] => () } } diff --git a/src/test/compile-fail/unsized3.rs b/src/test/compile-fail/unsized3.rs index cf42e79b394..f71afeb1b30 100644 --- a/src/test/compile-fail/unsized3.rs +++ b/src/test/compile-fail/unsized3.rs @@ -57,20 +57,18 @@ fn f9<Sized? X>(x1: Box<S<X>>, x2: Box<E<X>>) { //~^ ERROR instantiating a type parameter with an incompatible type } -// I would like these to fail eventually. -/* // impl - bounded trait T1<Z: T> { } struct S3<Sized? Y>; -impl<Sized? X: T> T1<X> for S3<X> { //ERROR instantiating a type parameter with an incompatible type +impl<Sized? X: T> T1<X> for S3<X> { //~ ERROR instantiating a type parameter with an incompatible } // impl - unbounded trait T2<Z> { } -impl<Sized? X> T2<X> for S3<X> { //ERROR instantiating a type parameter with an incompatible type `X -*/ +impl<Sized? X> T2<X> for S3<X> { //~ ERROR instantiating a type parameter with an incompatible type +} // impl - struct trait T3<Sized? Z> { diff --git a/src/test/compile-fail/vec-matching-obsolete-syntax.rs b/src/test/compile-fail/vec-matching-obsolete-syntax.rs new file mode 100644 index 00000000000..6330aac2d8b --- /dev/null +++ b/src/test/compile-fail/vec-matching-obsolete-syntax.rs @@ -0,0 +1,22 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let x = [1i, 2, 3]; + match x { + [a, b, ..c] => { //~ ERROR obsolete syntax + assert_eq!(a, 1); + assert_eq!(b, 2); + let expected: &[_] = &[3]; + assert_eq!(c, expected); + } + } +} + diff --git a/src/test/run-pass-fulldeps/issue-16992.rs b/src/test/run-pass-fulldeps/issue-16992.rs new file mode 100644 index 00000000000..563b8394963 --- /dev/null +++ b/src/test/run-pass-fulldeps/issue-16992.rs @@ -0,0 +1,26 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-pretty +// ignore-android + +#![feature(quote)] + +extern crate syntax; + +use syntax::ext::base::ExtCtxt; + +#[allow(dead_code)] +fn foobar(cx: &mut ExtCtxt) { + quote_expr!(cx, 1i); + quote_expr!(cx, 2i); +} + +fn main() { } diff --git a/src/test/run-pass/borrowck-trait-lifetime.rs b/src/test/run-pass/borrowck-trait-lifetime.rs new file mode 100644 index 00000000000..b39f03a93c9 --- /dev/null +++ b/src/test/run-pass/borrowck-trait-lifetime.rs @@ -0,0 +1,21 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This test verifies that casting from the same lifetime on a value +// to the same lifetime on a trait succeeds. See issue #10766. + +#![allow(dead_code)] +fn main() { + trait T {} + + fn f<'a, V: T>(v: &'a V) -> &'a T { + v as &'a T + } +} diff --git a/src/test/run-pass/for-loop-does-not-borrow-iterators.rs b/src/test/run-pass/for-loop-does-not-borrow-iterators.rs deleted file mode 100644 index 206ab0dfeb2..00000000000 --- a/src/test/run-pass/for-loop-does-not-borrow-iterators.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -// The `for` loop use to keep a mutable borrow when executing its body, -// making it impossible to re-use the iterator as follows. -// https://github.com/rust-lang/rust/issues/8372 -// -// This was fixed in https://github.com/rust-lang/rust/pull/15809 - -pub fn main() { - let mut for_loop_values = Vec::new(); - let mut explicit_next_call_values = Vec::new(); - - let mut iter = range(1i, 10); - for i in iter { - for_loop_values.push(i); - explicit_next_call_values.push(iter.next()); - } - - assert_eq!(for_loop_values, vec![1, 3, 5, 7, 9]); - assert_eq!(explicit_next_call_values, vec![Some(2), Some(4), Some(6), Some(8), None]); -} diff --git a/src/test/run-pass/ignore-all-the-things.rs b/src/test/run-pass/ignore-all-the-things.rs index 27c63d425bf..1c87b6dad89 100644 --- a/src/test/run-pass/ignore-all-the-things.rs +++ b/src/test/run-pass/ignore-all-the-things.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(advanced_slice_patterns)] + struct Foo(int, int, int, int); struct Bar{a: int, b: int, c: int, d: int} diff --git a/src/test/run-pass/issue-15080.rs b/src/test/run-pass/issue-15080.rs index 444e8bd3770..1709321a71c 100644 --- a/src/test/run-pass/issue-15080.rs +++ b/src/test/run-pass/issue-15080.rs @@ -14,11 +14,11 @@ fn main() { let mut result = vec!(); loop { x = match x { - [1, n, 3, ..rest] => { + [1, n, 3, rest..] => { result.push(n); rest } - [n, ..rest] => { + [n, rest..] => { result.push(n); rest } diff --git a/src/test/run-pass/issue-15104.rs b/src/test/run-pass/issue-15104.rs index d2711339ccb..c6c9e800455 100644 --- a/src/test/run-pass/issue-15104.rs +++ b/src/test/run-pass/issue-15104.rs @@ -16,6 +16,6 @@ fn count_members(v: &[uint]) -> uint { match v { [] => 0, [_] => 1, - [_x, ..xs] => 1 + count_members(xs) + [_x, xs..] => 1 + count_members(xs) } } diff --git a/src/test/run-pass/issue-17074.rs b/src/test/run-pass/issue-17074.rs new file mode 100644 index 00000000000..e346148691d --- /dev/null +++ b/src/test/run-pass/issue-17074.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +static X: u64 = -1 as u16 as u64; +static Y: u64 = -1 as u32 as u64; + +fn main() { + assert_eq!(match 1 { + X => unreachable!(), + Y => unreachable!(), + _ => 1i + }, 1); +} diff --git a/src/test/run-pass/issue-7784.rs b/src/test/run-pass/issue-7784.rs index d307a057038..666847517ef 100644 --- a/src/test/run-pass/issue-7784.rs +++ b/src/test/run-pass/issue-7784.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(advanced_slice_patterns)] + fn foo<T: Add<T, T> + Clone>([x, y, z]: [T, ..3]) -> (T, T, T) { (x.clone(), x.clone() + y.clone(), x + y + z) } @@ -29,7 +31,7 @@ fn main() { assert_eq!(d, "baz"); let out = bar("baz", "foo"); - let [a, ..xs, d] = out; + let [a, xs.., d] = out; assert_eq!(a, "baz"); assert!(xs == ["foo", "foo"]); assert_eq!(d, "baz"); diff --git a/src/test/run-pass/match-vec-alternatives.rs b/src/test/run-pass/match-vec-alternatives.rs index de1bb02bfef..ae4fd1f1993 100644 --- a/src/test/run-pass/match-vec-alternatives.rs +++ b/src/test/run-pass/match-vec-alternatives.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(advanced_slice_patterns)] + fn match_vecs<'a, T>(l1: &'a [T], l2: &'a [T]) -> &'static str { match (l1, l2) { ([], []) => "both empty", diff --git a/src/test/run-pass/unboxed-closures-unique-type-id.rs b/src/test/run-pass/unboxed-closures-unique-type-id.rs new file mode 100644 index 00000000000..55d89d4e4f6 --- /dev/null +++ b/src/test/run-pass/unboxed-closures-unique-type-id.rs @@ -0,0 +1,34 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +// This code used to produce the following ICE: +// +// error: internal compiler error: get_unique_type_id_of_type() - +// unexpected type: closure, +// ty_unboxed_closure(syntax::ast::DefId{krate: 0u32, node: 66u32}, +// ReScope(63u32)) +// +// This is a regression test for issue #17021. + +#![feature(unboxed_closures, overloaded_calls)] + +use std::ptr; + +pub fn replace_map<'a, T, F>(src: &mut T, prod: F) +where F: |: T| -> T { + unsafe { *src = prod(ptr::read(src as *mut T as *const T)); } +} + +pub fn main() { + let mut a = 7u; + let b = &mut a; + replace_map(b, |: x: uint| x * 2); + assert_eq!(*b, 14u); +} diff --git a/src/test/run-pass/unsized.rs b/src/test/run-pass/unsized.rs index 0530c8a6ab3..141d6c88dd9 100644 --- a/src/test/run-pass/unsized.rs +++ b/src/test/run-pass/unsized.rs @@ -24,6 +24,7 @@ struct S1<Sized? X>; enum E<Sized? X> {} impl <Sized? X> T1 for S1<X> {} fn f<Sized? X>() {} +type TT<Sized? T> = T; pub fn main() { } diff --git a/src/test/run-pass/vec-matching-fixed.rs b/src/test/run-pass/vec-matching-fixed.rs index 3e9d4b9fc3a..a1a14823ff5 100644 --- a/src/test/run-pass/vec-matching-fixed.rs +++ b/src/test/run-pass/vec-matching-fixed.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(advanced_slice_patterns)] + fn a() { let x = [1i, 2, 3]; match x { diff --git a/src/test/run-pass/vec-matching-fold.rs b/src/test/run-pass/vec-matching-fold.rs index 07ee5f535e9..63914a8df31 100644 --- a/src/test/run-pass/vec-matching-fold.rs +++ b/src/test/run-pass/vec-matching-fold.rs @@ -8,12 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(advanced_slice_patterns)] + fn foldl<T,U:Clone>(values: &[T], initial: U, function: |partial: U, element: &T| -> U) -> U { match values { - [ref head, ..tail] => + [ref head, tail..] => foldl(tail, function(initial, head), function), [] => initial.clone() } @@ -24,7 +26,7 @@ fn foldr<T,U:Clone>(values: &[T], function: |element: &T, partial: U| -> U) -> U { match values { - [..head, ref tail] => + [head.., ref tail] => foldr(head, function(tail, initial), function), [] => initial.clone() } diff --git a/src/test/run-pass/vec-matching-legal-tail-element-borrow.rs b/src/test/run-pass/vec-matching-legal-tail-element-borrow.rs index 2fd8a4ab256..a140399447b 100644 --- a/src/test/run-pass/vec-matching-legal-tail-element-borrow.rs +++ b/src/test/run-pass/vec-matching-legal-tail-element-borrow.rs @@ -13,7 +13,7 @@ pub fn main() { let x: &[int] = &[1, 2, 3, 4, 5]; if !x.is_empty() { let el = match x { - [1, ..ref tail] => &tail[0], + [1, ref tail..] => &tail[0], _ => unreachable!() }; println!("{}", *el); diff --git a/src/test/run-pass/vec-matching.rs b/src/test/run-pass/vec-matching.rs index e95495a42d2..187d97f483d 100644 --- a/src/test/run-pass/vec-matching.rs +++ b/src/test/run-pass/vec-matching.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(advanced_slice_patterns)] + fn a() { let x = [1i]; match x { @@ -20,7 +22,7 @@ fn a() { fn b() { let x = [1i, 2, 3]; match x { - [a, b, ..c] => { + [a, b, c..] => { assert_eq!(a, 1); assert_eq!(b, 2); let expected: &[_] = &[3]; @@ -28,7 +30,7 @@ fn b() { } } match x { - [..a, b, c] => { + [a.., b, c] => { let expected: &[_] = &[1]; assert_eq!(a, expected); assert_eq!(b, 2); @@ -36,7 +38,7 @@ fn b() { } } match x { - [a, ..b, c] => { + [a, b.., c] => { assert_eq!(a, 1); let expected: &[_] = &[2]; assert_eq!(b, expected); diff --git a/src/test/run-pass/vec-tail-matching.rs b/src/test/run-pass/vec-tail-matching.rs index e58aebcddfe..a1a222549a0 100644 --- a/src/test/run-pass/vec-tail-matching.rs +++ b/src/test/run-pass/vec-tail-matching.rs @@ -20,14 +20,14 @@ pub fn main() { Foo { string: "baz".to_string() } ]; match x { - [ref first, ..tail] => { + [ref first, tail..] => { assert!(first.string == "foo".to_string()); assert_eq!(tail.len(), 2); assert!(tail[0].string == "bar".to_string()); assert!(tail[1].string == "baz".to_string()); match tail { - [Foo { .. }, _, Foo { .. }, .. _tail] => { + [Foo { .. }, _, Foo { .. }, _tail..] => { unreachable!(); } [Foo { string: ref a }, Foo { string: ref b }] => { |
