Readonly check for tuple
Open
@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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.