add ui test for E0594

This commit is contained in:
gaurikholkar 2018-03-11 00:25:23 +05:30
parent 55bd9148eb
commit 50299c6491
2 changed files with 31 additions and 0 deletions

View File

@ -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);
}

View File

@ -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"