-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
lint “non_upper_case_globals” wrongly warns the consumer #25207
Comments
I think this is by design; someone reading the match arm |
I don’t think so. You have the same ambiguity problem when matching against lower-case enum variants and there is no warning emitted for that. |
I think I can agree that there is an "if-and-only-if" relationship here: if (and only if) we warn about |
I think there are two things to agree on:
If it is the purpose of On the other hand, if it’s purpose is to warn about ambiguity, and we want to warn about ambiguity in this case it should give a better hint (e.g. "use full qualifier"). Furthermore we would also have to warn about this case (because it is not a constant): fn main() {
println!("{}", match 23 {
FOO_BAR => "yes",
_ => "no"
});
} This is why I oppose. The consequence would would be that would also have to warn about every variable not following naming conventions. |
Triage: no changes |
Triage: no change |
This seems to have been filed a second time: #39371 I presume one of the two issues can be merged into the other. |
Triage: no change |
@rustbot labels +I-lang-nominated Nominating this on behalf of @Lokathor. The main issue here seems to be that the person whose code is getting the warning is not necessarily well positioned to change the name, and the upstream who is well placed to change the name may have already silenced this warning but we still warn in the downstream code. |
We discussed this in today's @rust-lang/lang meeting. We agreed that the current lint should not fire on uses, only on declarations. However, we also felt cases that are ambiguous between being a constant or a binding (e.g. bare names like A pattern could be made unambiguously a binding with an |
The lint “non_upper_case_globals” wrongly warns the consumer about a ill-named constant (playpen). It only seems to happen if the constant is imported into the current namespace and if you’re using it in a match statement:
The text was updated successfully, but these errors were encountered: