Skip to content

Commit 41bb092

Browse files
committed
Auto merge of #7255 - whatisaphone:feat/similar-names-wparam-lparam, r=giraffate
Allow wparam and lparam in similar_names `wparam` and `lparam` are often used as generic parameter names in win32 (for example [WindowProc](https://docs.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ms633573(v=vs.85))). This PR adds them to the similar_names exception list. changelog: [`similar_names`] don't treat wparam and lparam as similar
2 parents 297e743 + 2eafec1 commit 41bb092

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

clippy_lints/src/non_expressive_names.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ const ALLOWED_TO_BE_SIMILAR: &[&[&str]] = &[
125125
&["args", "arms"],
126126
&["qpath", "path"],
127127
&["lit", "lint"],
128+
&["wparam", "lparam"],
128129
];
129130

130131
struct SimilarNamesNameVisitor<'a, 'tcx, 'b>(&'b mut SimilarNamesLocalVisitor<'a, 'tcx>);

tests/ui/similar_names.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ fn main() {
7272
let rx1: i32;
7373
let tx_cake: i32;
7474
let rx_cake: i32;
75+
76+
// names often used in win32 code (for example WindowProc)
77+
let wparam: i32;
78+
let lparam: i32;
7579
}
7680

7781
fn foo() {

tests/ui/similar_names.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@ LL | let parsee: i32;
9292
| ^^^^^^
9393

9494
error: binding's name is too similar to existing binding
95-
--> $DIR/similar_names.rs:81:16
95+
--> $DIR/similar_names.rs:85:16
9696
|
9797
LL | bpple: sprang,
9898
| ^^^^^^
9999
|
100100
note: existing binding defined here
101-
--> $DIR/similar_names.rs:80:16
101+
--> $DIR/similar_names.rs:84:16
102102
|
103103
LL | apple: spring,
104104
| ^^^^^^

0 commit comments

Comments
 (0)