Skip to content

Should non_snake_case lint ignore identifiers with leading _ ? #32653

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
pnkfelix opened this issue Mar 31, 2016 · 5 comments
Closed

Should non_snake_case lint ignore identifiers with leading _ ? #32653

pnkfelix opened this issue Mar 31, 2016 · 5 comments
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-enhancement Category: An issue proposing an enhancement or a PR with one. I-needs-decision Issue: In need of a decision.

Comments

@pnkfelix
Copy link
Member

We currently have a convention that unused variables that start with _ do not cause the unused variable lint to fire.

Should we put in a similar rule for the non_snake_case lint? (Perhaps just for variables with two leading underscores, __, ?)


In my particular case, I am using things like format!("foo {N}", N=name), and the expanded code causes the non-snake-case lint to fire, because it generates names like __argN ...

I could add an #[allow] annotation to the code in question, but this seems unfortunate to me. (Am I the only one who finds format strings easier to read if I use short capital letters for the named substitutions?)

pnkfelix added a commit to pnkfelix/rust that referenced this issue Mar 31, 2016
@steveklabnik steveklabnik added the A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. label Apr 1, 2016
@jonathanbuchanan
Copy link

I'd like to take this one. I was wondering, is there a test for this lint that I would have to update? I would look, but I'm on my phone now.

@nodakai
Copy link
Contributor

nodakai commented Apr 4, 2016

Can we have a table of identifier lint rules? First of all, how is "snake_case" defined in Rust?

pnkfelix added a commit to pnkfelix/rust that referenced this issue Apr 21, 2016
@Mark-Simulacrum
Copy link
Member

format! has been fixed to no longer cause lint warnings. The general issue about ignoring __TestTestTest in the snake case lint is still a problem, though.

@Mark-Simulacrum Mark-Simulacrum added C-enhancement Category: An issue proposing an enhancement or a PR with one. I-needs-decision Issue: In need of a decision. labels Jul 24, 2017
@oli-obk oli-obk added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. and removed E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. labels Jan 25, 2020
@oli-obk
Copy link
Contributor

oli-obk commented Jan 25, 2020

From the comments in #32683 this sounds like it needs an RFC. Should we just close this issue as it can be worked around with #[allow(non_snake_case)]?

@oli-obk
Copy link
Contributor

oli-obk commented Jan 25, 2020

Actually... this seems to have gotten fixed (https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=3116295265f7ab0fd5b435797d35e397). Likely because loads of lints have ben disabled in macro expansions.

@oli-obk oli-obk closed this as completed Jan 25, 2020
@fmease fmease added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. and removed A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. labels Dec 21, 2024
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-enhancement Category: An issue proposing an enhancement or a PR with one. I-needs-decision Issue: In need of a decision.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants