From 50299c6491ade2dab9f2ccf1edd6ac9123f0697d Mon Sep 17 00:00:00 2001 From: gaurikholkar Date: Sun, 11 Mar 2018 00:25:23 +0530 Subject: [PATCH] add ui test for E0594 --- src/test/ui/nll/issue-47388.rs | 20 ++++++++++++++++++++ src/test/ui/nll/issue-47388.stderr | 11 +++++++++++ 2 files changed, 31 insertions(+) create mode 100644 src/test/ui/nll/issue-47388.rs create mode 100644 src/test/ui/nll/issue-47388.stderr diff --git a/src/test/ui/nll/issue-47388.rs b/src/test/ui/nll/issue-47388.rs new file mode 100644 index 000000000000..683eec8f1bbd --- /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 or the MIT license +// , 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 000000000000..331836bebbaa --- /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"