Closed
Description
When I build this code on nightly...
#![feature(nll)]
fn main() {
let foo = &16;
*foo = 32;
let bar = foo;
*bar = 64;
}
...I get these errors:
error[E0594]: cannot assign to data in a `&` reference
--> src/main.rs:5:5
|
4 | let foo = &16;
| --- help: consider changing this to be a mutable reference: `&mut 16`
5 | *foo = 32;
| ^^^^^^^^^
error[E0594]: cannot assign to data in a `&` reference
--> src/main.rs:7:5
|
6 | let bar = foo;
| --- help: consider changing this to be a mutable reference: `&mut oo`
7 | *bar = 64;
| ^^^^^^^^^
The first error is fine, but the second one is missing the first character of foo
. It looks like rustc assumes the first character is an &
and removes it without checking.
Meta
rustc --version --verbose
:
rustc 1.28.0-nightly (1d4dbf488 2018-06-11)
binary: rustc
commit-hash: 1d4dbf488a4364413e7b9611866b7a5c75ce566f
commit-date: 2018-06-11
host: x86_64-unknown-linux-gnu
release: 1.28.0-nightly
LLVM version: 6.0