File tree 2 files changed +35
-0
lines changed
2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ #![ feature( nll) ]
12
+
13
+ fn main ( ) {
14
+ let foo = & 16 ;
15
+ * foo = 32 ;
16
+ let bar = foo;
17
+ * bar = 64 ;
18
+ }
Original file line number Diff line number Diff line change
1
+ error[E0594]: cannot assign to `*foo` which is behind a `&` reference
2
+ --> $DIR/issue-51515.rs:15:5
3
+ |
4
+ LL | let foo = &16;
5
+ | --- help: consider changing this to be a mutable reference: `&mut 16`
6
+ LL | *foo = 32;
7
+ | ^^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be written
8
+
9
+ error[E0594]: cannot assign to `*bar` which is behind a `&` reference
10
+ --> $DIR/issue-51515.rs:17:5
11
+ |
12
+ LL | *bar = 64;
13
+ | ^^^^^^^^^ `bar` is a `&` reference, so the data it refers to cannot be written
14
+
15
+ error: aborting due to 2 previous errors
16
+
17
+ For more information about this error, try `rustc --explain E0594`.
You can’t perform that action at this time.
0 commit comments