Skip to content

Error showing cannot mutate immutable variable even though it complies #17448

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

Closed
DE0CH opened this issue Jun 18, 2024 · 1 comment
Closed

Error showing cannot mutate immutable variable even though it complies #17448

DE0CH opened this issue Jun 18, 2024 · 1 comment
Labels
A-hygiene A-ty type system / type inference / traits / method resolution C-bug Category: bug

Comments

@DE0CH
Copy link

DE0CH commented Jun 18, 2024

rust-analyzer version: rust-analyzer version: 0.3.2002-standalone [/home/codespace/.vscode-remote/extensions/rust-lang.rust-analyzer-0.3.2002-linux-x64/server/rust-analyzer]

rustc version: rustc 1.79.0 (129f3b996 2024-06-10)

editor or extension: VSCode. I uninstalled all other extensions and the bug is still there.

relevant settings: I am using the stock codespaces image (Ubuntu) mcr.microsoft.com/devcontainers/universal:2, with rust installed with the installation script.

repository link (if public, optional): The original bug appeared in my project here, but I have a minimal reproducable example below

code snippet to reproduce:

use itertools::izip;

fn main() {
    let mut yp_sn = vec![0;5];
    let yp = vec![0;5];
    let x = vec![0;5];
    for (x, yp_sn, _yp) in izip!(x, yp_sn.iter_mut(), yp) {
        *yp_sn = x;
    }
}

rust analyzer shows that cannot mutate immutable variable `yp_sn` , but I can compile successfully with cargo build. If I add mut yp_sn, it shows a warning that the variable does not need to be mutable.

@DE0CH DE0CH added the C-bug Category: bug label Jun 18, 2024
@lnicola lnicola added A-ty type system / type inference / traits / method resolution A-hygiene labels Jun 18, 2024
@roife
Copy link
Member

roife commented Jun 20, 2024

Duplicate of #11681

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-hygiene A-ty type system / type inference / traits / method resolution C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

3 participants