]> git.lizzy.rs Git - rust.git/blob - src/test/ui/pattern/usefulness/issue-72476-and-89393-associated-type.rs
Auto merge of #98526 - jyn514:download-llvm-outside-checkout, r=Mark-Simulacrum
[rust.git] / src / test / ui / pattern / usefulness / issue-72476-and-89393-associated-type.rs
1 // check-pass
2
3 // From https://github.com/rust-lang/rust/issues/72476
4 // and https://github.com/rust-lang/rust/issues/89393
5
6 trait Trait {
7     type Projection;
8 }
9
10 struct A;
11 impl Trait for A {
12     type Projection = bool;
13 }
14
15 struct B;
16 impl Trait for B {
17     type Projection = (u32, u32);
18 }
19
20 struct Next<T: Trait>(T::Projection);
21
22 fn foo1(item: Next<A>) {
23     match item {
24         Next(true) => {}
25         Next(false) => {}
26     }
27 }
28
29 fn foo2(x: <A as Trait>::Projection) {
30     match x {
31         true => {}
32         false => {}
33     }
34 }
35
36 fn foo3(x: Next<B>) {
37     let Next((_, _)) = x;
38     match x {
39         Next((_, _)) => {}
40     }
41 }
42
43 fn foo4(x: <B as Trait>::Projection) {
44     let (_, _) = x;
45     match x {
46         (_, _) => {}
47     }
48 }
49
50 fn foo5<T: Trait>(x: <T as Trait>::Projection) {
51     match x {
52         _ => {}
53     }
54 }
55
56 fn main() {}