-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.A-reprArea: the `#[repr(stuff)]` attributeArea: the `#[repr(stuff)]` attributeC-discussionCategory: Discussion or questions that doesn't represent real issues.Category: Discussion or questions that doesn't represent real issues.L-non_camel_case_typesLint: non_camel_case_typesLint: non_camel_case_typesT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Description
Code
#![forbid(non_camel_case_types)]
#[repr(C)]
pub struct foo_bar {}
Current output
<no error>
Desired output
Compiling playground v0.0.1 (/playground)
error: type `foo_bar` should have an upper camel case name
--> src/lib.rs:4:12
|
4 | pub struct foo_bar {}
| ^^^^^^^ help: convert the identifier to upper camel case: `FooBar`
|
note: the lint level is defined here
--> src/lib.rs:1:11
|
1 | #![forbid(non_camel_case_types)]
| ^^^^^^^^^^^^^^^^^^^^
error: could not compile `playground` (lib) due to 1 previous error
Rationale and extra context
This was clearly an explicit design choice at one point:
if has_repr_c { |
Presumably, the idea was that you'd have a bunch of FFI types with their native C names, and that's what repr(C)
is for. You wouldn't want this lint firing for such types.
But I don't think it's one that makes sense today. repr(C)
is used any time you want a stable layout, not just when you're defining a C type for FFI. The lint should fire in all cases, and crates that define a bunch of C types should silence the lint where appropriate.
Other cases
Rust Version
> rustc --version --verbose
rustc 1.82.0 (f6e511eec 2024-10-15)
binary: rustc
commit-hash: f6e511eec7342f59a25f7c0534f1dbea00d01b14
commit-date: 2024-10-15
host: x86_64-unknown-linux-gnu
release: 1.82.0
LLVM version: 19.1.1
Anything else?
No response
tyrone-wu and tgross35
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.A-reprArea: the `#[repr(stuff)]` attributeArea: the `#[repr(stuff)]` attributeC-discussionCategory: Discussion or questions that doesn't represent real issues.Category: Discussion or questions that doesn't represent real issues.L-non_camel_case_typesLint: non_camel_case_typesLint: non_camel_case_typesT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team