Skip to content
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

On "const should be uppercase" lint, use structured suggestion #52414

Closed
estebank opened this issue Jul 16, 2018 · 1 comment
Closed

On "const should be uppercase" lint, use structured suggestion #52414

estebank opened this issue Jul 16, 2018 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@estebank
Copy link
Contributor

On the non_upper_case_globals lint, use span_suggestion to suggest the uppercase name.

We might want to consider applying the change everywhere the const is actually mentioned, which might be a big undertaking.

@estebank estebank added the A-diagnostics Area: Messages for errors, warnings, and lints label Jul 16, 2018
@bluetech
Copy link

I tried to implement just the simple variant of this (without the global rename). I have included the other nonstandard_style lints as well (snake case, camel case). Here is my attempt: https://github.com/bluetech/rust/commits/nonstandard-style-autofix

The problem I encountered is this: in order to make the suggestion applicable, the span needs to be accurate, i.e. it must span only the name/identifier itself. Currently it is not so in all cases. I (think) I have managed to make the spans accurate, except for 5 places, marked with XXX in the linked patch. They boil down to these cases:

Is there a way to get a Span covering just the name in these cases?

bors added a commit that referenced this issue Jan 14, 2019
Use structured suggestions for nonstandard style lints

This PR modifies the lints in the nonstandard_style group to use structured suggestions. Note that there's a bit of tricky span calculation going on for the `crate_name` attribute. It also simplifies the code a bit: I don't think the "fallback" suggestions for these lints can actually be triggered.

Fixes #48103.
Fixes #52414.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

No branches or pull requests

2 participants