Open
Description
I tried this code:
let [a] = &[()];
let [mut b] = &[()];
b = a;
I expected to see this happen: the mutable binding b
has type &()
, and thus the compilation succeeds without any error.
Instead, this happened: the mutable binding b
has type ()
, and the compilation fails with error:
error[E0308]: mismatched types
--> src\lib.rs:80:9
|
79 | let [mut b] = &[()];
| ----- expected due to the type of this binding
80 | b = a;
| ^ expected `()`, found `&()`
|
help: consider dereferencing the borrow
|
80 | b = *a;
| +
Meta
rustc --version --verbose
:
rustc 1.68.0-nightly (37d7de337 2022-12-12)
binary: rustc
commit-hash: 37d7de337903a558dbeb1e82c844fe915ab8ff25
commit-date: 2022-12-12
host: x86_64-pc-windows-msvc
release: 1.68.0-nightly
LLVM version: 15.0.6