File tree Expand file tree Collapse file tree 2 files changed +123
-54
lines changed
src/test/ui/rfc-2497-if-let-chains Expand file tree Collapse file tree 2 files changed +123
-54
lines changed Original file line number Diff line number Diff line change 17
17
//
18
18
// To that end, we check some positions which is not part of the language above.
19
19
20
+ #![ feature( const_generics) ] //~ WARN the feature `const_generics` is incomplete
21
+
20
22
#![ allow( irrefutable_let_patterns) ]
21
23
22
24
use std:: ops:: Range ;
@@ -157,3 +159,31 @@ fn outside_if_and_while_expr() {
157
159
& let 0 = 0
158
160
//~^ ERROR `let` expressions are not supported here
159
161
}
162
+
163
+ // Let's make sure that `let` inside const generic arguments are considered.
164
+ fn inside_const_generic_arguments ( ) {
165
+ struct A < const B : bool > ;
166
+ impl < const B : bool > A < { B } > { const O : u32 = 5 ; }
167
+
168
+ if let A :: < {
169
+ true && let 1 = 1 //~ ERROR `let` expressions are not supported here
170
+ } > :: O = 5 { }
171
+
172
+ while let A :: < {
173
+ true && let 1 = 1 //~ ERROR `let` expressions are not supported here
174
+ } > :: O = 5 { }
175
+
176
+ if A :: < {
177
+ true && let 1 = 1 //~ ERROR `let` expressions are not supported here
178
+ } > :: O == 5 { }
179
+
180
+ // In the cases above we have `ExprKind::Block` to help us out.
181
+ // Below however, we would not have a block and so an implementation might go
182
+ // from visiting expressions to types without banning `let` expressions down the tree.
183
+ // This tests ensures that we are not caught by surprise should the parser
184
+ // admit non-IDENT expressions in const generic arguments.
185
+
186
+ if A :: <
187
+ true && let 1 = 1 //~ ERROR expected one of `,` or `>`, found `&&`
188
+ >:: O == 5 { }
189
+ }
You can’t perform that action at this time.
0 commit comments