Closed
Description
Sounds cryptic, I know, sorry for that. Here's what's going on:
fn main() {
let foo = 1;
// works as expected
let bar = match foo {
1 => 2,
_ => 3,
} as u8;
// error: expected expression, found keyword `as`
let bar = {
match foo {
1 => 2,
_ => 3,
} as u8
};
// but this works
let bar = {
(match foo {
1 => 2,
_ => 3,
}) as u8
};
// and also this
let bar = {
1 as u8
};
}
Meta
rustc --version --verbose
:
This is present since at least stable-1.19, but here I rustup update
d just to be sure:
rustc 1.21.0 (3b72af97e 2017-10-09)
binary: rustc
commit-hash: 3b72af97e42989b2fe104d8edbaee123cdf7c58f
commit-date: 2017-10-09
host: x86_64-unknown-linux-gnu
release: 1.21.0
LLVM version: 4.0
rustc 1.23.0-nightly (bd0e45a32 2017-11-06)
binary: rustc
commit-hash: bd0e45a323f85a1940d997ac237023c00670da67
commit-date: 2017-11-06
host: x86_64-unknown-linux-gnu
release: 1.23.0-nightly
LLVM version: 4.0
Metadata
Metadata
Assignees
Labels
No labels