]> git.proxmox.com Git - rustc.git/blame - src/test/ui/rfc1445/issue-63479-match-fnptr.rs
New upstream version 1.48.0~beta.8+dfsg1
[rustc.git] / src / test / ui / rfc1445 / issue-63479-match-fnptr.rs
CommitLineData
416331ca
XL
1// run-pass
2
3// The actual regression test from #63479. (Including this because my
4// first draft at fn-ptr-is-structurally-matchable.rs failed to actually
5// cover the case this hit; I've since expanded it accordingly, but the
6// experience left me wary of leaving this regression test out.)
7
1b1a35ee
XL
8#![warn(pointer_structural_match)]
9
416331ca
XL
10#[derive(Eq)]
11struct A {
12 a: i64
13}
14
15impl PartialEq for A {
16 #[inline]
17 fn eq(&self, other: &Self) -> bool {
18 self.a.eq(&other.a)
19 }
20}
21
22type Fn = fn(&[A]);
23
24fn my_fn(_args: &[A]) {
25 println!("hello world");
26}
27
28const TEST: Fn = my_fn;
29
30struct B(Fn);
31
32fn main() {
33 let s = B(my_fn);
34 match s {
35 B(TEST) => println!("matched"),
1b1a35ee
XL
36 //~^ WARN pointers in patterns behave unpredictably
37 //~| WARN this was previously accepted by the compiler but is being phased out
416331ca
XL
38 _ => panic!("didn't match")
39 };
40}