2 #![deny(unused_variables)]
3 #![deny(unused_assignments)]
4 #![allow(dead_code, non_camel_case_types, trivial_numeric_casts)]
6 use std::ops::AddAssign;
9 //~^ ERROR unused variable: `x`
12 fn f1b(x: &mut isize) {
13 //~^ ERROR unused variable: `x`
16 #[allow(unused_variables)]
21 //~^ ERROR unused variable: `x`
26 //~^ ERROR unused variable: `x`
31 //~^ ERROR variable `x` is assigned to, but never used
33 //~^ ERROR value assigned to `x` is never read
38 //~^ ERROR variable `z` is assigned to, but never used
44 #[allow(unused_variables)]
50 #[allow(unused_variables)]
51 #[allow(unused_assignments)]
60 //~^ ERROR unused variable: `i`
67 a(isize), b(isize), c(isize)
72 tri::a(i) | tri::b(i) | tri::c(i) => {
80 //~^ ERROR unused variable: `x`
84 for (x, _) in [1, 2, 3].iter().enumerate() { }
85 //~^ ERROR unused variable: `x`
89 for (_, x) in [1, 2, 3].iter().enumerate() {
90 //~^ ERROR unused variable: `x`
92 drop(*x as i32); //~ WARNING unreachable statement
96 struct View<'a>(&'a mut [i32]);
98 impl<'a> AddAssign<i32> for View<'a> {
99 fn add_assign(&mut self, rhs: i32) {
100 for lhs in self.0.iter_mut() {
107 let mut array = [1, 2, 3];
108 let mut v = View(&mut array);
110 // ensure an error shows up for x even if lhs of an overloaded add assign
113 //~^ ERROR variable `x` is assigned to, but never used
116 x = 0; //~ ERROR value assigned to `x` is never read
122 struct MutRef<'a>(&'a mut i32);
124 impl<'a> AddAssign<i32> for MutRef<'a> {
125 fn add_assign(&mut self, rhs: i32) {
133 // `b` does not trigger unused_variables
134 let mut b = MutRef(&mut a);