about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-07-10 10:19:38 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-07-10 10:19:38 -0700
commitc26cd9f05dc20eb67cf90d2ebb18728807b53022 (patch)
tree53b3e1e19d06717dd0654fb5e95e5e6f3a168c93
parent6bd79d32e98dfe433c525a59ec69a6e5d77f293d (diff)
downloadrust-c26cd9f05dc20eb67cf90d2ebb18728807b53022.tar.gz
rust-c26cd9f05dc20eb67cf90d2ebb18728807b53022.zip
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.
-rw-r--r--src/librustc/lint/builtin.rs5
-rw-r--r--src/test/compile-fail/lint-non-camel-case-types.rs5
2 files changed, 10 insertions, 0 deletions
diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs
index 481187f7c2c..3049904fc44 100644
--- a/src/librustc/lint/builtin.rs
+++ b/src/librustc/lint/builtin.rs
@@ -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)
diff --git a/src/test/compile-fail/lint-non-camel-case-types.rs b/src/test/compile-fail/lint-non-camel-case-types.rs
index 537c7d62555..784930003d0 100644
--- a/src/test/compile-fail/lint-non-camel-case-types.rs
+++ b/src/test/compile-fail/lint-non-camel-case-types.rs
@@ -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() { }