about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-01-27 04:57:12 +0000
committerbors <bors@rust-lang.org>2017-01-27 04:57:12 +0000
commit025fb7de09dfcf5fbc19c5d1b6bed168ac987e6c (patch)
tree16fd6bd271c0f77f1c677eef4b9fb7c77235b5b4 /src/libstd
parent23a94697c2fa67ec750a8fc09b2e86213b5e0af1 (diff)
parente1280d81af3101d918fcd1ff9ca040b59e7d907b (diff)
downloadrust-025fb7de09dfcf5fbc19c5d1b6bed168ac987e6c.tar.gz
rust-025fb7de09dfcf5fbc19c5d1b6bed168ac987e6c.zip
Auto merge of #39139 - estebank:issue-38147, r=nikomatsakis
Point to immutable arg/fields when trying to use as &mut

Present the following output when trying to access an immutable borrow's
field as mutable:

```
error[E0389]: cannot borrow data mutably in a `&` reference
  --> $DIR/issue-38147-1.rs:27:9
   |
26 | fn f(&self) {
   |      -----  use `&mut self` here to make mutable
27 |     f.s.push('x');
   |     ^^^ assignment into an immutable reference
```

And the following when trying to access an immutable struct field as mutable:

```
error: cannot borrow immutable borrowed content `*self.s` as mutable
  --> $DIR/issue-38147-3.rs:17:9
   |
12 |     s: &'a String
   |     ------------- use `&'a mut String` here to make mutable
...|
16 |     fn f(&self) {
   |          -----  use `&mut self` here to make mutable
17 |         self.s.push('x');
   |         ^^^^^^ cannot borrow as mutable
```

Fixes #38147.
Diffstat (limited to 'src/libstd')
0 files changed, 0 insertions, 0 deletions