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