]> git.lizzy.rs Git - rust.git/blob - src/test/ui/rfc-1445-restrict-constants-in-patterns/feature-gate.rs
Rollup merge of #95376 - WaffleLapkin:drain_keep_rest, r=dtolnay
[rust.git] / src / test / ui / rfc-1445-restrict-constants-in-patterns / feature-gate.rs
1 // Test that use of structural-match traits is only permitted with a feature gate,
2 // and that if a feature gate is supplied, it permits the type to be
3 // used in a match.
4
5 // revisions: with_gate no_gate
6
7 // gate-test-structural_match
8
9 #![allow(unused)]
10 #![feature(rustc_attrs)]
11 #![cfg_attr(with_gate, feature(structural_match))]
12
13
14 struct Foo {
15     x: u32
16 }
17
18 const FOO: Foo = Foo { x: 0 };
19
20 #[rustc_error]
21 fn main() { //[with_gate]~ ERROR fatal error triggered by #[rustc_error]
22     let y = Foo { x: 1 };
23     match y {
24         FOO => { }
25         _ => { }
26     }
27 }
28
29 impl std::marker::StructuralPartialEq for Foo { }
30 //[no_gate]~^ ERROR use of unstable library feature 'structural_match'
31 impl std::marker::StructuralEq for Foo { }
32 //[no_gate]~^ ERROR use of unstable library feature 'structural_match'
33
34 impl PartialEq<Foo> for Foo {
35     fn eq(&self, other: &Self) -> bool {
36         self.x == other.x
37     }
38 }
39 impl Eq for Foo { }