]> git.lizzy.rs Git - rust.git/blob - src/test/ui/pattern/issue-22546.rs
Rollup merge of #98583 - joshtriplett:stabilize-windows-symlink-types, r=thomcc
[rust.git] / src / test / ui / pattern / issue-22546.rs
1 // run-pass
2 #![allow(unused_variables)]
3 // Parsing patterns with paths with type parameters (issue #22544)
4
5 use std::default::Default;
6
7 #[derive(Default)]
8 pub struct Foo<T>(T, T);
9
10 impl<T: ::std::fmt::Display> Foo<T> {
11     fn foo(&self) {
12         match *self {
13             Foo::<T>(ref x, ref y) => println!("Goodbye, World! {} {}", x, y)
14         }
15     }
16 }
17
18 trait Tr {
19     type U;
20 }
21
22 impl<T> Tr for Foo<T> {
23     type U = T;
24 }
25
26 struct Wrapper<T> {
27     value: T
28 }
29
30 fn main() {
31     let Foo::<i32>(a, b) = Default::default();
32
33     let f = Foo(2,3);
34     f.foo();
35
36     let w = Wrapper { value: Foo(10u8, 11u8) };
37     match w {
38         Wrapper::<Foo<u8>> { value: Foo(10, 11) } => {},
39         ::Wrapper::<<Foo<_> as Tr>::U> { value: Foo::<u8>(11, 16) } => { panic!() },
40         _ => { panic!() }
41     }
42
43     if let None::<u8> = Some(8) {
44         panic!();
45     }
46     if let None::<u8> { .. } = Some(8) {
47         panic!();
48     }
49     if let Option::None::<u8> { .. } = Some(8) {
50         panic!();
51     }
52 }