about summary refs log tree commit diff
diff options
context:
space:
mode:
authorashtneoi <ashtneoi@gmail.com>2018-07-11 03:45:25 -0700
committerashtneoi <ashtneoi@gmail.com>2018-07-12 22:51:30 -0700
commit77d5f397716778fcc82a60ea9d6102c0cfea15f6 (patch)
tree86107665565e61e353fb17d89c4990fbb2e6007a
parent73a979ad63ea20821996809aaccb82767ac84658 (diff)
downloadrust-77d5f397716778fcc82a60ea9d6102c0cfea15f6.tar.gz
rust-77d5f397716778fcc82a60ea9d6102c0cfea15f6.zip
Also test `&mut self` suggestion
-rw-r--r--src/test/ui/suggestions/suggest-ref-mut.rs11
-rw-r--r--src/test/ui/suggestions/suggest-ref-mut.stderr17
2 files changed, 24 insertions, 4 deletions
diff --git a/src/test/ui/suggestions/suggest-ref-mut.rs b/src/test/ui/suggestions/suggest-ref-mut.rs
index 1f5c5b03328..30b5371af1a 100644
--- a/src/test/ui/suggestions/suggest-ref-mut.rs
+++ b/src/test/ui/suggestions/suggest-ref-mut.rs
@@ -10,6 +10,17 @@
 
 #![feature(nll)]
 
+struct X(usize);
+
+impl X {
+    fn zap(&self) {
+        //~^ HELP
+        //~| SUGGESTION &mut self
+        self.0 = 32;
+        //~^ ERROR
+    }
+}
+
 fn main() {
     let ref foo = 16;
     //~^ HELP
diff --git a/src/test/ui/suggestions/suggest-ref-mut.stderr b/src/test/ui/suggestions/suggest-ref-mut.stderr
index d1590b3934e..0b2b240ef53 100644
--- a/src/test/ui/suggestions/suggest-ref-mut.stderr
+++ b/src/test/ui/suggestions/suggest-ref-mut.stderr
@@ -1,5 +1,14 @@
+error[E0594]: cannot assign to `self.0` which is behind a `&` reference
+  --> $DIR/suggest-ref-mut.rs:19:9
+   |
+LL |     fn zap(&self) {
+   |            ----- help: consider changing this to be a mutable reference: `&mut self`
+...
+LL |         self.0 = 32;
+   |         ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written
+
 error[E0594]: cannot assign to `*foo` which is behind a `&` reference
-  --> $DIR/suggest-ref-mut.rs:17:5
+  --> $DIR/suggest-ref-mut.rs:28:5
    |
 LL |     let ref foo = 16;
    |         ------- help: consider changing this to be a mutable reference: `ref mut foo`
@@ -8,7 +17,7 @@ LL |     *foo = 32;
    |     ^^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be written
 
 error[E0594]: cannot assign to `*bar` which is behind a `&` reference
-  --> $DIR/suggest-ref-mut.rs:22:9
+  --> $DIR/suggest-ref-mut.rs:33:9
    |
 LL |     if let Some(ref bar) = Some(16) {
    |                 ------- help: consider changing this to be a mutable reference: `ref mut bar`
@@ -17,13 +26,13 @@ LL |         *bar = 32;
    |         ^^^^^^^^^ `bar` is a `&` reference, so the data it refers to cannot be written
 
 error[E0594]: cannot assign to `*quo` which is behind a `&` reference
-  --> $DIR/suggest-ref-mut.rs:26:22
+  --> $DIR/suggest-ref-mut.rs:37:22
    |
 LL |         ref quo => { *quo = 32; },
    |         -------      ^^^^^^^^^ `quo` is a `&` reference, so the data it refers to cannot be written
    |         |
    |         help: consider changing this to be a mutable reference: `ref mut quo`
 
-error: aborting due to 3 previous errors
+error: aborting due to 4 previous errors
 
 For more information about this error, try `rustc --explain E0594`.