1
1
//@ edition: 2024
2
- //@ revisions: classic structural
2
+ //@ revisions: classic2024 structural2024
3
3
//! Test cases for poorly-typed patterns in edition 2024 which are caught by HIR typeck. These must
4
4
//! be separate from cases caught by MIR borrowck or the latter errors may not be emitted.
5
5
#![ allow( incomplete_features) ]
6
- #![ cfg_attr( classic , feature( ref_pat_eat_one_layer_2024) ) ]
7
- #![ cfg_attr( structural , feature( ref_pat_eat_one_layer_2024_structural) ) ]
6
+ #![ cfg_attr( classic2024 , feature( ref_pat_eat_one_layer_2024) ) ]
7
+ #![ cfg_attr( structural2024 , feature( ref_pat_eat_one_layer_2024_structural) ) ]
8
8
9
9
pub fn main ( ) {
10
10
if let Some ( & mut x) = & Some ( & mut 0 ) {
11
- //[classic ]~^ ERROR: mismatched types
11
+ //[classic2024 ]~^ ERROR: mismatched types
12
12
let _: & u32 = x;
13
13
}
14
14
if let Some ( & mut Some ( & x) ) = & Some ( & mut Some ( 0 ) ) {
15
- //[classic ]~^ ERROR: mismatched types
15
+ //[classic2024 ]~^ ERROR: mismatched types
16
16
let _: u32 = x;
17
17
}
18
18
if let Some ( Some ( & mut x) ) = & Some ( Some ( & mut 0 ) ) {
19
- //[classic ]~^ ERROR: mismatched types
19
+ //[classic2024 ]~^ ERROR: mismatched types
20
20
let _: & u32 = x;
21
21
}
22
22
23
23
if let Some ( & mut Some ( & _) ) = & Some ( & Some ( 0 ) ) {
24
24
//~^ ERROR: mismatched types
25
25
}
26
26
if let Some ( & Some ( & mut _) ) = & Some ( & mut Some ( 0 ) ) {
27
- //[structural ]~^ ERROR: mismatched types
27
+ //[structural2024 ]~^ ERROR: mismatched types
28
28
}
29
29
if let Some ( & Some ( & mut _) ) = & mut Some ( & Some ( 0 ) ) {
30
30
//~^ ERROR: mismatched types
31
31
}
32
32
if let Some ( & Some ( Some ( ( & mut _) ) ) ) = & Some ( Some ( & mut Some ( 0 ) ) ) {
33
- //[structural ]~^ ERROR: mismatched types
33
+ //[structural2024 ]~^ ERROR: mismatched types
34
34
}
35
35
if let Some ( & mut Some ( x) ) = & Some ( Some ( 0 ) ) {
36
36
//~^ ERROR: mismatched types
@@ -42,96 +42,96 @@ pub fn main() {
42
42
43
43
fn structural_errors_0 ( ) {
44
44
let & [ & mut x] = & & mut [ 0 ] ;
45
- //[structural ]~^ ERROR: mismatched types
46
- //[structural ]~| cannot match inherited `&` with `&mut` pattern
45
+ //[structural2024 ]~^ ERROR: mismatched types
46
+ //[structural2024 ]~| cannot match inherited `&` with `&mut` pattern
47
47
let _: u32 = x;
48
48
49
49
let & [ & mut x] = & mut & mut [ 0 ] ;
50
- //[structural ]~^ ERROR: mismatched types
51
- //[structural ]~| cannot match inherited `&` with `&mut` pattern
50
+ //[structural2024 ]~^ ERROR: mismatched types
51
+ //[structural2024 ]~| cannot match inherited `&` with `&mut` pattern
52
52
let _: u32 = x;
53
53
54
54
let & [ & mut ref x] = & & mut [ 0 ] ;
55
- //[structural ]~^ ERROR: mismatched types
56
- //[structural ]~| cannot match inherited `&` with `&mut` pattern
55
+ //[structural2024 ]~^ ERROR: mismatched types
56
+ //[structural2024 ]~| cannot match inherited `&` with `&mut` pattern
57
57
let _: & u32 = x;
58
58
59
59
let & [ & mut ref x] = & mut & mut [ 0 ] ;
60
- //[structural ]~^ ERROR: mismatched types
61
- //[structural ]~| cannot match inherited `&` with `&mut` pattern
60
+ //[structural2024 ]~^ ERROR: mismatched types
61
+ //[structural2024 ]~| cannot match inherited `&` with `&mut` pattern
62
62
let _: & u32 = x;
63
63
64
64
let & [ & mut mut x] = & & mut [ 0 ] ;
65
- //[structural ]~^ ERROR: mismatched types
66
- //[structural ]~| cannot match inherited `&` with `&mut` pattern
65
+ //[structural2024 ]~^ ERROR: mismatched types
66
+ //[structural2024 ]~| cannot match inherited `&` with `&mut` pattern
67
67
let _: u32 = x;
68
68
69
69
let & [ & mut mut x] = & mut & mut [ 0 ] ;
70
- //[structural ]~^ ERROR: mismatched types
71
- //[structural ]~| cannot match inherited `&` with `&mut` pattern
70
+ //[structural2024 ]~^ ERROR: mismatched types
71
+ //[structural2024 ]~| cannot match inherited `&` with `&mut` pattern
72
72
let _: u32 = x;
73
73
}
74
74
75
75
fn structural_errors_1 ( ) {
76
76
let [ & ( mut x) ] = & [ & 0 ] ;
77
- //[structural ]~^ ERROR: binding cannot be both mutable and by-reference
77
+ //[structural2024 ]~^ ERROR: binding cannot be both mutable and by-reference
78
78
let _: & u32 = x;
79
79
80
80
let [ & ( mut x) ] = & mut [ & 0 ] ;
81
- //[structural ]~^ ERROR: binding cannot be both mutable and by-reference
81
+ //[structural2024 ]~^ ERROR: binding cannot be both mutable and by-reference
82
82
let _: & u32 = x;
83
83
}
84
84
85
85
fn structural_errors_2 ( ) {
86
86
let [ & & mut x] = & [ & mut 0 ] ;
87
- //[structural ]~^ ERROR: mismatched types
88
- //[structural ]~| cannot match inherited `&` with `&mut` pattern
87
+ //[structural2024 ]~^ ERROR: mismatched types
88
+ //[structural2024 ]~| cannot match inherited `&` with `&mut` pattern
89
89
let _: u32 = x;
90
90
91
91
let [ & & mut x] = & mut [ & mut 0 ] ;
92
- //[structural ]~^ ERROR: mismatched types
93
- //[structural ]~| cannot match inherited `&` with `&mut` pattern
92
+ //[structural2024 ]~^ ERROR: mismatched types
93
+ //[structural2024 ]~| cannot match inherited `&` with `&mut` pattern
94
94
let _: u32 = x;
95
95
96
96
let [ & & mut ref x] = & [ & mut 0 ] ;
97
- //[structural ]~^ ERROR: mismatched types
98
- //[structural ]~| cannot match inherited `&` with `&mut` pattern
97
+ //[structural2024 ]~^ ERROR: mismatched types
98
+ //[structural2024 ]~| cannot match inherited `&` with `&mut` pattern
99
99
let _: & u32 = x;
100
100
101
101
let [ & & mut ref x] = & mut [ & mut 0 ] ;
102
- //[structural ]~^ ERROR: mismatched types
103
- //[structural ]~| cannot match inherited `&` with `&mut` pattern
102
+ //[structural2024 ]~^ ERROR: mismatched types
103
+ //[structural2024 ]~| cannot match inherited `&` with `&mut` pattern
104
104
let _: & u32 = x;
105
105
106
106
let [ & & mut mut x] = & [ & mut 0 ] ;
107
- //[structural ]~^ ERROR: mismatched types
108
- //[structural ]~| cannot match inherited `&` with `&mut` pattern
107
+ //[structural2024 ]~^ ERROR: mismatched types
108
+ //[structural2024 ]~| cannot match inherited `&` with `&mut` pattern
109
109
let _: u32 = x;
110
110
111
111
let [ & & mut mut x] = & mut [ & mut 0 ] ;
112
- //[structural ]~^ ERROR: mismatched types
113
- //[structural ]~| cannot match inherited `&` with `&mut` pattern
112
+ //[structural2024 ]~^ ERROR: mismatched types
113
+ //[structural2024 ]~| cannot match inherited `&` with `&mut` pattern
114
114
let _: u32 = x;
115
115
}
116
116
117
117
fn classic_errors_0 ( ) {
118
118
let [ & mut x] = & [ & mut 0 ] ;
119
- //[classic ]~^ ERROR: mismatched types
120
- //[classic ]~| cannot match inherited `&` with `&mut` pattern
119
+ //[classic2024 ]~^ ERROR: mismatched types
120
+ //[classic2024 ]~| cannot match inherited `&` with `&mut` pattern
121
121
let _: & u32 = x;
122
122
123
123
let [ & mut & x] = & [ & mut 0 ] ;
124
- //[classic ]~^ ERROR: mismatched types
125
- //[classic ]~| cannot match inherited `&` with `&mut` pattern
124
+ //[classic2024 ]~^ ERROR: mismatched types
125
+ //[classic2024 ]~| cannot match inherited `&` with `&mut` pattern
126
126
let _: u32 = x;
127
127
128
128
let [ & mut & ref x] = & [ & mut 0 ] ;
129
- //[classic ]~^ ERROR: mismatched types
130
- //[classic ]~| cannot match inherited `&` with `&mut` pattern
129
+ //[classic2024 ]~^ ERROR: mismatched types
130
+ //[classic2024 ]~| cannot match inherited `&` with `&mut` pattern
131
131
let _: & u32 = x;
132
132
133
133
let [ & mut & ( mut x) ] = & [ & mut 0 ] ;
134
- //[classic ]~^ ERROR: mismatched types
135
- //[classic ]~| cannot match inherited `&` with `&mut` pattern
134
+ //[classic2024 ]~^ ERROR: mismatched types
135
+ //[classic2024 ]~| cannot match inherited `&` with `&mut` pattern
136
136
let _: u32 = x;
137
137
}
0 commit comments