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

Fix invalid camel case suggestion involving unicode idents #81529

Merged
merged 2 commits into from
Feb 1, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 7 additions & 1 deletion compiler/rustc_lint/src/nonstandard_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ declare_lint! {
declare_lint_pass!(NonCamelCaseTypes => [NON_CAMEL_CASE_TYPES]);

fn char_has_case(c: char) -> bool {
c.is_lowercase() || c.is_uppercase()
c.to_lowercase().to_string() != c.to_uppercase().to_string()
estebank marked this conversation as resolved.
Show resolved Hide resolved
}

fn is_camel_case(name: &str) -> bool {
Expand Down Expand Up @@ -138,6 +138,8 @@ impl NonCamelCaseTypes {
to_camel_case(name),
Applicability::MaybeIncorrect,
);
} else {
err.span_label(ident.span, "should have an UpperCamelCase name");
estebank marked this conversation as resolved.
Show resolved Hide resolved
}

err.emit();
Expand Down Expand Up @@ -299,6 +301,8 @@ impl NonSnakeCase {
} else {
err.help(&format!("convert the identifier to snake case: `{}`", sc));
}
} else {
err.span_label(ident.span, "should have a snake_case name");
}

err.emit();
Expand Down Expand Up @@ -477,6 +481,8 @@ impl NonUpperCaseGlobals {
uc,
Applicability::MaybeIncorrect,
);
} else {
err.span_label(ident.span, "should have an UPPER_CASE name");
}

err.emit();
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/lint/special-upper-lower-cases.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@ warning: type `𝕟𝕠𝕥𝕒𝕔𝕒𝕞𝕖𝕝` should have an upper camel
--> $DIR/special-upper-lower-cases.rs:11:8
|
LL | struct 𝕟𝕠𝕥𝕒𝕔𝕒𝕞𝕖𝕝;
| ^^^^^^^^^
| ^^^^^^^^^ should have an UpperCamelCase name
|
= note: `#[warn(non_camel_case_types)]` on by default

warning: type `𝕟𝕠𝕥_𝕒_𝕔𝕒𝕞𝕖𝕝` should have an upper camel case name
--> $DIR/special-upper-lower-cases.rs:15:8
|
LL | struct 𝕟𝕠𝕥_𝕒_𝕔𝕒𝕞𝕖𝕝;
| ^^^^^^^^^^^ help: convert the identifier to upper camel case: `𝕟𝕠𝕥𝕒𝕔𝕒𝕞𝕖𝕝`
| ^^^^^^^^^^^ should have an UpperCamelCase name
estebank marked this conversation as resolved.
Show resolved Hide resolved

warning: static variable `𝗻𝗼𝗻𝘂𝗽𝗽𝗲𝗿𝗰𝗮𝘀𝗲` should have an upper case name
--> $DIR/special-upper-lower-cases.rs:18:8
|
LL | static 𝗻𝗼𝗻𝘂𝗽𝗽𝗲𝗿𝗰𝗮𝘀𝗲: i32 = 1;
| ^^^^^^^^^^^^
| ^^^^^^^^^^^^ should have an UPPER_CASE name
|
= note: `#[warn(non_upper_case_globals)]` on by default

warning: variable `𝓢𝓝𝓐𝓐𝓐𝓐𝓚𝓔𝓢` should have a snake case name
--> $DIR/special-upper-lower-cases.rs:22:9
|
LL | let 𝓢𝓝𝓐𝓐𝓐𝓐𝓚𝓔𝓢 = 1;
| ^^^^^^^^^
| ^^^^^^^^^ should have a snake_case name
|
= note: `#[warn(non_snake_case)]` on by default

Expand Down