Skip to content

Commit 49945a0

Browse files
committed
---
yaml --- r: 272854 b: refs/heads/beta c: cfe4efd h: refs/heads/master
1 parent 803e120 commit 49945a0

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
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: d5b6599ab64b2e44d2fe13eea884e2369ffdaa47
26+
refs/heads/beta: cfe4efd0523cd8106b20ba732f7d7677548f8157
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/librustc/middle/liveness.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,11 +1086,17 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
10861086
}
10871087

10881088
hir::ExprAssignOp(_, ref l, ref r) => {
1089-
// see comment on lvalues in
1090-
// propagate_through_lvalue_components()
1091-
let succ = self.write_lvalue(&l, succ, ACC_WRITE|ACC_READ);
1092-
let succ = self.propagate_through_expr(&r, succ);
1093-
self.propagate_through_lvalue_components(&l, succ)
1089+
// an overloaded assign op is like a method call
1090+
if self.ir.tcx.is_method_call(expr.id) {
1091+
let succ = self.propagate_through_expr(&l, succ);
1092+
self.propagate_through_expr(&r, succ)
1093+
} else {
1094+
// see comment on lvalues in
1095+
// propagate_through_lvalue_components()
1096+
let succ = self.write_lvalue(&l, succ, ACC_WRITE|ACC_READ);
1097+
let succ = self.propagate_through_expr(&r, succ);
1098+
self.propagate_through_lvalue_components(&l, succ)
1099+
}
10941100
}
10951101

10961102
// Uninteresting cases: just propagate in rev exec order

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,5 +127,24 @@ fn f6() {
127127
}) += 1;
128128
}
129129

130+
131+
struct MutRef<'a>(&'a mut i32);
132+
133+
impl<'a> AddAssign<i32> for MutRef<'a> {
134+
fn add_assign(&mut self, rhs: i32) {
135+
*self.0 += rhs;
136+
}
137+
}
138+
139+
fn f7() {
140+
let mut a = 1;
141+
{
142+
// `b` does not trigger unused_variables
143+
let mut b = MutRef(&mut a);
144+
b += 1;
145+
}
146+
drop(a);
147+
}
148+
130149
fn main() {
131150
}

0 commit comments

Comments
 (0)