]>
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 | ||
11 | // Parsing patterns with paths with type parameters (issue #22544) | |
12 | ||
13 | use std::default::Default; | |
14 | ||
15 | #[derive(Default)] | |
16 | pub struct Foo<T>(T, T); | |
17 | ||
18 | impl<T: ::std::fmt::Display> Foo<T> { | |
19 | fn foo(&self) { | |
20 | match *self { | |
21 | Foo::<T>(ref x, ref y) => println!("Goodbye, World! {} {}", x, y) | |
22 | } | |
23 | } | |
24 | } | |
25 | ||
26 | trait Tr { | |
27 | type U; | |
28 | } | |
29 | ||
30 | impl<T> Tr for Foo<T> { | |
31 | type U = T; | |
32 | } | |
33 | ||
34 | struct Wrapper<T> { | |
35 | value: T | |
36 | } | |
37 | ||
38 | fn main() { | |
39 | let Foo::<i32>(a, b) = Default::default(); | |
40 | ||
41 | let f = Foo(2,3); | |
42 | f.foo(); | |
43 | ||
44 | let w = Wrapper { value: Foo(10u8, 11u8) }; | |
45 | match w { | |
46 | Wrapper::<Foo<u8>> { value: Foo(10, 11) } => {}, | |
47 | ::Wrapper::<<Foo<_> as Tr>::U> { value: Foo::<u8>(11, 16) } => { panic!() }, | |
48 | _ => { panic!() } | |
49 | } | |
50 | ||
51 | if let None::<u8> = Some(8) { | |
52 | panic!(); | |
53 | } | |
c30ab7b3 SL |
54 | if let None::<u8> { .. } = Some(8) { |
55 | panic!(); | |
56 | } | |
57 | if let Option::None::<u8> { .. } = Some(8) { | |
58 | panic!(); | |
59 | } | |
9346a6ac | 60 | } |