Skip to content

Commit

Permalink
Add ui test for useless_concat lint
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Dec 14, 2024
1 parent f31fdf0 commit a627a09
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/ui/useless_concat.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#![warn(clippy::useless_concat)]
#![allow(clippy::print_literal)]

fn main() {
let x = ""; //~ useless_concat
let x = "a"; //~ useless_concat
println!("b: {}", "a"); //~ useless_concat
// Should not lint.
let x = concat!("a", "b");
}
10 changes: 10 additions & 0 deletions tests/ui/useless_concat.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#![warn(clippy::useless_concat)]
#![allow(clippy::print_literal)]

fn main() {
let x = concat!(); //~ useless_concat
let x = concat!("a"); //~ useless_concat
println!("b: {}", concat!("a")); //~ useless_concat
// Should not lint.
let x = concat!("a", "b");
}
23 changes: 23 additions & 0 deletions tests/ui/useless_concat.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
error: unneeded use of `concat!` macro
--> tests/ui/useless_concat.rs:5:13
|
LL | let x = concat!();
| ^^^^^^^^^ help: replace with: `""`
|
= note: `-D clippy::useless-concat` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::useless_concat)]`

error: unneeded use of `concat!` macro
--> tests/ui/useless_concat.rs:6:13
|
LL | let x = concat!("a");
| ^^^^^^^^^^^^ help: replace with: `"a"`

error: unneeded use of `concat!` macro
--> tests/ui/useless_concat.rs:7:23
|
LL | println!("b: {}", concat!("a"));
| ^^^^^^^^^^^^ help: replace with: `"a"`

error: aborting due to 3 previous errors

0 comments on commit a627a09

Please sign in to comment.