`non_camel_case_name` / `non_snake_case_name` / `non_upper_case_globals` don't fire for `use x as y`
Open
Nobody has claimed this yet.
A-diagnostics
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
// doesn't warn
use Option as option;
// doesn't warn
use drop as Drop;
const FOO: () = ();
// doesn't warn
use FOO as foo;
// does warn
enum yip {}
// does warn
fn Woof() {}
// does warn
const mya: () = ();
Current output
unused import warnings, but not name warnings on the imports
warning: unused import: `Option as option`
--> src/lib.rs:2:5
|
2 | use Option as option;
| ^^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: unused import: `drop as Drop`
--> src/lib.rs:5:5
|
5 | use drop as Drop;
| ^^^^^^^^^^^^
warning: unused import: `FOO as foo`
--> src/lib.rs:9:5
|
9 | use FOO as foo;
| ^^^^^^^^^^
warning: type `yip` should have an upper camel case name
--> src/lib.rs:12:6
|
12 | enum yip {}
| ^^^ help: convert the identifier to upper camel case (notice the capitalization): `Yip`
|
= note: `#[warn(non_camel_case_types)]` on by default
warning: constant `FOO` is never used
--> src/lib.rs:7:7
|
7 | const FOO: () = ();
| ^^^
|
= note: `#[warn(dead_code)]` on by default
warning: enum `yip` is never used
--> src/lib.rs:12:6
|
12 | enum yip {}
| ^^^
warning: function `Woof` is never used
--> src/lib.rs:15:4
|
15 | fn Woof() {}
| ^^^^
warning: constant `mya` is never used
--> src/lib.rs:18:7
|
18 | const mya: () = ();
| ^^^
warning: function `Woof` should have a snake case name
--> src/lib.rs:15:4
|
15 | fn Woof() {}
| ^^^^ help: convert the identifier to snake case (notice the capitalization): `woof`
|
= note: `#[warn(non_snake_case)]` on by default
warning: constant `mya` should have an upper case name
--> src/lib.rs:18:7
|
18 | const mya: () = ();
| ^^^ help: convert the identifier to upper case: `MYA`
|
= note: `#[warn(non_upper_case_globals)]` on by default
Desired output
import renames and re-exports should still be subject to the naming lints.
Rationale and extra context
No response
Other cases
No response
Rust Version
1.79.0 stable, tested on play.rust-lang.org
Anything else?
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the supplied Rust snippets with the naming lints enabled, using the reported Rust 1.79.0 behavior as a baseline. The issue names no source file or test path, so locate the compiler's handling of naming lints for import aliases and add coverage showing that renamed imports and re-exports emit the appropriate warnings.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100