]> git.proxmox.com Git - rustc.git/blob - src/test/ui/rfc1445/cant-hide-behind-direct-struct-embedded.rs
New upstream version 1.44.1+dfsg1
[rustc.git] / src / test / ui / rfc1445 / cant-hide-behind-direct-struct-embedded.rs
1 // This is part of a set of tests exploring the different ways a
2 // structural-match ADT might try to hold a
3 // non-structural-match in hidden manner that lets matches
4 // through that we had intended to reject.
5 //
6 // See discussion on rust-lang/rust#62307 and rust-lang/rust#62339
7
8 struct NoDerive(i32);
9
10 // This impl makes NoDerive irreflexive.
11 impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
12
13 impl Eq for NoDerive { }
14
15 #[derive(PartialEq, Eq)]
16 struct WrapInline(NoDerive);
17
18 const WRAP_DIRECT_INLINE: WrapInline = WrapInline(NoDerive(0));
19
20 fn main() {
21 match WRAP_DIRECT_INLINE {
22 WRAP_DIRECT_INLINE => { panic!("WRAP_DIRECT_INLINE matched itself"); }
23 //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
24 //~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
25 _ => { println!("WRAP_DIRECT_INLINE did not match itself"); }
26 }
27 }