Use libtest errors check to better enforce UI testing

This commit is contained in:
Guillaume Gomez 2023-07-25 18:26:56 +02:00
parent 15de3dd2af
commit 04b710b569
2 changed files with 30 additions and 28 deletions

View File

@ -3,8 +3,8 @@
use std::ptr::NonNull;
// Should only warn for `s`.
fn foo(s: &mut Vec<u32>, b: &u32, x: &mut u32) {
//~^ ERROR: this argument is a mutable reference, but not used mutably
*x += *b + s.len() as u32;
}
@ -28,8 +28,8 @@ fn foo5(s: &mut Vec<u32>) {
foo2(s);
}
// Should warn.
fn foo6(s: &mut Vec<u32>) {
//~^ ERROR: this argument is a mutable reference, but not used mutably
non_mut_ref(s);
}
@ -41,13 +41,13 @@ impl Bar {
// Should not warn on `&mut self`.
fn bar(&mut self) {}
// Should warn about `vec`
fn mushroom(&self, vec: &mut Vec<i32>) -> usize {
//~^ ERROR: this argument is a mutable reference, but not used mutably
vec.len()
}
// Should warn about `vec` (and not `self`).
fn badger(&mut self, vec: &mut Vec<i32>) -> usize {
//~^ ERROR: this argument is a mutable reference, but not used mutably
vec.len()
}
}
@ -123,36 +123,36 @@ async fn f7(x: &mut i32, y: i32, z: &mut i32, a: i32) {
*z += 1;
}
// Should warn.
async fn a1(x: &mut i32) {
//~^ ERROR: this argument is a mutable reference, but not used mutably
println!("{:?}", x);
}
// Should warn.
async fn a2(x: &mut i32, y: String) {
//~^ ERROR: this argument is a mutable reference, but not used mutably
println!("{:?}", x);
}
// Should warn.
async fn a3(x: &mut i32, y: String, z: String) {
//~^ ERROR: this argument is a mutable reference, but not used mutably
println!("{:?}", x);
}
// Should warn.
async fn a4(x: &mut i32, y: i32) {
//~^ ERROR: this argument is a mutable reference, but not used mutably
println!("{:?}", x);
}
// Should warn.
async fn a5(x: i32, y: &mut i32) {
//~^ ERROR: this argument is a mutable reference, but not used mutably
println!("{:?}", x);
}
// Should warn.
async fn a6(x: i32, y: &mut i32) {
//~^ ERROR: this argument is a mutable reference, but not used mutably
println!("{:?}", x);
}
// Should warn.
async fn a7(x: i32, y: i32, z: &mut i32) {
//~^ ERROR: this argument is a mutable reference, but not used mutably
println!("{:?}", z);
}
// Should warn.
async fn a8(x: i32, a: &mut i32, y: i32, z: &mut i32) {
//~^ ERROR: this argument is a mutable reference, but not used mutably
println!("{:?}", z);
}
@ -185,13 +185,15 @@ fn used_as_path(s: &mut u32) {}
fn lint_attr(s: &mut u32) {}
#[cfg(not(feature = "a"))]
// Should warn with note.
fn cfg_warn(s: &mut u32) {}
//~^ ERROR: this argument is a mutable reference, but not used mutably
//~| NOTE: this is cfg-gated and may require further changes
#[cfg(not(feature = "a"))]
mod foo {
// Should warn with note.
fn cfg_warn(s: &mut u32) {}
//~^ ERROR: this argument is a mutable reference, but not used mutably
//~| NOTE: this is cfg-gated and may require further changes
}
fn main() {

View File

@ -1,5 +1,5 @@
error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:7:11
--> $DIR/needless_pass_by_ref_mut.rs:6:11
|
LL | fn foo(s: &mut Vec<u32>, b: &u32, x: &mut u32) {
| ^^^^^^^^^^^^^ help: consider changing to: `&Vec<u32>`
@ -7,79 +7,79 @@ LL | fn foo(s: &mut Vec<u32>, b: &u32, x: &mut u32) {
= note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`
error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:32:12
--> $DIR/needless_pass_by_ref_mut.rs:31:12
|
LL | fn foo6(s: &mut Vec<u32>) {
| ^^^^^^^^^^^^^ help: consider changing to: `&Vec<u32>`
error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:45:29
--> $DIR/needless_pass_by_ref_mut.rs:44:29
|
LL | fn mushroom(&self, vec: &mut Vec<i32>) -> usize {
| ^^^^^^^^^^^^^ help: consider changing to: `&Vec<i32>`
error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:50:31
--> $DIR/needless_pass_by_ref_mut.rs:49:31
|
LL | fn badger(&mut self, vec: &mut Vec<i32>) -> usize {
| ^^^^^^^^^^^^^ help: consider changing to: `&Vec<i32>`
error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:127:16
--> $DIR/needless_pass_by_ref_mut.rs:126:16
|
LL | async fn a1(x: &mut i32) {
| ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:131:16
--> $DIR/needless_pass_by_ref_mut.rs:130:16
|
LL | async fn a2(x: &mut i32, y: String) {
| ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:135:16
--> $DIR/needless_pass_by_ref_mut.rs:134:16
|
LL | async fn a3(x: &mut i32, y: String, z: String) {
| ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:139:16
--> $DIR/needless_pass_by_ref_mut.rs:138:16
|
LL | async fn a4(x: &mut i32, y: i32) {
| ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:143:24
--> $DIR/needless_pass_by_ref_mut.rs:142:24
|
LL | async fn a5(x: i32, y: &mut i32) {
| ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:147:24
--> $DIR/needless_pass_by_ref_mut.rs:146:24
|
LL | async fn a6(x: i32, y: &mut i32) {
| ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:151:32
--> $DIR/needless_pass_by_ref_mut.rs:150:32
|
LL | async fn a7(x: i32, y: i32, z: &mut i32) {
| ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:155:24
--> $DIR/needless_pass_by_ref_mut.rs:154:24
|
LL | async fn a8(x: i32, a: &mut i32, y: i32, z: &mut i32) {
| ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:155:45
--> $DIR/needless_pass_by_ref_mut.rs:154:45
|
LL | async fn a8(x: i32, a: &mut i32, y: i32, z: &mut i32) {
| ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:189:16
--> $DIR/needless_pass_by_ref_mut.rs:188:16
|
LL | fn cfg_warn(s: &mut u32) {}
| ^^^^^^^^ help: consider changing to: `&u32`