Wrong errors reported: expected Expr
rust-analyzer version: rust-analyzer version: 0.3.1995-standalone (c86d6230f 2024-06-10) [/Users/Philip/.vscode/extensions/rust-lang.rust-analyzer-0.3.1995-darwin-x64/server/rust-analyzer]
rustc version: rustc 1.58.1 (db9d1b20b 2022-01-20)
editor or extension: VSCode, v0.3.1995
relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)
repository link (if public, optional): https://github.com/yipu3/algorithm-practice/tree/main/leetcode/502/rust
code snippet to reproduce:
use std::collections::BinaryHeap;
#[derive(Debug)]
struct Project {
profit: i32,
capital: i32,
}
pub fn find_maximized_capital(k: i32, w: i32, profits: Vec<i32>, capital: Vec<i32>) -> i32 {
let mut projects = Vec::new();
for i in 0..profits.len() {
projects.push(Project {
profit: profits[i],
capital: capital[i],
});
}
projects.sort_by(|a, b| a.capital.cmp(&b.capital));
// println!("{:?}", projects);
let mut w = w;
let mut h = BinaryHeap::new();
let mut c = 0;
let mut i = 0;
loop {
while i < projects.len() && projects[i].capital <= w {
h.push(projects[i].profit);
i += 1;
}
if h.peek().is_none() {
break;
}
w += h.pop().unwrap();
c += 1;
if c == k {
break;
}
}
w
}
fn main() {
assert_eq!(
find_maximized_capital(2, 0, vec![1, 2, 3], vec![0, 1, 1]),
4
);
}
Your rustc version is very old compared to the rust-analyzer releases so its likely to fail because of that given the error is within a standard library macro. Either upgrade your rust toolchain or downgrade your rust-analyzer, we generally dont support more than the ~2 latest stable releases for a given rust-analyzer version
I also have this issue on the latest version of rust / nightly release of rust-analyzer.
Cargo check / build reports no errors and if i restart rust analyzer the error disappears but then will reappear after some time.
I suspect its something to do with my macro, ill try make a smaller example
Why did you close the issue as complete it is still currently an issue. you can unsubscribe from the issue mailing list here
Why did you close the issue as complete it is still currently an issue. you can unsubscribe from the issue mailing list here
My problem has been solved by updating the rust version, suggested by the comment of Veykril. You can open a new issue providing details of your environment. That's more accurate and convenient. Thanks.
