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

Suggestion Span for non_upper_case_globals could be more precise #48103

Open
phansch opened this Issue Feb 9, 2018 · 3 comments

Comments

Projects
None yet
4 participants
@phansch
Contributor

phansch commented Feb 9, 2018

Playground link: https://play.rust-lang.org/?gist=054aaeb143021ea121fc0c091903697b&version=nightly

It currently prints:

warning: static variable `hello` should have an upper case name such as `HELLO`
 --> src/main.rs:3:1
  |
3 | static hello: &str = "Hello";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: #[warn(non_upper_case_globals)] on by default

warning: constant `world` should have an upper case name such as `WORLD`
 --> src/main.rs:4:1
  |
4 | const world: &str = ", world!";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

It would be nicer if it only underlines the variable name itself:

warning: static variable `hello` should have an upper case name such as `HELLO`
 --> src/main.rs:3:1
  |
3 | static hello: &str = "Hello";
  |        ^^^^^
  |
  = note: #[warn(non_upper_case_globals)] on by default

warning: constant `world` should have an upper case name such as `WORLD`
 --> src/main.rs:4:1
  |
4 | const world: &str = ", world!";
  |       ^^^^^

I have some basic lint writing experience through clippy, so I would like to give this a go.

@Manishearth

This comment has been minimized.

Show comment
Hide comment
@Manishearth

Manishearth Feb 10, 2018

Member

Sounds good! Let me know if you need help.

(Self-assigning since I can't assign it to you, but this means I'm mentoring this bug)

Member

Manishearth commented Feb 10, 2018

Sounds good! Let me know if you need help.

(Self-assigning since I can't assign it to you, but this means I'm mentoring this bug)

@Manishearth Manishearth self-assigned this Feb 10, 2018

@killercup

This comment has been minimized.

Show comment
Hide comment
@killercup

killercup Feb 10, 2018

Member

I'm pretty sure we can also this as a suggestion to make it auto-fixable. Not sure if we have a good SCREAMING_SNAKE_CASE transformer in rustc, but I guess it's fine to only suggest this for trivial changes at first.

Member

killercup commented Feb 10, 2018

I'm pretty sure we can also this as a suggestion to make it auto-fixable. Not sure if we have a good SCREAMING_SNAKE_CASE transformer in rustc, but I guess it's fine to only suggest this for trivial changes at first.

@phansch

This comment has been minimized.

Show comment
Hide comment
@phansch

phansch Feb 16, 2018

Contributor

Just a quick update because it's been a few days. I was able to fix this locally already, but got a faster laptop this week where the rust repo setup is broken somehow. I will try to fix it today, otherwise it will be next week 👍

Contributor

phansch commented Feb 16, 2018

Just a quick update because it's been a few days. I was able to fix this locally already, but got a faster laptop this week where the rust repo setup is broken somehow. I will try to fix it today, otherwise it will be next week 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment