I tried the following code:
#![allow(incomplete_features)]
#![allow(unused)]
#![feature(inline_const)]
#[repr(u8)]
enum Foo {
Bar,
Baz,
Qux
}
fn main() {
let x = const { Foo::Bar as u8 };
// 0
println!("{}", x);
let bytes = [0, 4, 3];
// Yes
match bytes[0] {
const { Foo::Bar as u8 } => println!("Yes"),
const { Foo::Baz as u8 } | const { Foo::Qux as u8 } => println!("No!"),
_ => panic!("not a valid Foo!")
}
}
rustc (1.50.0-nightly (2225ee1 2020-12-11)) successfully compiles this, producing no warnings. Running the produced binary yields the expected output:
However, rust-analyzer (2020-11-16 (e8c8039), I was not able to install the nightly version) believes that the const blocks are syntax errors:


I understand if this is expected behaviour since inline_const is an incomplete/unstable feature.
I tried the following code:
rustc (1.50.0-nightly (2225ee1 2020-12-11)) successfully compiles this, producing no warnings. Running the produced binary yields the expected output:
However, rust-analyzer (2020-11-16 (e8c8039), I was not able to install the nightly version) believes that the


constblocks are syntax errors:I understand if this is expected behaviour since
inline_constis an incomplete/unstable feature.