+++ /dev/null
-// 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.
-
-fn main() {
-
- match 0 {
- 0 => {
- } + 5 //~ ERROR unexpected token: `+`
- }
-}
+++ /dev/null
-// 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.
-
-// a good test that we merge paths correctly in the presence of a
-// variable that's used before it's declared
-
-fn my_fail() -> ! { fail!(); }
-
-fn main() {
- match true { false => { my_fail(); } true => { } }
-
- debug!(x); //~ ERROR unresolved name `x`.
- let x: int;
-}
+++ /dev/null
-// 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.
-
-fn main() {
- enum color {
- rgb(uint, uint, uint),
- cmyk(uint, uint, uint, uint),
- no_color,
- }
-
- fn foo(c: color) {
- match c {
- rgb(_, _, _) => { }
- cmyk(_, _, _, _) => { }
- no_color(_) => { }
- //~^ ERROR this pattern has 1 field, but the corresponding variant has no fields
- }
- }
-}
+++ /dev/null
-// 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.
-
-fn main() {
- enum color {
- rgb(uint, uint, uint),
- cmyk(uint, uint, uint, uint),
- no_color,
- }
-
- fn foo(c: color) {
- match c {
- rgb(_, _) => { }
- //~^ ERROR this pattern has 2 fields, but the corresponding variant has 3 fields
- cmyk(_, _, _, _) => { }
- no_color => { }
- }
- }
-}
+++ /dev/null
-// 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.
-
-//error-pattern: unreachable
-//error-pattern: unreachable
-//error-pattern: unreachable
-//error-pattern: unreachable
-//error-pattern: unreachable
-
-fn main() {
- match 5u {
- 1u .. 10u => { }
- 5u .. 6u => { }
- _ => {}
- };
-
- match 5u {
- 3u .. 6u => { }
- 4u .. 6u => { }
- _ => {}
- };
-
- match 5u {
- 4u .. 6u => { }
- 4u .. 6u => { }
- _ => {}
- };
-
- match 'c' {
- 'A' .. 'z' => {}
- 'a' .. 'z' => {}
- _ => {}
- };
-
- match 1.0 {
- 0.01 .. 6.5 => {}
- 0.02 => {}
- _ => {}
- };
-}
+++ /dev/null
-// 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.
-
-//error-pattern: lower range bound
-//error-pattern: non-numeric
-//error-pattern: mismatched types
-
-fn main() {
- match 5u {
- 6u .. 1u => { }
- _ => { }
- };
-
- match "wow" {
- "bar" .. "foo" => { }
- };
-
- match 5u {
- 'c' .. 100u => { }
- _ => { }
- };
-}
+++ /dev/null
-// 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.
-
-// error-pattern: mismatched types
-
-enum a { A, }
-enum b { B, }
-
-fn main() { let x: a = A; match x { B => { } } }
+++ /dev/null
-// 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.
-
-// error-pattern: mismatched types
-
-enum a { A(int), }
-enum b { B(int), }
-
-fn main() { let x: a = A(0); match x { B(y) => { } } }
+++ /dev/null
-fn main() {
- let a = ~[];
- match a {
- [1, ..tail, ..tail] => {}, //~ ERROR: unexpected token: `..`
- _ => ()
- }
-}
+++ /dev/null
-fn main() {
- match () {
- [()] => { } //~ ERROR mismatched types: expected `()` but found a vector pattern
- }
-}
+++ /dev/null
-fn main() {
- match ~"foo" {
- ['f', 'o', .._] => { } //~ ERROR mismatched types: expected `~str` but found a vector pattern
- _ => { }
- }
-}
+++ /dev/null
-fn main() {
- let x: ~[(int, int)] = ~[];
- match x {
- [a, (2, 3), _] => (),
- [(1, 2), (2, 3), b] => (), //~ ERROR unreachable pattern
- _ => ()
- }
-
- match [~"foo", ~"bar", ~"baz"] {
- [a, _, _, .._] => { io::println(a); }
- [~"foo", ~"bar", ~"baz", ~"foo", ~"bar"] => { } //~ ERROR unreachable pattern
- _ => { }
- }
-
- match ['a', 'b', 'c'] {
- ['a', 'b', 'c', .._tail] => {}
- ['a', 'b', 'c'] => {} //~ ERROR unreachable pattern
- _ => {}
- }
-}
+++ /dev/null
-// error-pattern: expected
-
-fn main() {
- let int x = 5;
- match x;
-}
--- /dev/null
+// error-pattern: expected
+
+fn main() {
+ let int x = 5;
+ match x;
+}
--- /dev/null
+// 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.
+
+fn main() {
+
+ match 0 {
+ 0 => {
+ } + 5 //~ ERROR unexpected token: `+`
+ }
+}
--- /dev/null
+// 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.
+
+// a good test that we merge paths correctly in the presence of a
+// variable that's used before it's declared
+
+fn my_fail() -> ! { fail!(); }
+
+fn main() {
+ match true { false => { my_fail(); } true => { } }
+
+ debug!(x); //~ ERROR unresolved name `x`.
+ let x: int;
+}
--- /dev/null
+// 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.
+
+fn main() {
+ enum color {
+ rgb(uint, uint, uint),
+ cmyk(uint, uint, uint, uint),
+ no_color,
+ }
+
+ fn foo(c: color) {
+ match c {
+ rgb(_, _, _) => { }
+ cmyk(_, _, _, _) => { }
+ no_color(_) => { }
+ //~^ ERROR this pattern has 1 field, but the corresponding variant has no fields
+ }
+ }
+}
--- /dev/null
+// 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.
+
+fn main() {
+ enum color {
+ rgb(uint, uint, uint),
+ cmyk(uint, uint, uint, uint),
+ no_color,
+ }
+
+ fn foo(c: color) {
+ match c {
+ rgb(_, _) => { }
+ //~^ ERROR this pattern has 2 fields, but the corresponding variant has 3 fields
+ cmyk(_, _, _, _) => { }
+ no_color => { }
+ }
+ }
+}
--- /dev/null
+// 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.
+
+//error-pattern: unreachable
+//error-pattern: unreachable
+//error-pattern: unreachable
+//error-pattern: unreachable
+//error-pattern: unreachable
+
+fn main() {
+ match 5u {
+ 1u .. 10u => { }
+ 5u .. 6u => { }
+ _ => {}
+ };
+
+ match 5u {
+ 3u .. 6u => { }
+ 4u .. 6u => { }
+ _ => {}
+ };
+
+ match 5u {
+ 4u .. 6u => { }
+ 4u .. 6u => { }
+ _ => {}
+ };
+
+ match 'c' {
+ 'A' .. 'z' => {}
+ 'a' .. 'z' => {}
+ _ => {}
+ };
+
+ match 1.0 {
+ 0.01 .. 6.5 => {}
+ 0.02 => {}
+ _ => {}
+ };
+}
--- /dev/null
+// 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.
+
+//error-pattern: lower range bound
+//error-pattern: non-numeric
+//error-pattern: mismatched types
+
+fn main() {
+ match 5u {
+ 6u .. 1u => { }
+ _ => { }
+ };
+
+ match "wow" {
+ "bar" .. "foo" => { }
+ };
+
+ match 5u {
+ 'c' .. 100u => { }
+ _ => { }
+ };
+}
--- /dev/null
+// 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.
+
+// error-pattern: mismatched types
+
+enum a { A, }
+enum b { B, }
+
+fn main() { let x: a = A; match x { B => { } } }
--- /dev/null
+// 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.
+
+// error-pattern: mismatched types
+
+enum a { A(int), }
+enum b { B(int), }
+
+fn main() { let x: a = A(0); match x { B(y) => { } } }
--- /dev/null
+fn main() {
+ let a = ~[];
+ match a {
+ [1, ..tail, ..tail] => {}, //~ ERROR: unexpected token: `..`
+ _ => ()
+ }
+}
--- /dev/null
+fn main() {
+ match () {
+ [()] => { } //~ ERROR mismatched types: expected `()` but found a vector pattern
+ }
+}
--- /dev/null
+fn main() {
+ match ~"foo" {
+ ['f', 'o', .._] => { } //~ ERROR mismatched types: expected `~str` but found a vector pattern
+ _ => { }
+ }
+}
--- /dev/null
+fn main() {
+ let x: ~[(int, int)] = ~[];
+ match x {
+ [a, (2, 3), _] => (),
+ [(1, 2), (2, 3), b] => (), //~ ERROR unreachable pattern
+ _ => ()
+ }
+
+ match [~"foo", ~"bar", ~"baz"] {
+ [a, _, _, .._] => { io::println(a); }
+ [~"foo", ~"bar", ~"baz", ~"foo", ~"bar"] => { } //~ ERROR unreachable pattern
+ _ => { }
+ }
+
+ match ['a', 'b', 'c'] {
+ ['a', 'b', 'c', .._tail] => {}
+ ['a', 'b', 'c'] => {} //~ ERROR unreachable pattern
+ _ => {}
+ }
+}
+++ /dev/null
-// 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.
-
-// pp-exact
-
-// actually this doesn't quite look how I want it to, but I can't
-// get the prettyprinter to indent the long expr
-
-fn main() {
- let x = Some(3);
- let y =
- match x {
- Some(_) =>
- ~"some" + ~"very" + ~"very" + ~"very" + ~"very" + ~"very" +
- ~"very" + ~"very" + ~"very" + ~"long" + ~"string",
- None => ~"none"
- };
-}
+++ /dev/null
-// 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.
-
-// pp-exact
-
-fn main() {
- let x = Some(3);
- let _y =
- match x {
- Some(_) => ~[~"some(_)", ~"not", ~"SO", ~"long", ~"string"],
- None => ~[~"none"]
- };
-}
+++ /dev/null
-// 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.
-
-// pp-exact
-
-fn main() {
- let x = Some(3);
- let y = match x { Some(_) => ~"some(_)", None => ~"none" };
-}
--- /dev/null
+// 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.
+
+// pp-exact
+
+// actually this doesn't quite look how I want it to, but I can't
+// get the prettyprinter to indent the long expr
+
+fn main() {
+ let x = Some(3);
+ let y =
+ match x {
+ Some(_) =>
+ ~"some" + ~"very" + ~"very" + ~"very" + ~"very" + ~"very" +
+ ~"very" + ~"very" + ~"very" + ~"long" + ~"string",
+ None => ~"none"
+ };
+}
--- /dev/null
+// 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.
+
+// pp-exact
+
+fn main() {
+ let x = Some(3);
+ let _y =
+ match x {
+ Some(_) => ~[~"some(_)", ~"not", ~"SO", ~"long", ~"string"],
+ None => ~[~"none"]
+ };
+}
--- /dev/null
+// 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.
+
+// pp-exact
+
+fn main() {
+ let x = Some(3);
+ let y = match x { Some(_) => ~"some(_)", None => ~"none" };
+}
+++ /dev/null
-// 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.
-
-// error-pattern:explicit failure
-
-fn foo(s: ~str) { }
-
-fn main() {
- let i =
- match Some::<int>(3) { None::<int> => { fail!() } Some::<int>(_) => { fail!() } };
- foo(i);
-}
+++ /dev/null
-// 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.
-
-// error-pattern:quux
-fn f() -> ! { fail!("quux") }
-fn g() -> int { match f() { true => { 1 } false => { 0 } } }
-fn main() { g(); }
+++ /dev/null
-// 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.
-
-// error-pattern:squirrelcupcake
-fn cmp() -> int {
- match (option::Some('a'), option::None::<char>) {
- (option::Some(_), _) => { fail!("squirrelcupcake"); }
- (_, option::Some(_)) => { fail!(); }
- _ => { fail!("wat"); }
- }
-}
-
-fn main() { error!(cmp()); }
+++ /dev/null
-// 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.
-
-
-
-
-// error-pattern:explicit failure
-fn f() -> ! { fail!() }
-
-fn g() -> int { let x = match true { true => { f() } false => { 10 } }; return x; }
-
-fn main() { g(); }
+++ /dev/null
-// 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.
-
-
-
-
-// error-pattern:explicit failure
-fn main() { let x = match true { false => { 0 } true => { fail!() } }; }
--- /dev/null
+// 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.
+
+
+
+
+// error-pattern:explicit failure
+fn f() -> ! { fail!() }
+
+fn g() -> int { let x = match true { true => { f() } false => { 10 } }; return x; }
+
+fn main() { g(); }
--- /dev/null
+// 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.
+
+
+
+
+// error-pattern:explicit failure
+fn main() { let x = match true { false => { 0 } true => { fail!() } }; }
--- /dev/null
+// 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.
+
+// error-pattern:explicit failure
+
+fn foo(s: ~str) { }
+
+fn main() {
+ let i =
+ match Some::<int>(3) { None::<int> => { fail!() } Some::<int>(_) => { fail!() } };
+ foo(i);
+}
--- /dev/null
+// 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.
+
+// error-pattern:quux
+fn f() -> ! { fail!("quux") }
+fn g() -> int { match f() { true => { 1 } false => { 0 } } }
+fn main() { g(); }
--- /dev/null
+// 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.
+
+// error-pattern:squirrelcupcake
+fn cmp() -> int {
+ match (option::Some('a'), option::None::<char>) {
+ (option::Some(_), _) => { fail!("squirrelcupcake"); }
+ (_, option::Some(_)) => { fail!(); }
+ _ => { fail!("wat"); }
+ }
+}
+
+fn main() { error!(cmp()); }
+++ /dev/null
-// 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.
-
-// Issue #945
-// error-pattern:non-exhaustive match failure
-fn test_box() {
- @0;
-}
-fn test_str() {
- let res = match false { true => { ~"happy" },
- _ => fail!("non-exhaustive match failure") };
- assert_eq!(res, ~"happy");
-}
-fn main() {
- test_box();
- test_str();
-}
--- /dev/null
+// 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.
+
+// Issue #945
+// error-pattern:non-exhaustive match failure
+fn test_box() {
+ @0;
+}
+fn test_str() {
+ let res = match false { true => { ~"happy" },
+ _ => fail!("non-exhaustive match failure") };
+ assert_eq!(res, ~"happy");
+}
+fn main() {
+ test_box();
+ test_str();
+}
+++ /dev/null
-// xfail-test
-// xfail-fast
-// -*- rust -*-
-fn f1(ref_string: &str) {
- match ref_string {
- "a" => io::println("found a"),
- "b" => io::println("found b"),
- _ => io::println("not found")
- }
-}
-
-fn f2(ref_string: &str) {
- match ref_string {
- "a" => io::println("found a"),
- "b" => io::println("found b"),
- s => io::println(fmt!("not found (%s)", s))
- }
-}
-
-fn g1(ref_1: &str, ref_2: &str) {
- match (ref_1, ref_2) {
- ("a", "b") => io::println("found a,b"),
- ("b", "c") => io::println("found b,c"),
- _ => io::println("not found")
- }
-}
-
-fn g2(ref_1: &str, ref_2: &str) {
- match (ref_1, ref_2) {
- ("a", "b") => io::println("found a,b"),
- ("b", "c") => io::println("found b,c"),
- (s1, s2) => io::println(fmt!("not found (%s, %s)", s1, s2))
- }
-}
-
-pub fn main() {
- f1(@"a");
- f1(~"b");
- f1(&"c");
- f1("d");
- f2(@"a");
- f2(~"b");
- f2(&"c");
- f2("d");
- g1(@"a", @"b");
- g1(~"b", ~"c");
- g1(&"c", &"d");
- g1("d", "e");
- g2(@"a", @"b");
- g2(~"b", ~"c");
- g2(&"c", &"d");
- g2("d", "e");
-}
+++ /dev/null
-// 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.
-
-// n.b. This was only ever failing with optimization disabled.
-fn a() -> int { match return 1 { 2 => 3, _ => fail!() } }
-pub fn main() { a(); }
+++ /dev/null
-// 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.
-
-
-pub fn main() {
- let i: int =
- match Some::<int>(3) { None::<int> => { fail!() } Some::<int>(_) => { 5 } };
- debug!("%?", i);
-}
+++ /dev/null
-// 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.
-
-struct Pair { a: ~int, b: ~int }
-
-pub fn main() {
- let mut x = ~Pair {a: ~10, b: ~20};
- match x {
- ~Pair {a: ref mut a, b: ref mut b} => {
- assert!(**a == 10); *a = ~30; assert!(**a == 30);
- }
- }
-}
+++ /dev/null
-// 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.
-
-
-extern mod extra;
-
-fn foo<T>(y: Option<T>) {
- let mut x: int;
- let mut rs: ~[int] = ~[];
- /* tests that x doesn't get put in the precondition for the
- entire if expression */
-
- if true {
- } else {
- match y {
- None::<T> => x = 17,
- _ => x = 42
- }
- rs += ~[x];
- }
- return;
-}
-
-pub fn main() { debug!("hello"); foo::<int>(Some::<int>(5)); }
+++ /dev/null
-// 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.
-
-struct X { x: int }
-
-pub fn main() {
- let x = match 0 {
- _ => X {
- x: 0
- }.x
- };
-}
+++ /dev/null
-// 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.
-
-struct X { x: int }
-
-pub fn main() {
- let x = match 0 {
- _ => X {
- x: 0
- }
- };
-}
+++ /dev/null
-// 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.
-
-
-
-mod m1 {
- pub enum foo { foo1, foo2, }
-}
-
-fn bar(x: m1::foo) { match x { m1::foo1 => { } m1::foo2 => { } } }
-
-pub fn main() { }
+++ /dev/null
-// 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.
-
-
-
-// -*- rust -*-
-enum t { make_t(@int), clam, }
-
-fn foo(s: @int) {
- let count = ::std::sys::refcount(s);
- let x: t = make_t(s); // ref up
-
- match x {
- make_t(y) => {
- debug!("%?", y); // ref up then down
-
- }
- _ => { debug!("?"); fail!(); }
- }
- debug!(::std::sys::refcount(s));
- assert_eq!(::std::sys::refcount(s), count + 1u);
- let _ = ::std::sys::refcount(s); // don't get bitten by last-use.
-}
-
-pub fn main() {
- let s: @int = @0; // ref up
-
- let count = ::std::sys::refcount(s);
-
- foo(s); // ref up then down
-
- debug!("%u", ::std::sys::refcount(s));
- let count2 = ::std::sys::refcount(s);
- let _ = ::std::sys::refcount(s); // don't get bitten by last-use.
- assert_eq!(count, count2);
-}
+++ /dev/null
-// 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.
-
-
-
-fn altlit(f: int) -> int {
- match f {
- 10 => { debug!("case 10"); return 20; }
- 11 => { debug!("case 11"); return 22; }
- _ => fail!("the impossible happened")
- }
-}
-
-pub fn main() { assert!((altlit(10) == 20)); assert!((altlit(11) == 22)); }
+++ /dev/null
-// 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.
-
-enum maybe<T> { nothing, just(T), }
-
-fn foo(x: maybe<int>) {
- match x { nothing => { error!("A"); } just(a) => { error!("B"); } }
-}
-
-pub fn main() { }
+++ /dev/null
-// 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.
-
-
-
-fn altsimple(f: int) { match f { x => () } }
-
-pub fn main() { }
+++ /dev/null
-// 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.
-
-
-
-enum thing { a, b, c, }
-
-fn foo(it: &fn(int)) { it(10); }
-
-pub fn main() {
- let mut x = true;
- match a {
- a => { x = true; foo(|_i| { } ) }
- b => { x = false; }
- c => { x = false; }
- }
-}
+++ /dev/null
-// 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.
-
-pub fn main() {
- match 5u {
- 1u..5u => {}
- _ => fail!("should match range"),
- }
- match 5u {
- 6u..7u => fail!("shouldn't match range"),
- _ => {}
- }
- match 5u {
- 1u => fail!("should match non-first range"),
- 2u..6u => {}
- _ => fail!("math is broken")
- }
- match 'c' {
- 'a'..'z' => {}
- _ => fail!("should suppport char ranges")
- }
- match -3 {
- -7..5 => {}
- _ => fail!("should match signed range")
- }
- match 3.0 {
- 1.0..5.0 => {}
- _ => fail!("should match float range")
- }
- match -1.5 {
- -3.6..3.6 => {}
- _ => fail!("should match negative float range")
- }
-}
+++ /dev/null
-// 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.
-
-pub fn main() {
- let x = Some(unstable::sync::exclusive(true));
- match x {
- Some(ref z) if z.with(|b| *b) => {
- do z.with |b| { assert!(*b); }
- },
- _ => fail!()
- }
-}
+++ /dev/null
-// 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.
-
-pub fn main() {
- let mut v = Some(22);
- match v {
- None => {}
- Some(ref mut p) => { *p += 1; }
- }
- assert_eq!(v, Some(23));
-}
+++ /dev/null
-// 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.
-
-struct Rec {
- f: int
-}
-
-fn destructure(x: &mut Rec) {
- match *x {
- Rec {f: ref mut f} => *f += 1
- }
-}
-
-pub fn main() {
- let mut v = Rec {f: 22};
- destructure(&mut v);
- assert_eq!(v.f, 23);
-}
+++ /dev/null
-// 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.
-
-fn destructure(x: Option<int>) -> int {
- match x {
- None => 0,
- Some(ref v) => *v
- }
-}
-
-pub fn main() {
- assert_eq!(destructure(Some(22)), 22);
-}
+++ /dev/null
-// 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.
-
-// Issue #53
-
-pub fn main() {
- match ~"test" { ~"not-test" => fail!(), ~"test" => (), _ => fail!() }
-
- enum t { tag1(~str), tag2, }
-
-
- match tag1(~"test") {
- tag2 => fail!(),
- tag1(~"not-test") => fail!(),
- tag1(~"test") => (),
- _ => fail!()
- }
-
- let x = match ~"a" { ~"a" => 1, ~"b" => 2, _ => fail!() };
- assert_eq!(x, 1);
-
- match ~"a" { ~"a" => { } ~"b" => { }, _ => fail!() }
-
-}
+++ /dev/null
-// 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.
-
-
-
-
-// -*- rust -*-
-enum color {
- rgb(int, int, int),
- rgba(int, int, int, int),
- hsl(int, int, int),
-}
-
-fn process(c: color) -> int {
- let mut x: int;
- match c {
- rgb(r, _, _) => { x = r; }
- rgba(_, _, _, a) => { x = a; }
- hsl(_, s, _) => { x = s; }
- }
- return x;
-}
-
-pub fn main() {
- let gray: color = rgb(127, 127, 127);
- let clear: color = rgba(50, 150, 250, 0);
- let red: color = hsl(0, 255, 255);
- assert_eq!(process(gray), 127);
- assert_eq!(process(clear), 0);
- assert_eq!(process(red), 255);
-}
+++ /dev/null
-// 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.
-
-pub fn main() {
- match ~100 {
- ~x => {
- debug!("%?", x);
- assert_eq!(x, 100);
- }
- }
-}
+++ /dev/null
-// 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.
-
-fn foo(x: Option<~int>, b: bool) -> int {
- match x {
- None => { 1 }
- Some(ref x) if b => { *x.clone() }
- Some(_) => { 0 }
- }
-}
-
-pub fn main() {
- foo(Some(~22), true);
- foo(Some(~22), false);
- foo(None, true);
- foo(None, false);
-}
+++ /dev/null
-// 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.
-
-pub fn main() {
- // sometimes we have had trouble finding
- // the right type for f, as we unified
- // bot and u32 here
- let f = match uint::from_str(~"1234") {
- None => return (),
- Some(num) => num as u32
- };
- assert_eq!(f, 1234u32);
- error!(f)
-}
+++ /dev/null
-// 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.
-
-
-
-
-// -*- rust -*-
-
-// Tests for match as expressions resulting in boxed types
-fn test_box() {
- let res = match true { true => { @100 } _ => fail!("wat") };
- assert_eq!(*res, 100);
-}
-
-fn test_str() {
- let res = match true { true => { ~"happy" },
- _ => fail!("not happy at all") };
- assert_eq!(res, ~"happy");
-}
-
-pub fn main() { test_box(); test_str(); }
+++ /dev/null
-// 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.
-
-
-
-
-// When all branches of an match expression result in fail, the entire
-// match expression results in fail.
-pub fn main() {
- let x =
- match true {
- true => { 10 }
- false => { match true { true => { fail!() } false => { fail!() } } }
- };
-}
+++ /dev/null
-// 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.
-
-fn test_simple() {
- let r = match true { true => { true } false => { fail!() } };
- assert_eq!(r, true);
-}
-
-fn test_box() {
- let r = match true { true => { ~[10] } false => { fail!() } };
- assert_eq!(r[0], 10);
-}
-
-pub fn main() { test_simple(); test_box(); }
+++ /dev/null
-// 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.
-
-
-
-
-// -*- rust -*-
-type compare<T> = @fn(@T, @T) -> bool;
-
-fn test_generic<T>(expected: @T, eq: compare<T>) {
- let actual: @T = match true { true => { expected }, _ => fail!() };
- assert!((eq(expected, actual)));
-}
-
-fn test_box() {
- fn compare_box(b1: @bool, b2: @bool) -> bool { return *b1 == *b2; }
- test_generic::<bool>(@true, compare_box);
-}
-
-pub fn main() { test_box(); }
+++ /dev/null
-// 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.
-
-// xfail-fast
-// -*- rust -*-
-
-type compare<T> = @fn(T, T) -> bool;
-
-fn test_generic<T:Copy>(expected: T, eq: compare<T>) {
- let actual: T = match true { true => { expected }, _ => fail!("wat") };
- assert!((eq(expected, actual)));
-}
-
-fn test_vec() {
- fn compare_box(v1: @int, v2: @int) -> bool { return v1 == v2; }
- test_generic::<@int>(@1, compare_box);
-}
-
-pub fn main() { test_vec(); }
+++ /dev/null
-// 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.
-
-
-
-// -*- rust -*-
-type compare<T> = @fn(~T, ~T) -> bool;
-
-fn test_generic<T:Copy+Clone>(expected: ~T, eq: compare<T>) {
- let actual: ~T = match true {
- true => { expected.clone() },
- _ => fail!("wat")
- };
- assert!((eq(expected, actual)));
-}
-
-fn test_box() {
- fn compare_box(b1: ~bool, b2: ~bool) -> bool { return *b1 == *b2; }
- test_generic::<bool>(~true, compare_box);
-}
-
-pub fn main() { test_box(); }
+++ /dev/null
-// 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.
-
-// xfail-fast
-// -*- rust -*-
-
-type compare<T> = @fn(T, T) -> bool;
-
-fn test_generic<T:Copy+Clone>(expected: T, eq: compare<T>) {
- let actual: T = match true {
- true => expected.clone(),
- _ => fail!("wat")
- };
- assert!((eq(expected, actual)));
-}
-
-fn test_vec() {
- fn compare_box(v1: ~int, v2: ~int) -> bool { return v1 == v2; }
- test_generic::<~int>(~1, compare_box);
-}
-
-pub fn main() { test_vec(); }
+++ /dev/null
-// 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.
-
-// xfail-fast
-// -*- rust -*-
-
-type compare<T> = @fn(T, T) -> bool;
-
-fn test_generic<T:Copy>(expected: T, eq: compare<T>) {
- let actual: T = match true { true => { expected }, _ => fail!("wat") };
- assert!((eq(expected, actual)));
-}
-
-fn test_bool() {
- fn compare_bool(b1: bool, b2: bool) -> bool { return b1 == b2; }
- test_generic::<bool>(true, compare_bool);
-}
-
-struct Pair { a: int, b: int }
-
-fn test_rec() {
- fn compare_rec(t1: Pair, t2: Pair) -> bool {
- t1.a == t2.a && t1.b == t2.b
- }
- test_generic::<Pair>(Pair {a: 1, b: 2}, compare_rec);
-}
-
-pub fn main() { test_bool(); test_rec(); }
+++ /dev/null
-// 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.
-
-
-
-
-// -*- rust -*-
-
-// Tests for match as expressions resulting in struct types
-struct R { i: int }
-
-fn test_rec() {
- let rs = match true { true => R {i: 100}, _ => fail!() };
- assert_eq!(rs.i, 100);
-}
-
-enum mood { happy, sad, }
-
-impl cmp::Eq for mood {
- fn eq(&self, other: &mood) -> bool {
- ((*self) as uint) == ((*other) as uint)
- }
- fn ne(&self, other: &mood) -> bool { !(*self).eq(other) }
-}
-
-fn test_tag() {
- let rs = match true { true => { happy } false => { sad } };
- assert_eq!(rs, happy);
-}
-
-pub fn main() { test_rec(); test_tag(); }
+++ /dev/null
-// 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.
-
-
-
-
-// -*- rust -*-
-
-// Tests for match as expressions resulting in boxed types
-fn test_box() {
- let res = match true { true => { ~100 }, _ => fail!() };
- assert_eq!(*res, 100);
-}
-
-pub fn main() { test_box(); }
+++ /dev/null
-// 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.
-
-
-
-
-// -*- rust -*-
-
-// Tests for using match as an expression
-fn test_basic() {
- let mut rs: bool = match true { true => { true } false => { false } };
- assert!((rs));
- rs = match false { true => { false } false => { true } };
- assert!((rs));
-}
-
-fn test_inferrence() {
- let mut rs = match true { true => { true } false => { false } };
- assert!((rs));
-}
-
-fn test_alt_as_alt_head() {
- // Yeah, this is kind of confusing ...
-
- let rs =
- match match false { true => { true } false => { false } } {
- true => { false }
- false => { true }
- };
- assert!((rs));
-}
-
-fn test_alt_as_block_result() {
- let rs =
- match false {
- true => { false }
- false => { match true { true => { true } false => { false } } }
- };
- assert!((rs));
-}
-
-pub fn main() {
- test_basic();
- test_inferrence();
- test_alt_as_alt_head();
- test_alt_as_block_result();
-}
--- /dev/null
+// 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.
+
+
+
+
+// -*- rust -*-
+
+// Tests for match as expressions resulting in boxed types
+fn test_box() {
+ let res = match true { true => { @100 } _ => fail!("wat") };
+ assert_eq!(*res, 100);
+}
+
+fn test_str() {
+ let res = match true { true => { ~"happy" },
+ _ => fail!("not happy at all") };
+ assert_eq!(res, ~"happy");
+}
+
+pub fn main() { test_box(); test_str(); }
--- /dev/null
+// 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.
+
+
+
+
+// When all branches of an match expression result in fail, the entire
+// match expression results in fail.
+pub fn main() {
+ let x =
+ match true {
+ true => { 10 }
+ false => { match true { true => { fail!() } false => { fail!() } } }
+ };
+}
--- /dev/null
+// 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.
+
+fn test_simple() {
+ let r = match true { true => { true } false => { fail!() } };
+ assert_eq!(r, true);
+}
+
+fn test_box() {
+ let r = match true { true => { ~[10] } false => { fail!() } };
+ assert_eq!(r[0], 10);
+}
+
+pub fn main() { test_simple(); test_box(); }
--- /dev/null
+// 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.
+
+
+
+
+// -*- rust -*-
+type compare<T> = @fn(@T, @T) -> bool;
+
+fn test_generic<T>(expected: @T, eq: compare<T>) {
+ let actual: @T = match true { true => { expected }, _ => fail!() };
+ assert!((eq(expected, actual)));
+}
+
+fn test_box() {
+ fn compare_box(b1: @bool, b2: @bool) -> bool { return *b1 == *b2; }
+ test_generic::<bool>(@true, compare_box);
+}
+
+pub fn main() { test_box(); }
--- /dev/null
+// 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.
+
+// xfail-fast
+// -*- rust -*-
+
+type compare<T> = @fn(T, T) -> bool;
+
+fn test_generic<T:Copy>(expected: T, eq: compare<T>) {
+ let actual: T = match true { true => { expected }, _ => fail!("wat") };
+ assert!((eq(expected, actual)));
+}
+
+fn test_vec() {
+ fn compare_box(v1: @int, v2: @int) -> bool { return v1 == v2; }
+ test_generic::<@int>(@1, compare_box);
+}
+
+pub fn main() { test_vec(); }
--- /dev/null
+// 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.
+
+
+
+// -*- rust -*-
+type compare<T> = @fn(~T, ~T) -> bool;
+
+fn test_generic<T:Copy+Clone>(expected: ~T, eq: compare<T>) {
+ let actual: ~T = match true {
+ true => { expected.clone() },
+ _ => fail!("wat")
+ };
+ assert!((eq(expected, actual)));
+}
+
+fn test_box() {
+ fn compare_box(b1: ~bool, b2: ~bool) -> bool { return *b1 == *b2; }
+ test_generic::<bool>(~true, compare_box);
+}
+
+pub fn main() { test_box(); }
--- /dev/null
+// 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.
+
+// xfail-fast
+// -*- rust -*-
+
+type compare<T> = @fn(T, T) -> bool;
+
+fn test_generic<T:Copy+Clone>(expected: T, eq: compare<T>) {
+ let actual: T = match true {
+ true => expected.clone(),
+ _ => fail!("wat")
+ };
+ assert!((eq(expected, actual)));
+}
+
+fn test_vec() {
+ fn compare_box(v1: ~int, v2: ~int) -> bool { return v1 == v2; }
+ test_generic::<~int>(~1, compare_box);
+}
+
+pub fn main() { test_vec(); }
--- /dev/null
+// 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.
+
+// xfail-fast
+// -*- rust -*-
+
+type compare<T> = @fn(T, T) -> bool;
+
+fn test_generic<T:Copy>(expected: T, eq: compare<T>) {
+ let actual: T = match true { true => { expected }, _ => fail!("wat") };
+ assert!((eq(expected, actual)));
+}
+
+fn test_bool() {
+ fn compare_bool(b1: bool, b2: bool) -> bool { return b1 == b2; }
+ test_generic::<bool>(true, compare_bool);
+}
+
+struct Pair { a: int, b: int }
+
+fn test_rec() {
+ fn compare_rec(t1: Pair, t2: Pair) -> bool {
+ t1.a == t2.a && t1.b == t2.b
+ }
+ test_generic::<Pair>(Pair {a: 1, b: 2}, compare_rec);
+}
+
+pub fn main() { test_bool(); test_rec(); }
--- /dev/null
+// 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.
+
+
+
+
+// -*- rust -*-
+
+// Tests for match as expressions resulting in struct types
+struct R { i: int }
+
+fn test_rec() {
+ let rs = match true { true => R {i: 100}, _ => fail!() };
+ assert_eq!(rs.i, 100);
+}
+
+enum mood { happy, sad, }
+
+impl cmp::Eq for mood {
+ fn eq(&self, other: &mood) -> bool {
+ ((*self) as uint) == ((*other) as uint)
+ }
+ fn ne(&self, other: &mood) -> bool { !(*self).eq(other) }
+}
+
+fn test_tag() {
+ let rs = match true { true => { happy } false => { sad } };
+ assert_eq!(rs, happy);
+}
+
+pub fn main() { test_rec(); test_tag(); }
--- /dev/null
+// 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.
+
+
+
+
+// -*- rust -*-
+
+// Tests for match as expressions resulting in boxed types
+fn test_box() {
+ let res = match true { true => { ~100 }, _ => fail!() };
+ assert_eq!(*res, 100);
+}
+
+pub fn main() { test_box(); }
--- /dev/null
+// 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.
+
+
+
+
+// -*- rust -*-
+
+// Tests for using match as an expression
+fn test_basic() {
+ let mut rs: bool = match true { true => { true } false => { false } };
+ assert!((rs));
+ rs = match false { true => { false } false => { true } };
+ assert!((rs));
+}
+
+fn test_inferrence() {
+ let mut rs = match true { true => { true } false => { false } };
+ assert!((rs));
+}
+
+fn test_alt_as_alt_head() {
+ // Yeah, this is kind of confusing ...
+
+ let rs =
+ match match false { true => { true } false => { false } } {
+ true => { false }
+ false => { true }
+ };
+ assert!((rs));
+}
+
+fn test_alt_as_block_result() {
+ let rs =
+ match false {
+ true => { false }
+ false => { match true { true => { true } false => { false } } }
+ };
+ assert!((rs));
+}
+
+pub fn main() {
+ test_basic();
+ test_inferrence();
+ test_alt_as_alt_head();
+ test_alt_as_block_result();
+}
+++ /dev/null
-// -*- rust -*-
-// 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.
-
-
-enum color {
- red,
- green,
- blue
-}
-
-pub fn main() {
- error!(match red {
- red => { 1 }
- green => { 2 }
- blue => { 3 }
- });
-}
--- /dev/null
+// -*- rust -*-
+// 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.
+
+
+enum color {
+ red,
+ green,
+ blue
+}
+
+pub fn main() {
+ error!(match red {
+ red => { 1 }
+ green => { 2 }
+ blue => { 3 }
+ });
+}
+++ /dev/null
-// 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.
-
-
-
-enum foo<T> { arm(T), }
-
-fn altfoo<T>(f: foo<T>) {
- let mut hit = false;
- match f { arm::<T>(x) => { debug!("in arm"); hit = true; } }
- assert!((hit));
-}
-
-pub fn main() { altfoo::<int>(arm::<int>(10)); }
--- /dev/null
+// 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.
+
+
+
+enum foo<T> { arm(T), }
+
+fn altfoo<T>(f: foo<T>) {
+ let mut hit = false;
+ match f { arm::<T>(x) => { debug!("in arm"); hit = true; } }
+ assert!((hit));
+}
+
+pub fn main() { altfoo::<int>(arm::<int>(10)); }
--- /dev/null
+// xfail-test
+// xfail-fast
+// -*- rust -*-
+fn f1(ref_string: &str) {
+ match ref_string {
+ "a" => io::println("found a"),
+ "b" => io::println("found b"),
+ _ => io::println("not found")
+ }
+}
+
+fn f2(ref_string: &str) {
+ match ref_string {
+ "a" => io::println("found a"),
+ "b" => io::println("found b"),
+ s => io::println(fmt!("not found (%s)", s))
+ }
+}
+
+fn g1(ref_1: &str, ref_2: &str) {
+ match (ref_1, ref_2) {
+ ("a", "b") => io::println("found a,b"),
+ ("b", "c") => io::println("found b,c"),
+ _ => io::println("not found")
+ }
+}
+
+fn g2(ref_1: &str, ref_2: &str) {
+ match (ref_1, ref_2) {
+ ("a", "b") => io::println("found a,b"),
+ ("b", "c") => io::println("found b,c"),
+ (s1, s2) => io::println(fmt!("not found (%s, %s)", s1, s2))
+ }
+}
+
+pub fn main() {
+ f1(@"a");
+ f1(~"b");
+ f1(&"c");
+ f1("d");
+ f2(@"a");
+ f2(~"b");
+ f2(&"c");
+ f2("d");
+ g1(@"a", @"b");
+ g1(~"b", ~"c");
+ g1(&"c", &"d");
+ g1("d", "e");
+ g2(@"a", @"b");
+ g2(~"b", ~"c");
+ g2(&"c", &"d");
+ g2("d", "e");
+}
--- /dev/null
+// 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.
+
+// n.b. This was only ever failing with optimization disabled.
+fn a() -> int { match return 1 { 2 => 3, _ => fail!() } }
+pub fn main() { a(); }
--- /dev/null
+// 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.
+
+
+pub fn main() {
+ let i: int =
+ match Some::<int>(3) { None::<int> => { fail!() } Some::<int>(_) => { 5 } };
+ debug!("%?", i);
+}
--- /dev/null
+// 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.
+
+struct Pair { a: ~int, b: ~int }
+
+pub fn main() {
+ let mut x = ~Pair {a: ~10, b: ~20};
+ match x {
+ ~Pair {a: ref mut a, b: ref mut b} => {
+ assert!(**a == 10); *a = ~30; assert!(**a == 30);
+ }
+ }
+}
--- /dev/null
+// 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.
+
+
+extern mod extra;
+
+fn foo<T>(y: Option<T>) {
+ let mut x: int;
+ let mut rs: ~[int] = ~[];
+ /* tests that x doesn't get put in the precondition for the
+ entire if expression */
+
+ if true {
+ } else {
+ match y {
+ None::<T> => x = 17,
+ _ => x = 42
+ }
+ rs += ~[x];
+ }
+ return;
+}
+
+pub fn main() { debug!("hello"); foo::<int>(Some::<int>(5)); }
--- /dev/null
+// 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.
+
+struct X { x: int }
+
+pub fn main() {
+ let x = match 0 {
+ _ => X {
+ x: 0
+ }.x
+ };
+}
--- /dev/null
+// 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.
+
+struct X { x: int }
+
+pub fn main() {
+ let x = match 0 {
+ _ => X {
+ x: 0
+ }
+ };
+}
--- /dev/null
+// 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.
+
+
+
+mod m1 {
+ pub enum foo { foo1, foo2, }
+}
+
+fn bar(x: m1::foo) { match x { m1::foo1 => { } m1::foo2 => { } } }
+
+pub fn main() { }
--- /dev/null
+// 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.
+
+
+
+// -*- rust -*-
+enum t { make_t(@int), clam, }
+
+fn foo(s: @int) {
+ let count = ::std::sys::refcount(s);
+ let x: t = make_t(s); // ref up
+
+ match x {
+ make_t(y) => {
+ debug!("%?", y); // ref up then down
+
+ }
+ _ => { debug!("?"); fail!(); }
+ }
+ debug!(::std::sys::refcount(s));
+ assert_eq!(::std::sys::refcount(s), count + 1u);
+ let _ = ::std::sys::refcount(s); // don't get bitten by last-use.
+}
+
+pub fn main() {
+ let s: @int = @0; // ref up
+
+ let count = ::std::sys::refcount(s);
+
+ foo(s); // ref up then down
+
+ debug!("%u", ::std::sys::refcount(s));
+ let count2 = ::std::sys::refcount(s);
+ let _ = ::std::sys::refcount(s); // don't get bitten by last-use.
+ assert_eq!(count, count2);
+}
--- /dev/null
+// 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.
+
+
+
+fn altlit(f: int) -> int {
+ match f {
+ 10 => { debug!("case 10"); return 20; }
+ 11 => { debug!("case 11"); return 22; }
+ _ => fail!("the impossible happened")
+ }
+}
+
+pub fn main() { assert!((altlit(10) == 20)); assert!((altlit(11) == 22)); }
--- /dev/null
+// 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.
+
+enum maybe<T> { nothing, just(T), }
+
+fn foo(x: maybe<int>) {
+ match x { nothing => { error!("A"); } just(a) => { error!("B"); } }
+}
+
+pub fn main() { }
--- /dev/null
+// 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.
+
+
+
+fn altsimple(f: int) { match f { x => () } }
+
+pub fn main() { }
--- /dev/null
+// 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.
+
+
+
+enum thing { a, b, c, }
+
+fn foo(it: &fn(int)) { it(10); }
+
+pub fn main() {
+ let mut x = true;
+ match a {
+ a => { x = true; foo(|_i| { } ) }
+ b => { x = false; }
+ c => { x = false; }
+ }
+}
--- /dev/null
+// 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.
+
+pub fn main() {
+ match 5u {
+ 1u..5u => {}
+ _ => fail!("should match range"),
+ }
+ match 5u {
+ 6u..7u => fail!("shouldn't match range"),
+ _ => {}
+ }
+ match 5u {
+ 1u => fail!("should match non-first range"),
+ 2u..6u => {}
+ _ => fail!("math is broken")
+ }
+ match 'c' {
+ 'a'..'z' => {}
+ _ => fail!("should suppport char ranges")
+ }
+ match -3 {
+ -7..5 => {}
+ _ => fail!("should match signed range")
+ }
+ match 3.0 {
+ 1.0..5.0 => {}
+ _ => fail!("should match float range")
+ }
+ match -1.5 {
+ -3.6..3.6 => {}
+ _ => fail!("should match negative float range")
+ }
+}
--- /dev/null
+// 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.
+
+pub fn main() {
+ let x = Some(unstable::sync::exclusive(true));
+ match x {
+ Some(ref z) if z.with(|b| *b) => {
+ do z.with |b| { assert!(*b); }
+ },
+ _ => fail!()
+ }
+}
--- /dev/null
+// 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.
+
+pub fn main() {
+ let mut v = Some(22);
+ match v {
+ None => {}
+ Some(ref mut p) => { *p += 1; }
+ }
+ assert_eq!(v, Some(23));
+}
--- /dev/null
+// 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.
+
+struct Rec {
+ f: int
+}
+
+fn destructure(x: &mut Rec) {
+ match *x {
+ Rec {f: ref mut f} => *f += 1
+ }
+}
+
+pub fn main() {
+ let mut v = Rec {f: 22};
+ destructure(&mut v);
+ assert_eq!(v.f, 23);
+}
--- /dev/null
+// 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.
+
+fn destructure(x: Option<int>) -> int {
+ match x {
+ None => 0,
+ Some(ref v) => *v
+ }
+}
+
+pub fn main() {
+ assert_eq!(destructure(Some(22)), 22);
+}
--- /dev/null
+// 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.
+
+// Issue #53
+
+pub fn main() {
+ match ~"test" { ~"not-test" => fail!(), ~"test" => (), _ => fail!() }
+
+ enum t { tag1(~str), tag2, }
+
+
+ match tag1(~"test") {
+ tag2 => fail!(),
+ tag1(~"not-test") => fail!(),
+ tag1(~"test") => (),
+ _ => fail!()
+ }
+
+ let x = match ~"a" { ~"a" => 1, ~"b" => 2, _ => fail!() };
+ assert_eq!(x, 1);
+
+ match ~"a" { ~"a" => { } ~"b" => { }, _ => fail!() }
+
+}
--- /dev/null
+// 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.
+
+
+
+
+// -*- rust -*-
+enum color {
+ rgb(int, int, int),
+ rgba(int, int, int, int),
+ hsl(int, int, int),
+}
+
+fn process(c: color) -> int {
+ let mut x: int;
+ match c {
+ rgb(r, _, _) => { x = r; }
+ rgba(_, _, _, a) => { x = a; }
+ hsl(_, s, _) => { x = s; }
+ }
+ return x;
+}
+
+pub fn main() {
+ let gray: color = rgb(127, 127, 127);
+ let clear: color = rgba(50, 150, 250, 0);
+ let red: color = hsl(0, 255, 255);
+ assert_eq!(process(gray), 127);
+ assert_eq!(process(clear), 0);
+ assert_eq!(process(red), 255);
+}
--- /dev/null
+// 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.
+
+pub fn main() {
+ match ~100 {
+ ~x => {
+ debug!("%?", x);
+ assert_eq!(x, 100);
+ }
+ }
+}
--- /dev/null
+// 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.
+
+fn foo(x: Option<~int>, b: bool) -> int {
+ match x {
+ None => { 1 }
+ Some(ref x) if b => { *x.clone() }
+ Some(_) => { 0 }
+ }
+}
+
+pub fn main() {
+ foo(Some(~22), true);
+ foo(Some(~22), false);
+ foo(None, true);
+ foo(None, false);
+}
--- /dev/null
+// 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.
+
+pub fn main() {
+ // sometimes we have had trouble finding
+ // the right type for f, as we unified
+ // bot and u32 here
+ let f = match uint::from_str(~"1234") {
+ None => return (),
+ Some(num) => num as u32
+ };
+ assert_eq!(f, 1234u32);
+ error!(f)
+}
+++ /dev/null
-// 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.
-
-
-fn baz() -> ! { fail!(); }
-
-fn foo() {
- match Some::<int>(5) {
- Some::<int>(x) => {
- let mut bar;
- match None::<int> { None::<int> => { bar = 5; } _ => { baz(); } }
- debug!(bar);
- }
- None::<int> => { debug!("hello"); }
- }
-}
-
-pub fn main() { foo(); }
+++ /dev/null
-// 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.
-
-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(_), _} => {}
- }
-}
--- /dev/null
+// 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.
+
+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(_), _} => {}
+ }
+}
--- /dev/null
+// 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.
+
+
+fn baz() -> ! { fail!(); }
+
+fn foo() {
+ match Some::<int>(5) {
+ Some::<int>(x) => {
+ let mut bar;
+ match None::<int> { None::<int> => { bar = 5; } _ => { baz(); } }
+ debug!(bar);
+ }
+ None::<int> => { debug!("hello"); }
+ }
+}
+
+pub fn main() { foo(); }
+++ /dev/null
-// 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.
-
-
-
-enum opt<T> { none, }
-
-pub fn main() {
- let x = none::<int>;
- match x { none::<int> => { debug!("hello world"); } }
-}
+++ /dev/null
-// 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.
-
-
-
-enum clam<T> { a(T), }
-
-pub fn main() { let c = a(2); match c { a::<int>(_) => { } } }
--- /dev/null
+// 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.
+
+
+
+enum clam<T> { a(T), }
+
+pub fn main() { let c = a(2); match c { a::<int>(_) => { } } }
--- /dev/null
+// 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.
+
+
+
+enum opt<T> { none, }
+
+pub fn main() {
+ let x = none::<int>;
+ match x { none::<int> => { debug!("hello world"); } }
+}
+++ /dev/null
-// 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.
-
-// Issue #961
-
-fn altsimple() {
- match ~true {
- _ => { }
- }
-}
-pub fn main() { }
--- /dev/null
+// 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.
+
+// Issue #961
+
+fn altsimple() {
+ match ~true {
+ _ => { }
+ }
+}
+pub fn main() { }
+++ /dev/null
-// 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.
-
-
-
-fn foo<T>(o: myoption<T>) -> int {
- let mut x: int = 5;
- match o { none::<T> => { } some::<T>(t) => { x += 1; } }
- return x;
-}
-
-enum myoption<T> { none, some(T), }
-
-pub fn main() { debug!(5); }
+++ /dev/null
-// 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.
-
-
-
-fn foo<T>(o: myoption<T>) -> int {
- let mut x: int;
- match o { none::<T> => { fail!(); } some::<T>(t) => { x = 5; } }
- return x;
-}
-
-enum myoption<T> { none, some(T), }
-
-pub fn main() { debug!(5); }
--- /dev/null
+// 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.
+
+
+
+fn foo<T>(o: myoption<T>) -> int {
+ let mut x: int = 5;
+ match o { none::<T> => { } some::<T>(t) => { x += 1; } }
+ return x;
+}
+
+enum myoption<T> { none, some(T), }
+
+pub fn main() { debug!(5); }
--- /dev/null
+// 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.
+
+
+
+fn foo<T>(o: myoption<T>) -> int {
+ let mut x: int;
+ match o { none::<T> => { fail!(); } some::<T>(t) => { x = 5; } }
+ return x;
+}
+
+enum myoption<T> { none, some(T), }
+
+pub fn main() { debug!(5); }