mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 15:23:46 +00:00
add ui test for E0594
This commit is contained in:
parent
55bd9148eb
commit
50299c6491
20
src/test/ui/nll/issue-47388.rs
Normal file
20
src/test/ui/nll/issue-47388.rs
Normal 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);
|
||||
}
|
11
src/test/ui/nll/issue-47388.stderr
Normal file
11
src/test/ui/nll/issue-47388.stderr
Normal 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"
|
Loading…
Reference in New Issue
Block a user