Skip to content

Commit f19fc49

Browse files
committed
Add run-pass test and fix failing test
1 parent 5294992 commit f19fc49

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// run-pass
2+
3+
#![allow(incomplete_features)]
4+
#![feature(inline_const)]
5+
6+
fn if_let_1() -> i32 {
7+
let x = 2;
8+
const Y: i32 = 3;
9+
10+
if let const { (Y + 1) / 2 } = x {
11+
x
12+
} else {
13+
0
14+
}
15+
}
16+
17+
fn if_let_2() -> i32 {
18+
let x = 2;
19+
20+
if let const { 1 + 2 } = x {
21+
const { 1 + 2 }
22+
} else {
23+
0
24+
}
25+
}
26+
27+
fn main() {
28+
assert_eq!(if_let_1(), 2);
29+
assert_eq!(if_let_2(), 0);
30+
}
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// This file was auto-generated using 'src/etc/generate-keyword-tests.py const'
2-
31
fn main() {
4-
let const = "foo"; //~ error: expected identifier, found keyword `const`
2+
let const = "foo"; //~ ERROR expected `{`, found `=`
53
}

src/test/ui/parser/keyword-const-as-identifier.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: expected `{`, found `=`
2-
--> $DIR/keyword-const-as-identifier.rs:4:15
2+
--> $DIR/keyword-const-as-identifier.rs:2:15
33
|
44
LL | let const = "foo";
55
| ^ expected `{`

0 commit comments

Comments
 (0)