From b676e99b605274c48bea04d344ff18c546041a8f Mon Sep 17 00:00:00 2001 From: Lee Jeffery Date: Mon, 29 Jun 2015 20:40:18 +0100 Subject: [PATCH 1/3] Fix incorrect warning about unused repr attributes. --- src/librustc_lint/builtin.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index db48608823d..16db45c909d 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -821,10 +821,12 @@ impl LintPass for NonCamelCaseTypes { } fn check_item(&mut self, cx: &Context, it: &ast::Item) { - let has_extern_repr = it.attrs.iter().any(|attr| { + let extern_repr_count = it.attrs.iter().filter(|attr| { attr::find_repr_attrs(cx.tcx.sess.diagnostic(), attr).iter() .any(|r| r == &attr::ReprExtern) - }); + }).count(); + let has_extern_repr = extern_repr_count > 0; + if has_extern_repr { return; } From 58ff6cc6681c23cbb10311c2bb2d884f00f9bf24 Mon Sep 17 00:00:00 2001 From: Eljay Date: Mon, 29 Jun 2015 21:27:10 +0100 Subject: [PATCH 2/3] Add test for #26646. --- src/test/run-pass/issue-26646.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/test/run-pass/issue-26646.rs diff --git a/src/test/run-pass/issue-26646.rs b/src/test/run-pass/issue-26646.rs new file mode 100644 index 00000000000..2bb96117868 --- /dev/null +++ b/src/test/run-pass/issue-26646.rs @@ -0,0 +1,21 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(unused_attributes)] + +#[repr(C)] +#[repr(packed)] +pub struct Foo; + +#[repr(packed)] +#[repr(C)] +pub struct Bar; + +fn main() { } \ No newline at end of file From e8fe55f453c0b7c21baba91c219e7df4b6f2db47 Mon Sep 17 00:00:00 2001 From: Eljay Date: Mon, 29 Jun 2015 21:49:15 +0100 Subject: [PATCH 3/3] Add missing trailing newline. --- src/test/run-pass/issue-26646.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/run-pass/issue-26646.rs b/src/test/run-pass/issue-26646.rs index 2bb96117868..89c0a11e292 100644 --- a/src/test/run-pass/issue-26646.rs +++ b/src/test/run-pass/issue-26646.rs @@ -18,4 +18,4 @@ pub struct Foo; #[repr(C)] pub struct Bar; -fn main() { } \ No newline at end of file +fn main() { }