-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.
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.
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.