From 3c68f0695e3d8fc3607cbc683ee8eab6724a89b3 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 28 Jul 2023 15:24:40 +0200 Subject: [PATCH] Manually add annotations for ui tests --- tests/ui/crashes/auxiliary/ice-7868-aux.rs | 2 + tests/ui/trivially_copy_pass_by_ref.rs | 19 ++++++- tests/ui/trivially_copy_pass_by_ref.stderr | 60 +++++++++++----------- 3 files changed, 50 insertions(+), 31 deletions(-) diff --git a/tests/ui/crashes/auxiliary/ice-7868-aux.rs b/tests/ui/crashes/auxiliary/ice-7868-aux.rs index bee29894b63d..882b66d67693 100644 --- a/tests/ui/crashes/auxiliary/ice-7868-aux.rs +++ b/tests/ui/crashes/auxiliary/ice-7868-aux.rs @@ -1,3 +1,5 @@ fn zero() { unsafe { 0 }; + //~^ ERROR: unsafe block missing a safety comment + //~| NOTE: `-D clippy::undocumented-unsafe-blocks` implied by `-D warnings` } diff --git a/tests/ui/trivially_copy_pass_by_ref.rs b/tests/ui/trivially_copy_pass_by_ref.rs index 86f5cc937f44..70ba468b0578 100644 --- a/tests/ui/trivially_copy_pass_by_ref.rs +++ b/tests/ui/trivially_copy_pass_by_ref.rs @@ -1,5 +1,5 @@ //@normalize-stderr-test: "\(\d+ byte\)" -> "(N byte)" -//@normalize-stderr-test: "\(limit: \d+ byte\)" -> "(limit: N byte)" +//@normalize-stderr-test: "\(limit: \d+ byte\)" -> "(limit: 8 byte)" #![deny(clippy::trivially_copy_pass_by_ref)] #![allow( clippy::disallowed_names, @@ -50,6 +50,8 @@ fn good_return_explicit_lt_struct<'a>(foo: &'a Foo) -> FooRef<'a> { } fn bad(x: &u32, y: &Foo, z: &Baz) {} +//~^ ERROR: this argument (4 byte) is passed by reference, but would be more efficient if passed by +//~| ERROR: this argument (4 byte) is passed by reference, but would be more efficient if passed by impl Foo { fn good(self, a: &mut u32, b: u32, c: &Bar) {} @@ -57,10 +59,18 @@ impl Foo { fn good2(&mut self) {} fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} + //~^ ERROR: this argument (4 byte) is passed by reference, but would be more efficient if passed by + //~| ERROR: this argument (4 byte) is passed by reference, but would be more efficient if passed by + //~| ERROR: this argument (4 byte) is passed by reference, but would be more efficient if passed by + //~| ERROR: this argument (4 byte) is passed by reference, but would be more efficient if passed by fn bad2(x: &u32, y: &Foo, z: &Baz) {} + //~^ ERROR: this argument (4 byte) is passed by reference, but would be more efficient if passed by + //~| ERROR: this argument (4 byte) is passed by reference, but would be more efficient if passed by + //~| ERROR: this argument (4 byte) is passed by reference, but would be more efficient if passed by fn bad_issue7518(self, other: &Self) {} + //~^ ERROR: this argument (4 byte) is passed by reference, but would be more efficient if } impl AsRef for Foo { @@ -73,10 +83,14 @@ impl Bar { fn good(&self, a: &mut u32, b: u32, c: &Bar) {} fn bad2(x: &u32, y: &Foo, z: &Baz) {} + //~^ ERROR: this argument (4 byte) is passed by reference, but would be more efficient if + //~| ERROR: this argument (4 byte) is passed by reference, but would be more efficient if + //~| ERROR: this argument (4 byte) is passed by reference, but would be more efficient if } trait MyTrait { fn trait_method(&self, _foo: &Foo); + //~^ ERROR: this argument (4 byte) is passed by reference, but would be more efficient if } pub trait MyTrait2 { @@ -109,11 +123,13 @@ mod issue5876 { #[inline(never)] fn foo_never(x: &i32) { + //~^ ERROR: this argument (4 byte) is passed by reference, but would be more efficient if passed by println!("{}", x); } #[inline] fn foo(x: &i32) { + //~^ ERROR: this argument (4 byte) is passed by reference, but would be more efficient if passed by println!("{}", x); } } @@ -141,6 +157,7 @@ async fn _async_explicit<'a>(x: &'a u32) -> &'a u32 { } fn _unrelated_lifetimes<'a, 'b>(_x: &'a u32, y: &'b u32) -> &'b u32 { + //~^ ERROR: this argument (4 byte) is passed by reference, but would be more efficient if passed by y } diff --git a/tests/ui/trivially_copy_pass_by_ref.stderr b/tests/ui/trivially_copy_pass_by_ref.stderr index 2af668537f5c..903c240bfcab 100644 --- a/tests/ui/trivially_copy_pass_by_ref.stderr +++ b/tests/ui/trivially_copy_pass_by_ref.stderr @@ -22,92 +22,92 @@ error: this argument (N byte) is passed by reference, but would be more efficien LL | fn bad(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Baz` -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) - --> $DIR/trivially_copy_pass_by_ref.rs:59:12 +error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) + --> $DIR/trivially_copy_pass_by_ref.rs:61:12 | LL | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} | ^^^^^ help: consider passing by value instead: `self` -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) - --> $DIR/trivially_copy_pass_by_ref.rs:59:22 +error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) + --> $DIR/trivially_copy_pass_by_ref.rs:61:22 | LL | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `u32` -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) - --> $DIR/trivially_copy_pass_by_ref.rs:59:31 +error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) + --> $DIR/trivially_copy_pass_by_ref.rs:61:31 | LL | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Foo` -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) - --> $DIR/trivially_copy_pass_by_ref.rs:59:40 +error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) + --> $DIR/trivially_copy_pass_by_ref.rs:61:40 | LL | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Baz` -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) - --> $DIR/trivially_copy_pass_by_ref.rs:61:16 +error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) + --> $DIR/trivially_copy_pass_by_ref.rs:67:16 | LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `u32` -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) - --> $DIR/trivially_copy_pass_by_ref.rs:61:25 +error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) + --> $DIR/trivially_copy_pass_by_ref.rs:67:25 | LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Foo` -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) - --> $DIR/trivially_copy_pass_by_ref.rs:61:34 +error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) + --> $DIR/trivially_copy_pass_by_ref.rs:67:34 | LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Baz` -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) - --> $DIR/trivially_copy_pass_by_ref.rs:63:35 +error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) + --> $DIR/trivially_copy_pass_by_ref.rs:72:35 | LL | fn bad_issue7518(self, other: &Self) {} | ^^^^^ help: consider passing by value instead: `Self` -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) - --> $DIR/trivially_copy_pass_by_ref.rs:75:16 +error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) + --> $DIR/trivially_copy_pass_by_ref.rs:85:16 | LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `u32` -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) - --> $DIR/trivially_copy_pass_by_ref.rs:75:25 +error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) + --> $DIR/trivially_copy_pass_by_ref.rs:85:25 | LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Foo` -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) - --> $DIR/trivially_copy_pass_by_ref.rs:75:34 +error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) + --> $DIR/trivially_copy_pass_by_ref.rs:85:34 | LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Baz` -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) - --> $DIR/trivially_copy_pass_by_ref.rs:79:34 +error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) + --> $DIR/trivially_copy_pass_by_ref.rs:92:34 | LL | fn trait_method(&self, _foo: &Foo); | ^^^^ help: consider passing by value instead: `Foo` -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) - --> $DIR/trivially_copy_pass_by_ref.rs:111:21 +error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) + --> $DIR/trivially_copy_pass_by_ref.rs:125:21 | LL | fn foo_never(x: &i32) { | ^^^^ help: consider passing by value instead: `i32` -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) - --> $DIR/trivially_copy_pass_by_ref.rs:116:15 +error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) + --> $DIR/trivially_copy_pass_by_ref.rs:131:15 | LL | fn foo(x: &i32) { | ^^^^ help: consider passing by value instead: `i32` -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) - --> $DIR/trivially_copy_pass_by_ref.rs:143:37 +error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) + --> $DIR/trivially_copy_pass_by_ref.rs:159:37 | LL | fn _unrelated_lifetimes<'a, 'b>(_x: &'a u32, y: &'b u32) -> &'b u32 { | ^^^^^^^ help: consider passing by value instead: `u32`