diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 190e2965e76cec72048074cc0c714698400863aa..2cc030eb0308c801278c7de1ba42920378022761 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -821,10 +821,12 @@ fn get_lints(&self) -> LintArray { } 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; } diff --git a/src/test/run-pass/issue-26646.rs b/src/test/run-pass/issue-26646.rs new file mode 100644 index 0000000000000000000000000000000000000000..89c0a11e292f5715c7fcfc1ef27b46b9756644d9 --- /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() { }