Skip to content

Commit c26cd9f

Browse files
committed
rustc: Exclude #[repr(C)] from non camel case
C structs predominately do not use camel case identifiers, and we have a clear indicator for what's a C struct now, so excuse all of them from this stylistic lint.
1 parent 6bd79d3 commit c26cd9f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/librustc/lint/builtin.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,11 @@ impl LintPass for NonCamelCaseTypes {
744744
}
745745
}
746746

747+
let has_extern_repr = it.attrs.iter().fold(attr::ReprAny, |acc, attr| {
748+
attr::find_repr_attr(cx.tcx.sess.diagnostic(), attr, acc)
749+
}) == attr::ReprExtern;
750+
if has_extern_repr { return }
751+
747752
match it.node {
748753
ast::ItemTy(..) | ast::ItemStruct(..) => {
749754
check_case(cx, "type", it.ident, it.span)

src/test/compile-fail/lint-non-camel-case-types.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,9 @@ enum Foo5 {
3232
trait foo6 { //~ ERROR trait `foo6` should have a camel case name such as `Foo6`
3333
}
3434

35+
#[repr(C)]
36+
struct foo7 {
37+
bar: int,
38+
}
39+
3540
fn main() { }

0 commit comments

Comments
 (0)