Skip to content

Commit

Permalink
rustc: Exclude #[repr(C)] from non camel case
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alexcrichton committed Jul 10, 2014
1 parent 6bd79d3 commit c26cd9f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/librustc/lint/builtin.rs
Expand Up @@ -744,6 +744,11 @@ impl LintPass for NonCamelCaseTypes {
}
}

let has_extern_repr = it.attrs.iter().fold(attr::ReprAny, |acc, attr| {
attr::find_repr_attr(cx.tcx.sess.diagnostic(), attr, acc)
}) == attr::ReprExtern;
if has_extern_repr { return }

match it.node {
ast::ItemTy(..) | ast::ItemStruct(..) => {
check_case(cx, "type", it.ident, it.span)
Expand Down
5 changes: 5 additions & 0 deletions src/test/compile-fail/lint-non-camel-case-types.rs
Expand Up @@ -32,4 +32,9 @@ enum Foo5 {
trait foo6 { //~ ERROR trait `foo6` should have a camel case name such as `Foo6`
}

#[repr(C)]
struct foo7 {
bar: int,
}

fn main() { }

0 comments on commit c26cd9f

Please sign in to comment.