]>
Commit | Line | Data |
---|---|---|
9346a6ac AL |
1 | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT |
2 | // file at the top-level directory of this distribution and at | |
3 | // http://rust-lang.org/COPYRIGHT. | |
4 | // | |
5 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
6 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
7 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
8 | // option. This file may not be copied, modified, or distributed | |
9 | // except according to those terms. | |
10 | ||
b7449926 | 11 | // run-pass |
9346a6ac AL |
12 | // Parsing patterns with paths with type parameters (issue #22544) |
13 | ||
14 | use std::default::Default; | |
15 | ||
16 | #[derive(Default)] | |
17 | pub struct Foo<T>(T, T); | |
18 | ||
19 | impl<T: ::std::fmt::Display> Foo<T> { | |
20 | fn foo(&self) { | |
21 | match *self { | |
22 | Foo::<T>(ref x, ref y) => println!("Goodbye, World! {} {}", x, y) | |
23 | } | |
24 | } | |
25 | } | |
26 | ||
27 | trait Tr { | |
28 | type U; | |
29 | } | |
30 | ||
31 | impl<T> Tr for Foo<T> { | |
32 | type U = T; | |
33 | } | |
34 | ||
35 | struct Wrapper<T> { | |
36 | value: T | |
37 | } | |
38 | ||
39 | fn main() { | |
40 | let Foo::<i32>(a, b) = Default::default(); | |
41 | ||
42 | let f = Foo(2,3); | |
43 | f.foo(); | |
44 | ||
45 | let w = Wrapper { value: Foo(10u8, 11u8) }; | |
46 | match w { | |
47 | Wrapper::<Foo<u8>> { value: Foo(10, 11) } => {}, | |
48 | ::Wrapper::<<Foo<_> as Tr>::U> { value: Foo::<u8>(11, 16) } => { panic!() }, | |
49 | _ => { panic!() } | |
50 | } | |
51 | ||
52 | if let None::<u8> = Some(8) { | |
53 | panic!(); | |
54 | } | |
c30ab7b3 SL |
55 | if let None::<u8> { .. } = Some(8) { |
56 | panic!(); | |
57 | } | |
58 | if let Option::None::<u8> { .. } = Some(8) { | |
59 | panic!(); | |
60 | } | |
9346a6ac | 61 | } |