mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 13:13:34 +00:00
UI test cleanup: Extract similar_names tests
This commit is contained in:
parent
5725726345
commit
9dbabffe60
4 changed files with 223 additions and 217 deletions
|
@ -1,87 +1,6 @@
|
|||
#![warn(clippy::all, clippy::similar_names)]
|
||||
#![warn(clippy::all)]
|
||||
#![allow(unused, clippy::println_empty_string)]
|
||||
|
||||
struct Foo {
|
||||
apple: i32,
|
||||
bpple: i32,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let specter: i32;
|
||||
let spectre: i32;
|
||||
|
||||
let apple: i32;
|
||||
|
||||
let bpple: i32;
|
||||
|
||||
let cpple: i32;
|
||||
|
||||
let a_bar: i32;
|
||||
let b_bar: i32;
|
||||
let c_bar: i32;
|
||||
|
||||
let items = [5];
|
||||
for item in &items {
|
||||
loop {}
|
||||
}
|
||||
|
||||
let foo_x: i32;
|
||||
let foo_y: i32;
|
||||
|
||||
let rhs: i32;
|
||||
let lhs: i32;
|
||||
|
||||
let bla_rhs: i32;
|
||||
let bla_lhs: i32;
|
||||
|
||||
let blubrhs: i32;
|
||||
let blublhs: i32;
|
||||
|
||||
let blubx: i32;
|
||||
let bluby: i32;
|
||||
|
||||
let cake: i32;
|
||||
let cakes: i32;
|
||||
let coke: i32;
|
||||
|
||||
match 5 {
|
||||
cheese @ 1 => {},
|
||||
rabbit => panic!(),
|
||||
}
|
||||
let cheese: i32;
|
||||
match (42, 43) {
|
||||
(cheese1, 1) => {},
|
||||
(cheese2, 2) => panic!(),
|
||||
_ => println!(""),
|
||||
}
|
||||
let ipv4: i32;
|
||||
let ipv6: i32;
|
||||
let abcd1: i32;
|
||||
let abdc2: i32;
|
||||
let xyz1abc: i32;
|
||||
let xyz2abc: i32;
|
||||
let xyzeabc: i32;
|
||||
|
||||
let parser: i32;
|
||||
let parsed: i32;
|
||||
let parsee: i32;
|
||||
|
||||
let setter: i32;
|
||||
let getter: i32;
|
||||
let tx1: i32;
|
||||
let rx1: i32;
|
||||
let tx_cake: i32;
|
||||
let rx_cake: i32;
|
||||
}
|
||||
|
||||
fn foo() {
|
||||
let Foo { apple, bpple } = unimplemented!();
|
||||
let Foo {
|
||||
apple: spring,
|
||||
bpple: sprang,
|
||||
} = unimplemented!();
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
enum MaybeInst {
|
||||
Split,
|
||||
|
@ -160,22 +79,4 @@ impl Bar {
|
|||
}
|
||||
}
|
||||
|
||||
// false positive similar_names (#3057, #2651)
|
||||
// clippy claimed total_reg_src_size and total_size and
|
||||
// numb_reg_src_checkouts and total_bin_size were similar
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct DirSizes {
|
||||
pub(crate) total_size: u64,
|
||||
pub(crate) numb_bins: u64,
|
||||
pub(crate) total_bin_size: u64,
|
||||
pub(crate) total_reg_size: u64,
|
||||
pub(crate) total_git_db_size: u64,
|
||||
pub(crate) total_git_repos_bare_size: u64,
|
||||
pub(crate) numb_git_repos_bare_repos: u64,
|
||||
pub(crate) numb_git_checkouts: u64,
|
||||
pub(crate) total_git_chk_size: u64,
|
||||
pub(crate) total_reg_cache_size: u64,
|
||||
pub(crate) total_reg_src_size: u64,
|
||||
pub(crate) numb_reg_cache_entries: u64,
|
||||
pub(crate) numb_reg_src_checkouts: u64,
|
||||
}
|
||||
fn main() {}
|
||||
|
|
|
@ -1,110 +1,5 @@
|
|||
error: binding's name is too similar to existing binding
|
||||
--> $DIR/non_expressive_names.rs:15:9
|
||||
|
|
||||
LL | let bpple: i32;
|
||||
| ^^^^^
|
||||
|
|
||||
= note: `-D clippy::similar-names` implied by `-D warnings`
|
||||
note: existing binding defined here
|
||||
--> $DIR/non_expressive_names.rs:13:9
|
||||
|
|
||||
LL | let apple: i32;
|
||||
| ^^^^^
|
||||
help: separate the discriminating character by an underscore like: `b_pple`
|
||||
--> $DIR/non_expressive_names.rs:15:9
|
||||
|
|
||||
LL | let bpple: i32;
|
||||
| ^^^^^
|
||||
|
||||
error: binding's name is too similar to existing binding
|
||||
--> $DIR/non_expressive_names.rs:17:9
|
||||
|
|
||||
LL | let cpple: i32;
|
||||
| ^^^^^
|
||||
|
|
||||
note: existing binding defined here
|
||||
--> $DIR/non_expressive_names.rs:13:9
|
||||
|
|
||||
LL | let apple: i32;
|
||||
| ^^^^^
|
||||
help: separate the discriminating character by an underscore like: `c_pple`
|
||||
--> $DIR/non_expressive_names.rs:17:9
|
||||
|
|
||||
LL | let cpple: i32;
|
||||
| ^^^^^
|
||||
|
||||
error: binding's name is too similar to existing binding
|
||||
--> $DIR/non_expressive_names.rs:41:9
|
||||
|
|
||||
LL | let bluby: i32;
|
||||
| ^^^^^
|
||||
|
|
||||
note: existing binding defined here
|
||||
--> $DIR/non_expressive_names.rs:40:9
|
||||
|
|
||||
LL | let blubx: i32;
|
||||
| ^^^^^
|
||||
help: separate the discriminating character by an underscore like: `blub_y`
|
||||
--> $DIR/non_expressive_names.rs:41:9
|
||||
|
|
||||
LL | let bluby: i32;
|
||||
| ^^^^^
|
||||
|
||||
error: binding's name is too similar to existing binding
|
||||
--> $DIR/non_expressive_names.rs:45:9
|
||||
|
|
||||
LL | let coke: i32;
|
||||
| ^^^^
|
||||
|
|
||||
note: existing binding defined here
|
||||
--> $DIR/non_expressive_names.rs:43:9
|
||||
|
|
||||
LL | let cake: i32;
|
||||
| ^^^^
|
||||
|
||||
error: binding's name is too similar to existing binding
|
||||
--> $DIR/non_expressive_names.rs:63:9
|
||||
|
|
||||
LL | let xyzeabc: i32;
|
||||
| ^^^^^^^
|
||||
|
|
||||
note: existing binding defined here
|
||||
--> $DIR/non_expressive_names.rs:61:9
|
||||
|
|
||||
LL | let xyz1abc: i32;
|
||||
| ^^^^^^^
|
||||
|
||||
error: binding's name is too similar to existing binding
|
||||
--> $DIR/non_expressive_names.rs:67:9
|
||||
|
|
||||
LL | let parsee: i32;
|
||||
| ^^^^^^
|
||||
|
|
||||
note: existing binding defined here
|
||||
--> $DIR/non_expressive_names.rs:65:9
|
||||
|
|
||||
LL | let parser: i32;
|
||||
| ^^^^^^
|
||||
help: separate the discriminating character by an underscore like: `parse_e`
|
||||
--> $DIR/non_expressive_names.rs:67:9
|
||||
|
|
||||
LL | let parsee: i32;
|
||||
| ^^^^^^
|
||||
|
||||
error: binding's name is too similar to existing binding
|
||||
--> $DIR/non_expressive_names.rs:81:16
|
||||
|
|
||||
LL | bpple: sprang,
|
||||
| ^^^^^^
|
||||
|
|
||||
note: existing binding defined here
|
||||
--> $DIR/non_expressive_names.rs:80:16
|
||||
|
|
||||
LL | apple: spring,
|
||||
| ^^^^^^
|
||||
|
||||
error: 5th binding whose name is just one char
|
||||
--> $DIR/non_expressive_names.rs:116:17
|
||||
--> $DIR/non_expressive_names.rs:35:17
|
||||
|
|
||||
LL | let e: i32;
|
||||
| ^
|
||||
|
@ -112,25 +7,25 @@ LL | let e: i32;
|
|||
= note: `-D clippy::many-single-char-names` implied by `-D warnings`
|
||||
|
||||
error: 5th binding whose name is just one char
|
||||
--> $DIR/non_expressive_names.rs:119:17
|
||||
--> $DIR/non_expressive_names.rs:38:17
|
||||
|
|
||||
LL | let e: i32;
|
||||
| ^
|
||||
|
||||
error: 6th binding whose name is just one char
|
||||
--> $DIR/non_expressive_names.rs:120:17
|
||||
--> $DIR/non_expressive_names.rs:39:17
|
||||
|
|
||||
LL | let f: i32;
|
||||
| ^
|
||||
|
||||
error: 5th binding whose name is just one char
|
||||
--> $DIR/non_expressive_names.rs:124:13
|
||||
--> $DIR/non_expressive_names.rs:43:13
|
||||
|
|
||||
LL | e => panic!(),
|
||||
| ^
|
||||
|
||||
error: consider choosing a more descriptive name
|
||||
--> $DIR/non_expressive_names.rs:134:9
|
||||
--> $DIR/non_expressive_names.rs:53:9
|
||||
|
|
||||
LL | let _1 = 1; //~ERROR Consider a more descriptive name
|
||||
| ^^
|
||||
|
@ -138,34 +33,34 @@ LL | let _1 = 1; //~ERROR Consider a more descriptive name
|
|||
= note: `-D clippy::just-underscores-and-digits` implied by `-D warnings`
|
||||
|
||||
error: consider choosing a more descriptive name
|
||||
--> $DIR/non_expressive_names.rs:135:9
|
||||
--> $DIR/non_expressive_names.rs:54:9
|
||||
|
|
||||
LL | let ____1 = 1; //~ERROR Consider a more descriptive name
|
||||
| ^^^^^
|
||||
|
||||
error: consider choosing a more descriptive name
|
||||
--> $DIR/non_expressive_names.rs:136:9
|
||||
--> $DIR/non_expressive_names.rs:55:9
|
||||
|
|
||||
LL | let __1___2 = 12; //~ERROR Consider a more descriptive name
|
||||
| ^^^^^^^
|
||||
|
||||
error: consider choosing a more descriptive name
|
||||
--> $DIR/non_expressive_names.rs:156:13
|
||||
--> $DIR/non_expressive_names.rs:75:13
|
||||
|
|
||||
LL | let _1 = 1;
|
||||
| ^^
|
||||
|
||||
error: consider choosing a more descriptive name
|
||||
--> $DIR/non_expressive_names.rs:157:13
|
||||
--> $DIR/non_expressive_names.rs:76:13
|
||||
|
|
||||
LL | let ____1 = 1;
|
||||
| ^^^^^
|
||||
|
||||
error: consider choosing a more descriptive name
|
||||
--> $DIR/non_expressive_names.rs:158:13
|
||||
--> $DIR/non_expressive_names.rs:77:13
|
||||
|
|
||||
LL | let __1___2 = 12;
|
||||
| ^^^^^^^
|
||||
|
||||
error: aborting due to 17 previous errors
|
||||
error: aborting due to 10 previous errors
|
||||
|
||||
|
|
103
tests/ui/similar_names.rs
Normal file
103
tests/ui/similar_names.rs
Normal file
|
@ -0,0 +1,103 @@
|
|||
#![warn(clippy::similar_names)]
|
||||
#![allow(unused, clippy::println_empty_string)]
|
||||
|
||||
struct Foo {
|
||||
apple: i32,
|
||||
bpple: i32,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let specter: i32;
|
||||
let spectre: i32;
|
||||
|
||||
let apple: i32;
|
||||
|
||||
let bpple: i32;
|
||||
|
||||
let cpple: i32;
|
||||
|
||||
let a_bar: i32;
|
||||
let b_bar: i32;
|
||||
let c_bar: i32;
|
||||
|
||||
let items = [5];
|
||||
for item in &items {
|
||||
loop {}
|
||||
}
|
||||
|
||||
let foo_x: i32;
|
||||
let foo_y: i32;
|
||||
|
||||
let rhs: i32;
|
||||
let lhs: i32;
|
||||
|
||||
let bla_rhs: i32;
|
||||
let bla_lhs: i32;
|
||||
|
||||
let blubrhs: i32;
|
||||
let blublhs: i32;
|
||||
|
||||
let blubx: i32;
|
||||
let bluby: i32;
|
||||
|
||||
let cake: i32;
|
||||
let cakes: i32;
|
||||
let coke: i32;
|
||||
|
||||
match 5 {
|
||||
cheese @ 1 => {},
|
||||
rabbit => panic!(),
|
||||
}
|
||||
let cheese: i32;
|
||||
match (42, 43) {
|
||||
(cheese1, 1) => {},
|
||||
(cheese2, 2) => panic!(),
|
||||
_ => println!(""),
|
||||
}
|
||||
let ipv4: i32;
|
||||
let ipv6: i32;
|
||||
let abcd1: i32;
|
||||
let abdc2: i32;
|
||||
let xyz1abc: i32;
|
||||
let xyz2abc: i32;
|
||||
let xyzeabc: i32;
|
||||
|
||||
let parser: i32;
|
||||
let parsed: i32;
|
||||
let parsee: i32;
|
||||
|
||||
let setter: i32;
|
||||
let getter: i32;
|
||||
let tx1: i32;
|
||||
let rx1: i32;
|
||||
let tx_cake: i32;
|
||||
let rx_cake: i32;
|
||||
}
|
||||
|
||||
fn foo() {
|
||||
let Foo { apple, bpple } = unimplemented!();
|
||||
let Foo {
|
||||
apple: spring,
|
||||
bpple: sprang,
|
||||
} = unimplemented!();
|
||||
}
|
||||
|
||||
// false positive similar_names (#3057, #2651)
|
||||
// clippy claimed total_reg_src_size and total_size and
|
||||
// numb_reg_src_checkouts and total_bin_size were similar
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct DirSizes {
|
||||
pub(crate) total_size: u64,
|
||||
pub(crate) numb_bins: u64,
|
||||
pub(crate) total_bin_size: u64,
|
||||
pub(crate) total_reg_size: u64,
|
||||
pub(crate) total_git_db_size: u64,
|
||||
pub(crate) total_git_repos_bare_size: u64,
|
||||
pub(crate) numb_git_repos_bare_repos: u64,
|
||||
pub(crate) numb_git_checkouts: u64,
|
||||
pub(crate) total_git_chk_size: u64,
|
||||
pub(crate) total_reg_cache_size: u64,
|
||||
pub(crate) total_reg_src_size: u64,
|
||||
pub(crate) numb_reg_cache_entries: u64,
|
||||
pub(crate) numb_reg_src_checkouts: u64,
|
||||
}
|
107
tests/ui/similar_names.stderr
Normal file
107
tests/ui/similar_names.stderr
Normal file
|
@ -0,0 +1,107 @@
|
|||
error: binding's name is too similar to existing binding
|
||||
--> $DIR/similar_names.rs:15:9
|
||||
|
|
||||
LL | let bpple: i32;
|
||||
| ^^^^^
|
||||
|
|
||||
= note: `-D clippy::similar-names` implied by `-D warnings`
|
||||
note: existing binding defined here
|
||||
--> $DIR/similar_names.rs:13:9
|
||||
|
|
||||
LL | let apple: i32;
|
||||
| ^^^^^
|
||||
help: separate the discriminating character by an underscore like: `b_pple`
|
||||
--> $DIR/similar_names.rs:15:9
|
||||
|
|
||||
LL | let bpple: i32;
|
||||
| ^^^^^
|
||||
|
||||
error: binding's name is too similar to existing binding
|
||||
--> $DIR/similar_names.rs:17:9
|
||||
|
|
||||
LL | let cpple: i32;
|
||||
| ^^^^^
|
||||
|
|
||||
note: existing binding defined here
|
||||
--> $DIR/similar_names.rs:13:9
|
||||
|
|
||||
LL | let apple: i32;
|
||||
| ^^^^^
|
||||
help: separate the discriminating character by an underscore like: `c_pple`
|
||||
--> $DIR/similar_names.rs:17:9
|
||||
|
|
||||
LL | let cpple: i32;
|
||||
| ^^^^^
|
||||
|
||||
error: binding's name is too similar to existing binding
|
||||
--> $DIR/similar_names.rs:41:9
|
||||
|
|
||||
LL | let bluby: i32;
|
||||
| ^^^^^
|
||||
|
|
||||
note: existing binding defined here
|
||||
--> $DIR/similar_names.rs:40:9
|
||||
|
|
||||
LL | let blubx: i32;
|
||||
| ^^^^^
|
||||
help: separate the discriminating character by an underscore like: `blub_y`
|
||||
--> $DIR/similar_names.rs:41:9
|
||||
|
|
||||
LL | let bluby: i32;
|
||||
| ^^^^^
|
||||
|
||||
error: binding's name is too similar to existing binding
|
||||
--> $DIR/similar_names.rs:45:9
|
||||
|
|
||||
LL | let coke: i32;
|
||||
| ^^^^
|
||||
|
|
||||
note: existing binding defined here
|
||||
--> $DIR/similar_names.rs:43:9
|
||||
|
|
||||
LL | let cake: i32;
|
||||
| ^^^^
|
||||
|
||||
error: binding's name is too similar to existing binding
|
||||
--> $DIR/similar_names.rs:63:9
|
||||
|
|
||||
LL | let xyzeabc: i32;
|
||||
| ^^^^^^^
|
||||
|
|
||||
note: existing binding defined here
|
||||
--> $DIR/similar_names.rs:61:9
|
||||
|
|
||||
LL | let xyz1abc: i32;
|
||||
| ^^^^^^^
|
||||
|
||||
error: binding's name is too similar to existing binding
|
||||
--> $DIR/similar_names.rs:67:9
|
||||
|
|
||||
LL | let parsee: i32;
|
||||
| ^^^^^^
|
||||
|
|
||||
note: existing binding defined here
|
||||
--> $DIR/similar_names.rs:65:9
|
||||
|
|
||||
LL | let parser: i32;
|
||||
| ^^^^^^
|
||||
help: separate the discriminating character by an underscore like: `parse_e`
|
||||
--> $DIR/similar_names.rs:67:9
|
||||
|
|
||||
LL | let parsee: i32;
|
||||
| ^^^^^^
|
||||
|
||||
error: binding's name is too similar to existing binding
|
||||
--> $DIR/similar_names.rs:81:16
|
||||
|
|
||||
LL | bpple: sprang,
|
||||
| ^^^^^^
|
||||
|
|
||||
note: existing binding defined here
|
||||
--> $DIR/similar_names.rs:80:16
|
||||
|
|
||||
LL | apple: spring,
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
|
Loading…
Reference in a new issue