about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgaurikholkar <f2013002@goa.bits-pilani.ac.in>2018-03-11 00:25:23 +0530
committergaurikholkar <f2013002@goa.bits-pilani.ac.in>2018-03-11 00:25:23 +0530
commit50299c6491ade2dab9f2ccf1edd6ac9123f0697d (patch)
tree39328a49b901e5dd103187f3a3fe1fd802950a0f
parent55bd9148eb966691dd54c4afe03416acc62bb9b9 (diff)
downloadrust-50299c6491ade2dab9f2ccf1edd6ac9123f0697d.tar.gz
rust-50299c6491ade2dab9f2ccf1edd6ac9123f0697d.zip
add ui test for E0594
-rw-r--r--src/test/ui/nll/issue-47388.rs20
-rw-r--r--src/test/ui/nll/issue-47388.stderr11
2 files changed, 31 insertions, 0 deletions
diff --git a/src/test/ui/nll/issue-47388.rs b/src/test/ui/nll/issue-47388.rs
new file mode 100644
index 00000000000..683eec8f1bb
--- /dev/null
+++ b/src/test/ui/nll/issue-47388.rs
@@ -0,0 +1,20 @@
+// 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)]
+struct FancyNum {
+    num: u8,
+}
+
+fn main() {
+    let mut fancy = FancyNum{ num: 5 };
+    let fancy_ref = &(&mut fancy);
+    fancy_ref.num = 6;
+    println!("{}", fancy_ref.num);
+}
\ No newline at end of file
diff --git a/src/test/ui/nll/issue-47388.stderr b/src/test/ui/nll/issue-47388.stderr
new file mode 100644
index 00000000000..331836bebba
--- /dev/null
+++ b/src/test/ui/nll/issue-47388.stderr
@@ -0,0 +1,11 @@
+error[E0594]: cannot assign through `&`-reference `fancy_ref`
+  --> $DIR/issue-47388.rs:18:5
+   |
+LL |     let fancy_ref = &(&mut fancy);
+   |                     ------------- help: consider changing this to be a mutable reference: `&mut`
+LL |     fancy_ref.num = 6;
+   |     ^^^^^^^^^^^^^^^^^ cannot assign through `&`-reference
+
+error: aborting due to previous error
+
+If you want more information on this error, try using "rustc --explain E0594"