auto merge of #10709 : alexcrichton/rust/snapshot, r=pcwalton

This commit is contained in:
bors 2013-11-28 20:31:39 -08:00
commit bf6964ecb6
182 changed files with 1287 additions and 1334 deletions

View file

@ -1,6 +1,6 @@
fn main() {
match ~"foo" {
['f', 'o', .._] => { } //~ ERROR mismatched types: expected `~str` but found a vector pattern
['f', 'o', ..] => { } //~ ERROR mismatched types: expected `~str` but found a vector pattern
_ => { }
}
}

View file

@ -7,7 +7,7 @@ fn main() {
}
match ~[~"foo", ~"bar", ~"baz"] {
[a, _, _, .._] => { println(a); }
[a, _, _, ..] => { println(a); }
[~"foo", ~"bar", ~"baz", ~"foo", ~"bar"] => { } //~ ERROR unreachable pattern
_ => { }
}

View file

@ -36,8 +36,8 @@ fn main() {
(b, b) => {}
}
match ~[Some(42), None, Some(21)] { //~ ERROR non-exhaustive patterns: vectors of length 0 not covered
[Some(*), None, ..tail] => {}
[Some(*), Some(*), ..tail] => {}
[Some(..), None, ..tail] => {}
[Some(..), Some(..), ..tail] => {}
[None] => {}
}
match ~[1] {
@ -51,10 +51,10 @@ fn main() {
[] => ()
}
match ~[Some(42), None, Some(21)] {
[Some(*), None, ..tail] => {}
[Some(*), Some(*), ..tail] => {}
[Some(..), None, ..tail] => {}
[Some(..), Some(..), ..tail] => {}
[None, None, ..tail] => {}
[None, Some(*), ..tail] => {}
[None, Some(..), ..tail] => {}
[Some(_)] => {}
[None] => {}
[] => {}

View file

@ -29,7 +29,7 @@ fn main() {
_ => ()
}
match 'c' {
S { _ } => (), //~ ERROR mismatched types: expected `char` but found a structure pattern
S { .. } => (), //~ ERROR mismatched types: expected `char` but found a structure pattern
_ => ()
}

View file

@ -221,7 +221,7 @@ fn ignored_tuple_element((m, _, n): (int, u16, i32)) {
zzz();
}
fn ignored_struct_field(Struct { b: o, _ }: Struct) {
fn ignored_struct_field(Struct { b: o, .. }: Struct) {
zzz();
}
@ -262,7 +262,7 @@ fn ref_binding_in_tuple((ref ff, gg): (int, (int, int))) {
zzz();
}
fn ref_binding_in_struct(Struct { b: ref hh, _ }: Struct) {
fn ref_binding_in_struct(Struct { b: ref hh, .. }: Struct) {
zzz();
}

View file

@ -157,7 +157,7 @@ fn main() {
let (m, _, n) = (14, 15, 16);
// ignored struct field
let Struct { b: o, _ } = Struct { a: 17, b: 18 };
let Struct { b: o, .. } = Struct { a: 17, b: 18 };
// one struct destructured, one not
let (Struct { a: p, b: q }, r) = (Struct { a: 19, b: 20 }, Struct { a: 21, b: 22 });
@ -188,7 +188,7 @@ fn main() {
let (ref ff, gg) = (46, (47, 48));
// ref binding in struct
let Struct { b: ref hh, _ } = Struct { a: 49, b: 50 };
let Struct { b: ref hh, .. } = Struct { a: 49, b: 50 };
// univariant enum
let Unit(ii) = Unit(51);

View file

@ -116,7 +116,7 @@ fn main() {
match Struct { x: 239, y: 240 } {
// ignored field
Struct { x: shadowed, _ } => {
Struct { x: shadowed, .. } => {
zzz();
sentinel();

View file

@ -15,7 +15,7 @@ impl E {
pub fn method(&self) {
match *self {
V => {}
VV(*) => fail!()
VV(..) => fail!()
}
}
}

View file

@ -14,7 +14,7 @@ static C: E = V;
fn f(a: &E) {
match *a {
V => {}
VV(*) => fail!()
VV(..) => fail!()
}
}

View file

@ -19,7 +19,7 @@ static C: E = S1 { u: 23 };
pub fn main() {
match C {
S0 { _ } => fail!(),
S0 { .. } => fail!(),
S1 { u } => assert!(u == 23)
}
}

View file

@ -58,13 +58,13 @@ fn test_destroy_actually_kills(force: bool) {
#[cfg(unix,not(target_os="android"))]
fn process_exists(pid: libc::pid_t) -> bool {
let run::ProcessOutput {output, _} = run::process_output("ps", [~"-p", pid.to_str()]);
let run::ProcessOutput {output, ..} = run::process_output("ps", [~"-p", pid.to_str()]);
str::from_utf8(output).contains(pid.to_str())
}
#[cfg(unix,target_os="android")]
fn process_exists(pid: libc::pid_t) -> bool {
let run::ProcessOutput {output, _} = run::process_output("/system/bin/ps", [pid.to_str()]);
let run::ProcessOutput {output, ..} = run::process_output("/system/bin/ps", [pid.to_str()]);
str::from_utf8(output).contains(~"root")
}

View file

@ -6,7 +6,7 @@ struct Foo {
y: ~uint,
}
fn foo(Foo {x, _}: Foo) -> *uint {
fn foo(Foo {x, ..}: Foo) -> *uint {
let addr: *uint = &*x;
addr
}

View file

@ -13,16 +13,14 @@ struct Bar{a: int, b: int, c: int, d: int}
pub fn main() {
let Foo(..) = Foo(5, 5, 5, 5);
let Foo(*) = Foo(5, 5, 5, 5);
let Foo(..) = Foo(5, 5, 5, 5);
let Bar{..} = Bar{a: 5, b: 5, c: 5, d: 5};
let Bar{_} = Bar{a: 5, b: 5, c: 5, d: 5};
//let (..) = (5, 5, 5, 5);
//let Foo(a, b, ..) = Foo(5, 5, 5, 5);
//let Foo(.., d) = Foo(5, 5, 5, 5);
//let (a, b, ..) = (5, 5, 5, 5);
//let (.., c, d) = (5, 5, 5, 5);
let Bar{b: b, ..} = Bar{a: 5, b: 5, c: 5, d: 5};
let Bar{b: b, _} = Bar{a: 5, b: 5, c: 5, d: 5};
match [5, 5, 5, 5] {
[..] => { }
}
@ -36,15 +34,15 @@ pub fn main() {
[a, .., b] => { }
}
match [5, 5, 5] {
[.._] => { }
[..] => { }
}
match [5, 5, 5] {
[a, .._] => { }
[a, ..] => { }
}
match [5, 5, 5] {
[.._, a] => { }
[.., a] => { }
}
match [5, 5, 5] {
[a, .._, b] => { }
[a, .., b] => { }
}
}

View file

@ -16,10 +16,10 @@ enum animal { cat(pattern), dog(breed), rabbit(name, ear_kind), tiger }
fn noise(a: animal) -> Option<~str> {
match a {
cat(*) => { Some(~"meow") }
dog(*) => { Some(~"woof") }
rabbit(*) => { None }
tiger(*) => { Some(~"roar") }
cat(..) => { Some(~"meow") }
dog(..) => { Some(~"woof") }
rabbit(..) => { None }
tiger(..) => { Some(~"roar") }
}
}

View file

@ -14,7 +14,7 @@ pub struct Foo<T> {
data: T,
}
fn foo<T>(Foo{_}: Foo<T>) {
fn foo<T>(Foo{..}: Foo<T>) {
}
pub fn main() {

View file

@ -19,7 +19,7 @@ pub fn main() {
let e = Foo{f: 0};
match e {
Foo{f: 1} => fail!(),
Foo{_} => (),
Foo{..} => (),
_ => fail!(),
}
}

View file

@ -18,7 +18,7 @@ enum E {
pub fn main() {
let e = Foo{f: 1};
match e {
Foo{_} => (),
Foo{..} => (),
_ => fail!(),
}
match e {

View file

@ -16,7 +16,7 @@ pub fn main() {
let f = Foo{f: 1};
match f {
Foo{f: 0} => fail!(),
Foo{_} => (),
Foo{..} => (),
}
match f {
Foo{f: 0} => fail!(),

View file

@ -12,9 +12,9 @@ struct Foo { foo: bool, bar: Option<int>, baz: int }
pub fn main() {
match @Foo{foo: true, bar: Some(10), baz: 20} {
@Foo{foo: true, bar: Some(_), _} => {}
@Foo{foo: false, bar: None, _} => {}
@Foo{foo: true, bar: None, _} => {}
@Foo{foo: false, bar: Some(_), _} => {}
@Foo{foo: true, bar: Some(_), ..} => {}
@Foo{foo: false, bar: None, ..} => {}
@Foo{foo: true, bar: None, ..} => {}
@Foo{foo: false, bar: Some(_), ..} => {}
}
}

View file

@ -18,12 +18,12 @@ struct C { c: int }
pub fn main() {
match A {a: 10, b: @20} {
x@A {a, b: @20} => { assert!(x.a == 10); assert!(a == 10); }
A {b: _b, _} => { fail!(); }
A {b: _b, ..} => { fail!(); }
}
let mut x@B {b, _} = B {a: 10, b: C {c: 20}};
let mut x@B {b, ..} = B {a: 10, b: C {c: 20}};
x.b.c = 30;
assert_eq!(b.c, 20);
let mut y@D {d, _} = D {a: 10, d: C {c: 20}};
let mut y@D {d, ..} = D {a: 10, d: C {c: 20}};
y.d.c = 30;
assert_eq!(d.c, 20);
}

View file

@ -26,13 +26,13 @@ enum E<T> { Thing(int, T), Nothing((), ((), ()), [i8, ..0]) }
impl<T> E<T> {
fn is_none(&self) -> bool {
match *self {
Thing(*) => false,
Nothing(*) => true
Thing(..) => false,
Nothing(..) => true
}
}
fn get_ref<'r>(&'r self) -> (int, &'r T) {
match *self {
Nothing(*) => fail!("E::get_ref(Nothing::<%s>)", stringify!($T)),
Nothing(..) => fail!("E::get_ref(Nothing::<%s>)", stringify!($T)),
Thing(x, ref y) => (x, y)
}
}

View file

@ -14,7 +14,7 @@ enum t3 { c(T2, uint), }
fn m(input: t3) -> int {
match input {
c(T2 {x: a(m), _}, _) => { return m; }
c(T2 {x: a(m), ..}, _) => { return m; }
c(T2 {x: b(m), y: y}, z) => { return ((m + z) as int) + y; }
}
}

View file

@ -63,21 +63,21 @@ fn get_v6_a<'v>(a: &'v A, _i: uint) -> &'v int {
fn get_v6_b<'v>(a: &'v A, _i: uint) -> &'v int {
match *a {
A { value: B { v6: Some(ref v), _ } } => &v.f,
A { value: B { v6: Some(ref v), .. } } => &v.f,
_ => fail!()
}
}
fn get_v6_c<'v>(a: &'v A, _i: uint) -> &'v int {
match a {
&A { value: B { v6: Some(ref v), _ } } => &v.f,
&A { value: B { v6: Some(ref v), .. } } => &v.f,
_ => fail!()
}
}
fn get_v5_ref<'v>(a: &'v A, _i: uint) -> &'v int {
match &a.value {
&B {v5: ~C {f: ref v}, _} => v
&B {v5: ~C {f: ref v}, ..} => v
}
}

View file

@ -59,8 +59,8 @@ fn smoke_failure() {
io: io,
};
match io::result(|| Process::new(args)) {
Ok(*) => fail!(),
Err(*) => {}
Ok(..) => fail!(),
Err(..) => {}
}
}

View file

@ -22,7 +22,7 @@ impl Eq for colour {
}
green => {
match (*other) {
red(*) => false,
red(..) => false,
green => true
}
}

View file

@ -1,7 +1,7 @@
pub fn main() {
let x = @[1, 2, 3];
match x {
[2, .._] => fail!(),
[2, ..] => fail!(),
[1, ..tail] => {
assert_eq!(tail, [2, 3]);
}

View file

@ -2,17 +2,17 @@ fn a() {
let x = [1, 2, 3];
match x {
[1, 2, 4] => unreachable!(),
[0, 2, 3, .._] => unreachable!(),
[0, .._, 3] => unreachable!(),
[0, .._] => unreachable!(),
[0, 2, 3, ..] => unreachable!(),
[0, .., 3] => unreachable!(),
[0, ..] => unreachable!(),
[1, 2, 3] => (),
[_, _, _] => unreachable!(),
}
match x {
[.._] => (),
[..] => (),
}
match x {
[_, _, _, .._] => (),
[_, _, _, ..] => (),
}
match x {
[a, b, c] => {

View file

@ -1,9 +1,9 @@
fn a() {
let x = ~[1];
match x {
[_, _, _, _, _, .._] => fail!(),
[.._, _, _, _, _] => fail!(),
[_, .._, _, _] => fail!(),
[_, _, _, _, _, ..] => fail!(),
[.., _, _, _, _] => fail!(),
[_, .., _, _] => fail!(),
[_, _] => fail!(),
[a] => {
assert_eq!(a, 1);
@ -51,17 +51,17 @@ fn b() {
fn c() {
let x = [1];
match x {
[2, .. _] => fail!(),
[.. _] => ()
[2, ..] => fail!(),
[..] => ()
}
}
fn d() {
let x = [1, 2, 3];
let branch = match x {
[1, 1, .. _] => 0,
[1, 2, 3, .. _] => 1,
[1, 2, .. _] => 2,
[1, 1, ..] => 0,
[1, 2, 3, ..] => 1,
[1, 2, ..] => 2,
_ => 3
};
assert_eq!(branch, 1);

View file

@ -16,7 +16,7 @@ pub fn main() {
assert!(tail[1].string == ~"baz");
match tail {
[Foo { _ }, _, Foo { _ }, .. _tail] => {
[Foo { .. }, _, Foo { .. }, .. _tail] => {
unreachable!();
}
[Foo { string: ref a }, Foo { string: ref b }] => {