33
44use std:: ptr:: NonNull ;
55
6- // Should only warn for `s`.
76fn foo ( s : & mut Vec < u32 > , b : & u32 , x : & mut u32 ) {
7+ //~^ ERROR: this argument is a mutable reference, but not used mutably
88 * x += * b + s. len ( ) as u32 ;
99}
1010
@@ -28,8 +28,9 @@ fn foo5(s: &mut Vec<u32>) {
2828 foo2 ( s) ;
2929}
3030
31- // Should warn.
31+
3232fn foo6 ( s : & mut Vec < u32 > ) {
33+ //~^ ERROR: this argument is a mutable reference, but not used mutably
3334 non_mut_ref ( s) ;
3435}
3536
@@ -41,13 +42,13 @@ impl Bar {
4142 // Should not warn on `&mut self`.
4243 fn bar ( & mut self ) { }
4344
44- // Should warn about `vec`
4545 fn mushroom ( & self , vec : & mut Vec < i32 > ) -> usize {
46+ //~^ ERROR: this argument is a mutable reference, but not used mutably
4647 vec. len ( )
4748 }
4849
49- // Should warn about `vec` (and not `self`).
5050 fn badger ( & mut self , vec : & mut Vec < i32 > ) -> usize {
51+ //~^ ERROR: this argument is a mutable reference, but not used mutably
5152 vec. len ( )
5253 }
5354}
@@ -123,36 +124,36 @@ async fn f7(x: &mut i32, y: i32, z: &mut i32, a: i32) {
123124 * z += 1 ;
124125}
125126
126- // Should warn.
127127async fn a1 ( x : & mut i32 ) {
128+ //~^ ERROR: this argument is a mutable reference, but not used mutably
128129 println ! ( "{:?}" , x) ;
129130}
130- // Should warn.
131131async fn a2 ( x : & mut i32 , y : String ) {
132+ //~^ ERROR: this argument is a mutable reference, but not used mutably
132133 println ! ( "{:?}" , x) ;
133134}
134- // Should warn.
135135async fn a3 ( x : & mut i32 , y : String , z : String ) {
136+ //~^ ERROR: this argument is a mutable reference, but not used mutably
136137 println ! ( "{:?}" , x) ;
137138}
138- // Should warn.
139139async fn a4 ( x : & mut i32 , y : i32 ) {
140+ //~^ ERROR: this argument is a mutable reference, but not used mutably
140141 println ! ( "{:?}" , x) ;
141142}
142- // Should warn.
143143async fn a5 ( x : i32 , y : & mut i32 ) {
144+ //~^ ERROR: this argument is a mutable reference, but not used mutably
144145 println ! ( "{:?}" , x) ;
145146}
146- // Should warn.
147147async fn a6 ( x : i32 , y : & mut i32 ) {
148+ //~^ ERROR: this argument is a mutable reference, but not used mutably
148149 println ! ( "{:?}" , x) ;
149150}
150- // Should warn.
151151async fn a7 ( x : i32 , y : i32 , z : & mut i32 ) {
152+ //~^ ERROR: this argument is a mutable reference, but not used mutably
152153 println ! ( "{:?}" , z) ;
153154}
154- // Should warn.
155155async fn a8 ( x : i32 , a : & mut i32 , y : i32 , z : & mut i32 ) {
156+ //~^ ERROR: this argument is a mutable reference, but not used mutably
156157 println ! ( "{:?}" , z) ;
157158}
158159
@@ -185,13 +186,15 @@ fn used_as_path(s: &mut u32) {}
185186fn lint_attr ( s : & mut u32 ) { }
186187
187188#[ cfg( not( feature = "a" ) ) ]
188- // Should warn with note.
189189fn cfg_warn ( s : & mut u32 ) { }
190+ //~^ ERROR: this argument is a mutable reference, but not used mutably
191+ //~| NOTE: this is cfg-gated and may require further changes
190192
191193#[ cfg( not( feature = "a" ) ) ]
192194mod foo {
193- // Should warn with note.
194195 fn cfg_warn ( s : & mut u32 ) { }
196+ //~^ ERROR: this argument is a mutable reference, but not used mutably
197+ //~| NOTE: this is cfg-gated and may require further changes
195198}
196199
197200fn main ( ) {
0 commit comments