Skip to content

NLL: E0594 removes first char of variable name #51515

Closed
@ashtneoi

Description

@ashtneoi

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

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.NLL-diagnosticsWorking towards the "diagnostic parity" goalT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions