about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorashtneoi <ashtneoi@gmail.com>2018-07-09 13:16:02 -0700
committerashtneoi <ashtneoi@gmail.com>2018-07-09 13:16:02 -0700
commita49b75d2f342f5904d89f34f46dfd621c20da7f7 (patch)
tree8beb7d36e73efd3bab72ac509f7803b45baa6521 /src
parentc6807bb1b282e0c5398aa4e659dbc165b6f3c81b (diff)
downloadrust-a49b75d2f342f5904d89f34f46dfd621c20da7f7.tar.gz
rust-a49b75d2f342f5904d89f34f46dfd621c20da7f7.zip
Add test case from issue #51515
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/suggestions/issue-51515.rs18
-rw-r--r--src/test/ui/suggestions/issue-51515.stderr17
2 files changed, 35 insertions, 0 deletions
diff --git a/src/test/ui/suggestions/issue-51515.rs b/src/test/ui/suggestions/issue-51515.rs
new file mode 100644
index 00000000000..b5bbf48ddfa
--- /dev/null
+++ b/src/test/ui/suggestions/issue-51515.rs
@@ -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;
+}
diff --git a/src/test/ui/suggestions/issue-51515.stderr b/src/test/ui/suggestions/issue-51515.stderr
new file mode 100644
index 00000000000..7cdbef1badc
--- /dev/null
+++ b/src/test/ui/suggestions/issue-51515.stderr
@@ -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`.