summaryrefslogtreecommitdiffstats
path: root/src/test/ui/typeck/assign-non-lval-mut-ref.fixed
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/typeck/assign-non-lval-mut-ref.fixed')
-rw-r--r--src/test/ui/typeck/assign-non-lval-mut-ref.fixed15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/test/ui/typeck/assign-non-lval-mut-ref.fixed b/src/test/ui/typeck/assign-non-lval-mut-ref.fixed
new file mode 100644
index 000000000..10c7b9dbf
--- /dev/null
+++ b/src/test/ui/typeck/assign-non-lval-mut-ref.fixed
@@ -0,0 +1,15 @@
+// run-rustfix
+
+fn main() {
+ let mut x = vec![1usize];
+ *x.last_mut().unwrap() = 2;
+ //~^ ERROR invalid left-hand side of assignment
+ *x.last_mut().unwrap() += 1;
+ //~^ ERROR binary assignment operation `+=` cannot be applied to type `&mut usize`
+
+ let y = x.last_mut().unwrap();
+ *y = 2;
+ //~^ ERROR mismatched types
+ *y += 1;
+ //~^ ERROR binary assignment operation `+=` cannot be applied to type `&mut usize`
+}