Why can the following code compile and run successfully, but the VS Code Rust Analyzer extension reports an error?
⚓ Rust 📅 2026-07-16 👤 surdeus 👁️ 1I am a Rust beginner. here is the complete code:
fn main() {
let (x, y);
(x, ..) = (3, 4);
[.., y] = [1, 2];
// Fill in the blank to make the code work
assert_eq!([x, y], [3, 2]);
}
Why does
[.., y] = [1, 2];
error: pattern requires 1 element but array has 2
rust-analyzer E0527
4 posts - 4 participants
🏷️ Rust_feed