File tree Expand file tree Collapse file tree 5 files changed +133
-4
lines changed
Expand file tree Collapse file tree 5 files changed +133
-4
lines changed Original file line number Diff line number Diff line change @@ -26,15 +26,11 @@ fn main() { //~ ERROR compilation successful
2626 //~^^^ WARNING unmatchable NaN in pattern, use the is_nan method in a guard instead
2727 //~| WARNING floating point constants cannot be used
2828 //~| WARNING this was previously accepted
29- //~| WARNING floating point constants cannot be used
30- //~| WARNING this was previously accepted
3129 match [ x, 1.0 ] {
3230 [ NAN , _] => { } ,
3331 _ => { } ,
3432 } ;
3533 //~^^^ WARNING unmatchable NaN in pattern, use the is_nan method in a guard instead
3634 //~| WARNING floating point constants cannot be used
3735 //~| WARNING this was previously accepted
38- //~| WARNING floating point constants cannot be used
39- //~| WARNING this was previously accepted
4036}
Original file line number Diff line number Diff line change 1+ // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ // Test that structural match is only permitted with a feature gate,
12+ // and that if a feature gate is supplied, it permits the type to be
13+ // used in a match.
14+
15+ // revisions: with_gate no_gate
16+
17+ #![ allow( dead_code) ]
18+ #![ deny( future_incompatible) ]
19+ #![ feature( rustc_attrs) ]
20+ #![ cfg_attr( with_gate, feature( structural_match) ) ]
21+
22+ #[ structural_match] //[no_gate]~ ERROR semantics of constant patterns is not yet settled
23+ struct Foo {
24+ x : u32
25+ }
26+
27+ const FOO : Foo = Foo { x : 0 } ;
28+
29+ #[ rustc_error]
30+ fn main ( ) { //[with_gate]~ ERROR compilation successful
31+ let y = Foo { x : 1 } ;
32+ match y {
33+ FOO => { }
34+ _ => { }
35+ }
36+ }
Original file line number Diff line number Diff line change 1+ // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ #![ allow( dead_code) ]
12+ #![ deny( future_incompatible) ]
13+
14+ use std:: f32;
15+
16+ #[ derive( PartialEq ) ]
17+ struct Foo {
18+ x : u32
19+ }
20+
21+ const FOO : Foo = Foo { x : 0 } ;
22+
23+ fn main ( ) {
24+ let y = Foo { x : 1 } ;
25+ match y {
26+ FOO => { }
27+ //~^ ERROR must be annotated with `#[derive(Eq)]`
28+ //~| WARNING will become a hard error
29+ _ => { }
30+ }
31+
32+ let x = 0.0 ;
33+ match x {
34+ f32:: INFINITY => { }
35+ //~^ ERROR floating point constants cannot be used in patterns
36+ //~| WARNING will become a hard error
37+ _ => { }
38+ }
39+ }
Original file line number Diff line number Diff line change 1+ // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ #![ allow( dead_code) ]
12+
13+ macro_rules! foo {
14+ ( #[ $attr: meta] $x: ident) => {
15+ #[ $attr]
16+ struct $x {
17+ x: u32
18+ }
19+ }
20+ }
21+
22+ foo ! { #[ derive( PartialEq , Eq ) ] Foo }
23+
24+ const FOO : Foo = Foo { x : 0 } ;
25+
26+ fn main ( ) {
27+ let y = Foo { x : 1 } ;
28+ match y {
29+ FOO => { }
30+ _ => { }
31+ }
32+ }
Original file line number Diff line number Diff line change 1+ // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ #![ allow( dead_code) ]
12+
13+ #[ derive( PartialEq , Eq ) ]
14+ struct Foo {
15+ x : u32
16+ }
17+
18+ const FOO : Foo = Foo { x : 0 } ;
19+
20+ fn main ( ) {
21+ let y = Foo { x : 1 } ;
22+ match y {
23+ FOO => { }
24+ _ => { }
25+ }
26+ }
You can’t perform that action at this time.
0 commit comments