Skip to content

Commit fc6193e

Browse files
diannejoshtriplett
andauthored
additional tests for is expressions' lexical scope
Co-authored-by: Josh Triplett <[email protected]>
1 parent d9cfd3e commit fc6193e

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

tests/ui/rfcs/rfc-3573-is/name-resolution-errors.rs

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,63 @@ fn main() {
1111
&& x
1212
{
1313
x;
14+
} else {
15+
x; //~ ERROR cannot find value `x` in this scope
1416
}
1517
x; //~ ERROR cannot find value `x` in this scope
1618

1719
// Elsewhere, `is`'s bindings only extend to the end of its `&&`-chain.
1820
if x //~ ERROR cannot find value `x` in this scope
19-
&& (is!(true is x) && x)
21+
&& (is!(true is x) && x && { x })
2022
&& x //~ ERROR cannot find value `x` in this scope
2123
&& (is!(true is x) || x) //~ ERROR cannot find value `x` in this scope
24+
&& (!is!(true is x) || x) //~ ERROR cannot find value `x` in this scope
25+
&& (is!(true is x) & x) //~ ERROR cannot find value `x` in this scope
2226
{
2327
x; //~ ERROR cannot find value `x` in this scope
2428
}
29+
30+
match is!(true is x) {
31+
_ => { x; } //~ ERROR cannot find value `x` in this scope
32+
}
33+
34+
match () {
35+
() if is!(true is x) && x => { x; }
36+
() if x => {} //~ ERROR cannot find value `x` in this scope
37+
}
38+
39+
match () {
40+
() if is!(true is x) && x => { x; }
41+
() => { x; } //~ ERROR cannot find value `x` in this scope
42+
}
43+
44+
fn f(_a: bool, _b: bool) {}
45+
f(is!(true is x) && x, true);
46+
f(is!(true is x), x); //~ ERROR cannot find value `x` in this scope
47+
f(is!(true is x) && x, x); //~ ERROR cannot find value `x` in this scope
48+
49+
if !is!(true is x) {
50+
x; //~ ERROR cannot find value `x` in this scope
51+
} else {
52+
x; //~ ERROR cannot find value `x` in this scope
53+
}
54+
55+
if true
56+
&& if is!(true is x) && x { x } else { false }
57+
&& x //~ ERROR cannot find value `x` in this scope
58+
{
59+
x; //~ ERROR cannot find value `x` in this scope
60+
}
61+
62+
while is!(true is x) {
63+
x;
64+
break;
65+
}
66+
x; //~ ERROR cannot find value `x` in this scope
67+
68+
true is x;
69+
x; //~ ERROR cannot find value `x` in this scope
70+
2571
is!(true is x);
2672
x; //~ ERROR cannot find value `x` in this scope
2773
}

0 commit comments

Comments
 (0)