rust-analyzer version: 0.3.1229-standalone (5c28ad1 2022-10-01) and 0.4.1236-standalone (61504c8 2022-10-08)
rustc version: 1.64.0 (a55dd71d5 2022-09-19)
relevant settings: N/A
RA emits an error for the following code when feature is disabled:
fn main() {
#[cfg(feature = "feature")]
my_fn(0, MyStruct(0));
#[cfg(not(feature = "feature"))]
my_fn(MyStruct(0));
}
struct MyStruct(u8);
impl MyStruct {
fn get_mut(&mut self) -> &mut u8 {
let MyStruct(val) = self;
val
}
}
fn immutable(_: &u8) {}
fn mutable(_: &mut u8) {}
fn my_fn(#[cfg(feature = "feature")] _: u8, mut my_struct: MyStruct) {
let val = my_struct.get_mut();
immutable(val);
mutable(val); // expected &mut u8, found &u8 rust-analyzer(type-mismatch)
}
However, it complies fine via cargo run
Thank you!