Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

similar_names: No longer suggest inserting or appending an underscore #7221

Merged
merged 1 commit into from
Jul 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions clippy_lints/src/non_expressive_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ impl<'a, 'tcx, 'b> SimilarNamesNameVisitor<'a, 'tcx, 'b> {
if allowed_to_be_similar(&interned_name, existing_name.exemptions) {
continue;
}
let mut split_at = None;
match existing_name.len.cmp(&count) {
Ordering::Greater => {
if existing_name.len - count != 1
Expand Down Expand Up @@ -268,7 +267,6 @@ impl<'a, 'tcx, 'b> SimilarNamesNameVisitor<'a, 'tcx, 'b> {
// or too many chars differ (foo_x, boo_y) or (foox, booy)
continue;
}
split_at = interned_name.char_indices().rev().next().map(|(i, _)| i);
}
} else {
let second_i = interned_chars.next().expect("we know we have at least two chars");
Expand All @@ -281,7 +279,6 @@ impl<'a, 'tcx, 'b> SimilarNamesNameVisitor<'a, 'tcx, 'b> {
// or too many chars differ (x_foo, y_boo) or (xfoo, yboo)
continue;
}
split_at = interned_name.chars().next().map(char::len_utf8);
}
},
}
Expand All @@ -292,17 +289,6 @@ impl<'a, 'tcx, 'b> SimilarNamesNameVisitor<'a, 'tcx, 'b> {
"binding's name is too similar to existing binding",
|diag| {
diag.span_note(existing_name.span, "existing binding defined here");
if let Some(split) = split_at {
diag.span_help(
ident.span,
&format!(
"separate the discriminating character by an \
underscore like: `{}_{}`",
&interned_name[..split],
&interned_name[split..]
),
);
}
},
);
return;
Expand Down
20 changes: 0 additions & 20 deletions tests/ui/similar_names.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ note: existing binding defined here
|
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
Expand All @@ -27,11 +22,6 @@ note: existing binding defined here
|
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
Expand All @@ -44,11 +34,6 @@ note: existing binding defined here
|
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
Expand Down Expand Up @@ -85,11 +70,6 @@ note: existing binding defined here
|
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:85:16
Expand Down