Skip to content

just_underscores_and_digits: fix false positive in error recovery scenario #14168

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

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
9 changes: 7 additions & 2 deletions clippy_dev/src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,13 @@ fn run_rustfmt(context: &FmtContext) -> Result<(), Error> {
.filter_map(|entry| {
let entry = entry.expect("failed to find tests");
let path = entry.path();

if path.extension() != Some("rs".as_ref()) || entry.file_name() == "ice-3891.rs" {
if path.extension() != Some("rs".as_ref())
|| path
.components()
.nth_back(1)
.is_some_and(|c| c.as_os_str() == "syntax-error-recovery")
|| entry.file_name() == "ice-3891.rs"
{
None
} else {
Some(entry.into_path().into_os_string())
Expand Down
3 changes: 2 additions & 1 deletion clippy_lints/src/non_expressive_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ impl SimilarNamesNameVisitor<'_, '_, '_> {

fn check_ident(&mut self, ident: Ident) {
let interned_name = ident.name.as_str();
if interned_name.chars().any(char::is_uppercase) {
// name can be empty if it comes from recovery
if interned_name.chars().any(char::is_uppercase) || interned_name.is_empty() {
return;
}
if interned_name.chars().all(|c| c.is_ascii_digit() || c == '_') {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// https://github.com/rust-lang/rust-clippy/issues/12302
use std::marker::PhantomData;

pub struct Aa<T>(PhantomData<T>);

fn aa(a: Aa<String>) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// https://github.com/rust-lang/rust-clippy/issues/12302
use std::marker::PhantomData;

pub struct Aa<T>(PhantomData<T>);

fn aa(a: Aa<String) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
error: expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `)`
--> tests/ui/syntax-error-recovery/non_expressive_names_error_recovery.rs:6:19
|
LL | fn aa(a: Aa<String) {
| ^ expected one of 7 possible tokens
|
help: you might have meant to end the type parameters here
|
LL | fn aa(a: Aa<String>) {
| +

error: aborting due to 1 previous error