Closed
Description
#![feature(augmented_assignments, op_assign_traits)]
use std::ops::AddAssign;
struct MutRef<'a>(&'a mut i32);
impl<'a> AddAssign<i32> for MutRef<'a> {
fn add_assign(&mut self, rhs: i32) {
*self.0 += rhs;
}
}
fn main() {
let mut a = 1;
{
let mut b = MutRef(&mut a);
b += 1;
}
println!("{}", a);
}
reads the variable b
by calling its AddAssign
implementation. However, the warning still triggers. If you expand b.add_assign(1)
manually, there is no warning.
cc @bluss. Found by "jatentaki" on IRC.