Skip to content

Using unicode literals as indentifier produces a weird warning about snake case #21735

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

Closed
eiennohito opened this issue Jan 29, 2015 · 1 comment · Fixed by #21765
Closed

Using unicode literals as indentifier produces a weird warning about snake case #21735

eiennohito opened this issue Jan 29, 2015 · 1 comment · Fixed by #21765
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.

Comments

@eiennohito
Copy link

Sample code (uses Hiragana を as an identifier)

fn (i: i32) -> i32 {
  i + 5
}

A warning:

test.rs:8:1: 10:2 warning: function `を` should have a snake case name such as `を`, #[warn(non_snake_case)] on by default
test.rs:8 fn を(i: i32) -> i32 {
test.rs:9   i + 5
test.rs:10 }
@huonw huonw added the A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. label Jan 29, 2015
@nagisa
Copy link
Member

nagisa commented Jan 29, 2015

The reason is that some scripts in Unicode (such as kana) have no associated case to them (i.e. they are no-case) and the lint only allows lowercase codepoints.

This is E-easy material, but it is unclear whether the lint should just outright accept any non-uppercase codepoint or we should refine the error message to not have “such as ” suggestion if the lint is triggered by no-case codepoints.

EDIT: I recall some other programming language compiler opting to keep emiting a warning if no-case codepoints are present in snake_case identifiers, but I don’t quite recall which language it was.

nagisa added a commit to nagisa/rust that referenced this issue Jan 29, 2015
ftxqxd added a commit to ftxqxd/rust that referenced this issue Jan 30, 2015
alexcrichton added a commit to alexcrichton/rust that referenced this issue Jan 30, 2015
An alternative to rust-lang#21749.

This also refactors the naming lint code a little bit and slightly rephrases some warnings (`uppercase` → `upper case`).

Closes rust-lang#21735.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants