Closed
Description
Type mismatch error messages involving integral expressions use the word "variable", when the problematic term is an expression.
I tried this code:
fn main() {
let f = if true {
()
} else {
1
};
}
I expected to see this happen:
<code sample that causes the bug>
error[E0308]: if and else have incompatible types
--> src/main.rs:2:13
|
2 | let f = if true {
| _____________^
3 | | ()
4 | | } else {
5 | | 1
6 | | };
| |_____^ expected (), found integral expression
|
= note: expected type `()`
found type `{integer}`
Instead, this happened:
<code sample that causes the bug>
error[E0308]: if and else have incompatible types
--> src/main.rs:2:13
|
2 | let f = if true {
| _____________^
3 | | ()
4 | | } else {
5 | | 1
6 | | };
| |_____^ expected (), found integral variable
|
= note: expected type `()`
found type `{integer}`
Meta
rustc --version --verbose
:
rustc 1.31.0-nightly (3e6f30ec3 2018-10-26)
binary: rustc
commit-hash: 3e6f30ec3e6bda159063fcd126dcb14725fef92d
commit-date: 2018-10-26
host: x86_64-apple-darwin
release: 1.31.0-nightly
LLVM version: 8.0
Backtrace: N/A