-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b76a53
commit b92d91b
Showing
3 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#![warn(clippy::useless_concat)] | ||
#![allow(clippy::print_literal)] | ||
|
||
macro_rules! my_concat { | ||
($fmt:literal $(, $e:expr)*) => { | ||
println!(concat!("ERROR: ", $fmt), $($e,)*); | ||
} | ||
} | ||
|
||
fn main() { | ||
let x = ""; //~ useless_concat | ||
let x = "a"; //~ useless_concat | ||
println!("b: {}", "a"); //~ useless_concat | ||
// Should not lint. | ||
let x = concat!("a", "b"); | ||
let local_i32 = 1; | ||
my_concat!("{}", local_i32); | ||
let x = concat!(file!(), "#L", line!()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#![warn(clippy::useless_concat)] | ||
#![allow(clippy::print_literal)] | ||
|
||
macro_rules! my_concat { | ||
($fmt:literal $(, $e:expr)*) => { | ||
println!(concat!("ERROR: ", $fmt), $($e,)*); | ||
} | ||
} | ||
|
||
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"); | ||
let local_i32 = 1; | ||
my_concat!("{}", local_i32); | ||
let x = concat!(file!(), "#L", line!()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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:11: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:12:13 | ||
| | ||
LL | let x = concat!("a"); | ||
| ^^^^^^^^^^^^ help: replace with: `"a"` | ||
|
||
error: unneeded use of `concat!` macro | ||
--> tests/ui/useless_concat.rs:13:23 | ||
| | ||
LL | println!("b: {}", concat!("a")); | ||
| ^^^^^^^^^^^^ help: replace with: `"a"` | ||
|
||
error: aborting due to 3 previous errors | ||
|