2020-03-24 13:52:22 -05:00
|
|
|
// Test that use of structural-match traits is only permitted with a feature gate,
|
2016-03-11 12:36:55 -06:00
|
|
|
// and that if a feature gate is supplied, it permits the type to be
|
|
|
|
// used in a match.
|
|
|
|
|
|
|
|
// revisions: with_gate no_gate
|
|
|
|
|
2017-01-10 19:25:44 -06:00
|
|
|
// gate-test-structural_match
|
|
|
|
|
2017-05-21 06:11:08 -05:00
|
|
|
#![allow(unused)]
|
2016-03-11 12:36:55 -06:00
|
|
|
#![feature(rustc_attrs)]
|
|
|
|
#![cfg_attr(with_gate, feature(structural_match))]
|
|
|
|
|
2019-10-17 03:54:37 -05:00
|
|
|
|
2016-03-11 12:36:55 -06:00
|
|
|
struct Foo {
|
|
|
|
x: u32
|
|
|
|
}
|
|
|
|
|
|
|
|
const FOO: Foo = Foo { x: 0 };
|
|
|
|
|
|
|
|
#[rustc_error]
|
2019-11-05 15:42:23 -06:00
|
|
|
fn main() { //[with_gate]~ ERROR fatal error triggered by #[rustc_error]
|
2016-03-11 12:36:55 -06:00
|
|
|
let y = Foo { x: 1 };
|
|
|
|
match y {
|
|
|
|
FOO => { }
|
|
|
|
_ => { }
|
|
|
|
}
|
|
|
|
}
|
2019-10-17 03:54:37 -05:00
|
|
|
|
|
|
|
impl std::marker::StructuralPartialEq for Foo { }
|
|
|
|
//[no_gate]~^ ERROR use of unstable library feature 'structural_match'
|
|
|
|
impl std::marker::StructuralEq for Foo { }
|
|
|
|
//[no_gate]~^ ERROR use of unstable library feature 'structural_match'
|
|
|
|
|
|
|
|
impl PartialEq<Foo> for Foo {
|
|
|
|
fn eq(&self, other: &Self) -> bool {
|
|
|
|
self.x == other.x
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl Eq for Foo { }
|