Skip to content

Commit 803e120

Browse files
committed
---
yaml --- r: 272853 b: refs/heads/beta c: d5b6599 h: refs/heads/master i: 272851: e483175
1 parent 0b3051e commit 803e120

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: a03222c2b16648c466f836d5eec425fc3c648aa4
26+
refs/heads/beta: d5b6599ab64b2e44d2fe13eea884e2369ffdaa47
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/test/compile-fail/liveness-unused.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#![deny(unused_assignments)]
1313
#![allow(dead_code, non_camel_case_types, trivial_numeric_casts)]
1414

15+
use std::ops::AddAssign;
16+
1517
fn f1(x: isize) {
1618
//~^ ERROR unused variable: `x`
1719
}
@@ -100,5 +102,30 @@ fn f5c() {
100102
}
101103
}
102104

105+
struct View<'a>(&'a mut [i32]);
106+
107+
impl<'a> AddAssign<i32> for View<'a> {
108+
fn add_assign(&mut self, rhs: i32) {
109+
for lhs in self.0.iter_mut() {
110+
*lhs += rhs;
111+
}
112+
}
113+
}
114+
115+
fn f6() {
116+
let mut array = [1, 2, 3];
117+
let mut v = View(&mut array);
118+
119+
// ensure an error shows up for x even if lhs of an overloaded add assign
120+
121+
let x;
122+
//~^ ERROR variable `x` is assigned to, but never used
123+
124+
*({
125+
x = 0; //~ ERROR value assigned to `x` is never read
126+
&mut v
127+
}) += 1;
128+
}
129+
103130
fn main() {
104131
}

0 commit comments

Comments
 (0)