Commit Graph

6 Commits

Author SHA1 Message Date
Guillaume Gomez
998b19740c Add new error codes and update tests 2017-05-27 19:58:52 +02:00
Michael Kohl
5558c64f33 Change error count messages
See #33525 for details.
2017-05-24 16:14:38 +07:00
Esteban Küber
1ca1483113 Point at variable moved by closure 2017-04-25 22:03:05 -07:00
Wesley Wiser
94687aaf58 Removes FIXMEs related to #22405 2017-01-31 21:27:13 -05:00
Esteban Küber
e1280d81af Point to immutable arg/fields when trying to use as &mut
Point to immutable borrow arguments and fields when trying to use them as
mutable borrows. Add label to primary span on "cannot borrow as mutable"
errors.

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
```
2017-01-26 10:57:23 -08:00
Mikhail Modin
67a24c2e18 add hint to fix error for immutable ref in arg 2016-11-29 00:32:34 +03:00