forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test case from issue rust-lang#51515
- Loading branch information
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
#![feature(nll)] | ||
|
||
fn main() { | ||
let foo = &16; | ||
*foo = 32; | ||
let bar = foo; | ||
*bar = 64; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
error[E0594]: cannot assign to `*foo` which is behind a `&` reference | ||
--> $DIR/issue-51515.rs:15:5 | ||
| | ||
LL | let foo = &16; | ||
| --- help: consider changing this to be a mutable reference: `&mut 16` | ||
LL | *foo = 32; | ||
| ^^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be written | ||
|
||
error[E0594]: cannot assign to `*bar` which is behind a `&` reference | ||
--> $DIR/issue-51515.rs:17:5 | ||
| | ||
LL | *bar = 64; | ||
| ^^^^^^^^^ `bar` is a `&` reference, so the data it refers to cannot be written | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0594`. |