Skip to content

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

@kennytm

Description

@kennytm

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-UnicodeArea: UnicodeA-diagnosticsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.F-non_ascii_idents`#![feature(non_ascii_idents)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions