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

case-related lints (non_snake_case, non_camel_case_types, โ€ฆ) did not suggest actual case-changed characters with Mathematical Alphanumeric Symbols #77273

Closed
kennytm opened this issue Sep 27, 2020 · 1 comment ยท Fixed by #77805
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` A-Unicode Area: Unicode C-bug Category: This is a bug. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. F-non_ascii_idents `#![feature(non_ascii_idents)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@kennytm
Copy link
Member

kennytm commented Sep 27, 2020

This example code:

let ๐“ข๐“๐“๐“๐“๐“๐“š๐“”๐“ข = 1;

Produced a useless conversion suggestion:

warning: variable `๐“ข๐“๐“๐“๐“๐“๐“š๐“”๐“ข` should have a snake case name
 --> src/main.rs:4:9
  |
4 |     let ๐“ข๐“๐“๐“๐“๐“๐“š๐“”๐“ข = 1;
  |         ^^^^^^^^^ help: convert the identifier to snake case: `๐“ข๐“๐“๐“๐“๐“๐“š๐“”๐“ข`
  |
  = note: `#[warn(non_snake_case)]` on by default

The problem here is that while these characters are in the Uppercase Letter (Lu) general category, they do not have a proper lowercase mapping: the lowercase of ๐“ is still ๐“, not ๐“ช (thus Rust cannot suggest ๐“ผ๐“ท๐“ช๐“ช๐“ช๐“ช๐“ด๐“ฎ๐“ผ).

This is the same for the other direction:

warning: type `๐•Ÿ๐• ๐•ฅ_๐•’_๐•”๐•’๐•ž๐•–๐•` should have an upper camel case name
 --> src/lib.rs:3:8
  |
3 | struct ๐•Ÿ๐• ๐•ฅ_๐•’_๐•”๐•’๐•ž๐•–๐•;
  |        ^^^^^^^^^^^ help: convert the identifier to upper camel case: `๐•Ÿ๐• ๐•ฅ๐•’๐•”๐•’๐•ž๐•–๐•`
  |
  = note: `#[warn(non_camel_case_types)]` on by default

It shouldn't produce the suggestion at all if the conversion result is not changed, but I'm not sure about cases involving adding or removing underscores.

Meta

rustc on playground, 1.48.0-nightly (2020-09-26 623fb90).

@kennytm kennytm added A-diagnostics Area: Messages for errors, warnings, and lints A-Unicode Area: Unicode T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. F-non_ascii_idents `#![feature(non_ascii_idents)]` labels Sep 27, 2020
@camelid camelid added A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. labels Sep 27, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Nov 21, 2020
โ€ฆ=Dylan-DPC

lint: Do not provide suggestions for non standard characters

Fixes rust-lang#77273

Only provide suggestions if the case-fixed result is different than the original.
@bors bors closed this as completed in 539402c Nov 21, 2020
@3nt3
Copy link

3nt3 commented Apr 10, 2023

I'd like this reopened because it seems like variables like ฮ”ฯ† still result in a suggestion that is identical to the variable name.

(rustc 1.68.0-nightly (52372f9 2023-01-21))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` A-Unicode Area: Unicode C-bug Category: This is a bug. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. F-non_ascii_idents `#![feature(non_ascii_idents)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants