Rust-GCC / Rust-GCC/gccrs

Readonly check for tuple

Open
#3,893 1 comment 0 reactions 1 assignee View on GitHub

@sakupan102 is already working on this.

Since Jul 11, 2025.

Dominant language
C++
Stars
2.9k
Forks
231
Avg merge
20h 2m
Merged PRs (30d)
66

Description

Reproducer

I tried this code:

fn main() {
    let a = 1;
    let b = 2;
    (a, b) = (b, a);
}
Does the code make use of any (1.49) nightly feature ?
  • Nightly
Godbolt link

No response

Actual behavior

It does not emit an error

Expected behavior

I expected to see...

error[E0384]: cannot assign twice to immutable variable `a`
  --> <source>:15:6
   |
13 |     let a = 1;
   |         - first assignment to `a`
14 |     let b = 2;
15 |     (a, b) = (b, a);
   |      ^ cannot assign twice to immutable variable
   |
help: consider making this binding mutable
   |
13 |     let mut a = 1;
   |         +++

error[E0384]: cannot assign twice to immutable variable `b`
  --> <source>:15:9
   |
14 |     let b = 2;
   |         - first assignment to `b`
15 |     (a, b) = (b, a);
   |         ^ cannot assign twice to immutable variable
   |
help: consider making this binding mutable
   |
14 |     let mut b = 2;
   |         +++

GCC Version

508b195

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.