Skip to content

Variable name with internal double-underscore gets snake case warning, but leading/trailing does not #19475

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
huonw opened this issue Dec 2, 2014 · 7 comments
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. I-needs-decision Issue: In need of a decision.

Comments

@huonw
Copy link
Member

huonw commented Dec 2, 2014

#![allow(unused_variables)]

fn main() {
    let x__y = 0u;

    let __xy = 0u;
    let xy__ = 0u;
}
doubleunder.rs:4:9: 4:13 warning: variable `x__y` should have a snake case name such as `x_y`, #[warn(non_snake_case)] on by default
doubleunder.rs:4     let x__y = 0u;
                         ^~~~

It seems slightly weird that we are inconsistent.

@huonw huonw added the A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. label Dec 2, 2014
@lilyball
Copy link
Contributor

lilyball commented Dec 2, 2014

Are you proposing that we remove the warning for x__y? Allowing xy__ and __xy seems correct.

@huonw
Copy link
Member Author

huonw commented Dec 2, 2014

I'm not proposing either, just wanting us to be consistent either way. (I personally would prefer making all legal.)

@frewsxcv
Copy link
Member

frewsxcv commented Jul 1, 2015

1.1.0 Update: The warning is still given for x__y

Playpen: http://is.gd/mmKJtz

@steveklabnik
Copy link
Member

Triage: no change.

o_____o

😉

@Mark-Simulacrum
Copy link
Member

I think the leading __ case is intentional, but uncertain about trailing.

@Mark-Simulacrum Mark-Simulacrum added C-bug Category: This is a bug. I-needs-decision Issue: In need of a decision. labels Jul 22, 2017
@steveklabnik
Copy link
Member

Triage: no change

@Mark-Simulacrum
Copy link
Member

The test case for this lint has two "don't allow two underscores" cases (https://github.com/rust-lang/rust/blob/master/src/test/ui/lint/lint-non-snake-case-functions.rs). I'm going to say that's probably enough that we don't want to just change behavior here -- in particular, it seems no one really wants this. (If they do, I would encourage them to file a PR or chime in here).

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. C-bug Category: This is a bug. I-needs-decision Issue: In need of a decision.
Projects
None yet
Development

No branches or pull requests

5 participants