-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Wrong "cannot mutate immutable variable array
(E0384)"
#15670
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can't reproduce this. Does it happen in a standalone project? Also your playground link is empty. |
Yeah, it doesn't even trigger for me on: fn repro<'a>(&'a self, idx: usize) {
let array = &mut self.array;
array[idx] = 1;
} nor on: fn repro<'a>(&'a self, idx: usize) {
let array = &self.array;
array[idx] = 1;
} |
Oh, I'm sorry: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=cc8b0dc5315b9bc75d6caa9e5faa85d4 |
Can't reproduce, does it still show up if you restart Code? |
I opened project where I reproduced it and now I can't 😐 |
I'm closing issue then xd |
First time I got it (at the time when i could still reproduce it) after I opened this folder in vscode: https://github.com/rust-in-action/code/blob/25f2e2277cbd527ab8bf5e8b68a17672215874f3/ch5/ch5-cpu3 rust-analyzer showed error on this line: https://github.com/rust-in-action/code/blob/19c4349758b57bdb233e186746bfec03ad9ea88d/ch5/ch5-cpu3/src/main.rs#L49 |
Then there is no issue xd |
Well, you seem to have one, but I have no idea why. |
Sorry for confusion, I can't reproduce it anymore either |
Maybe it was caching issue or something like that |
If it happens again, take a look at the Output panel, there are two RA channels there. Maybe you'll find something. |
I have encountered the same issue in some FFI code. code: pub struct A {}
pub unsafe fn foo(a: *mut A) {
let b = || -> *mut A { &mut *a };
let _ = b();
} playground link: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=6ac27c26e10eb46113dc10e88d939c60 |
This got closed by mistake, but feel free to open a new issue if needed, xxshady. |
rust-analyzer version: 0.4.1674-standalone (d3cc3bc 2023-09-25)
rustc version: 1.72.0 (5680fa18f 2023-08-23)
rust-analyzer complains about "immutable variable", but rustc compiles this code without issues
However this doesnt cause any issues:
The text was updated successfully, but these errors were encountered: