Skip to content

Commit ce1c5e0

Browse files
committed
add negative test case in assignment-expected-bool
1 parent 0b9c589 commit ce1c5e0

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/test/ui/type/type-check/assignment-expected-bool.rs

+5
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,9 @@ fn main() {
2626
let _ = (0 = 0) //~ ERROR mismatched types [E0308]
2727
&& { 0 = 0 } //~ ERROR mismatched types [E0308]
2828
|| (0 = 0); //~ ERROR mismatched types [E0308]
29+
30+
// A test to check that not expecting `bool` behaves well:
31+
let _: usize = 0 = 0;
32+
//~^ ERROR mismatched types [E0308]
33+
//~| ERROR invalid left-hand side expression [E0070]
2934
}

src/test/ui/type/type-check/assignment-expected-bool.stderr

+18-2
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,22 @@ LL | || (0 = 0);
130130
= note: expected type `bool`
131131
found type `()`
132132

133-
error: aborting due to 11 previous errors
133+
error[E0070]: invalid left-hand side expression
134+
--> $DIR/assignment-expected-bool.rs:31:20
135+
|
136+
LL | let _: usize = 0 = 0;
137+
| ^^^^^ left-hand of expression not valid
138+
139+
error[E0308]: mismatched types
140+
--> $DIR/assignment-expected-bool.rs:31:20
141+
|
142+
LL | let _: usize = 0 = 0;
143+
| ^^^^^ expected usize, found ()
144+
|
145+
= note: expected type `usize`
146+
found type `()`
147+
148+
error: aborting due to 13 previous errors
134149

135-
For more information about this error, try `rustc --explain E0308`.
150+
Some errors occurred: E0070, E0308.
151+
For more information about an error, try `rustc --explain E0070`.

0 commit comments

Comments
 (0)