mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 23:34:48 +00:00
Fix feature gate only being checked on first repr attr.
This commit is contained in:
parent
e8aef7cae1
commit
d22ae75c9d
@ -455,6 +455,11 @@ pub fn find_by_name<'a>(attrs: &'a [Attribute], name: &str) -> Option<&'a Attrib
|
|||||||
attrs.iter().find(|attr| attr.check_name(name))
|
attrs.iter().find(|attr| attr.check_name(name))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn filter_by_name<'a>(attrs: &'a [Attribute], name: &'a str)
|
||||||
|
-> impl Iterator<Item = &'a Attribute> {
|
||||||
|
attrs.iter().filter(move |attr| attr.check_name(name))
|
||||||
|
}
|
||||||
|
|
||||||
pub fn first_attr_value_str_by_name(attrs: &[Attribute], name: &str) -> Option<Symbol> {
|
pub fn first_attr_value_str_by_name(attrs: &[Attribute], name: &str) -> Option<Symbol> {
|
||||||
attrs.iter()
|
attrs.iter()
|
||||||
.find(|at| at.check_name(name))
|
.find(|at| at.check_name(name))
|
||||||
|
@ -1625,7 +1625,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ast::ItemKind::Struct(..) => {
|
ast::ItemKind::Struct(..) => {
|
||||||
if let Some(attr) = attr::find_by_name(&i.attrs[..], "repr") {
|
for attr in attr::filter_by_name(&i.attrs[..], "repr") {
|
||||||
for item in attr.meta_item_list().unwrap_or_else(Vec::new) {
|
for item in attr.meta_item_list().unwrap_or_else(Vec::new) {
|
||||||
if item.check_name("simd") {
|
if item.check_name("simd") {
|
||||||
gate_feature_post!(&self, repr_simd, attr.span,
|
gate_feature_post!(&self, repr_simd, attr.span,
|
||||||
|
@ -11,4 +11,8 @@
|
|||||||
#[repr(simd)] //~ error: SIMD types are experimental
|
#[repr(simd)] //~ error: SIMD types are experimental
|
||||||
struct Foo(u64, u64);
|
struct Foo(u64, u64);
|
||||||
|
|
||||||
|
#[repr(C)]
|
||||||
|
#[repr(simd)] //~ error: SIMD types are experimental
|
||||||
|
struct Bar(u64, u64);
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -6,6 +6,14 @@ LL | #[repr(simd)] //~ error: SIMD types are experimental
|
|||||||
|
|
|
|
||||||
= help: add #![feature(repr_simd)] to the crate attributes to enable
|
= help: add #![feature(repr_simd)] to the crate attributes to enable
|
||||||
|
|
||||||
error: aborting due to previous error
|
error[E0658]: SIMD types are experimental and possibly buggy (see issue #27731)
|
||||||
|
--> $DIR/feature-gate-repr-simd.rs:15:1
|
||||||
|
|
|
||||||
|
LL | #[repr(simd)] //~ error: SIMD types are experimental
|
||||||
|
| ^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= help: add #![feature(repr_simd)] to the crate attributes to enable
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0658`.
|
For more information about this error, try `rustc --explain E0658`.
|
||||||
|
@ -11,4 +11,8 @@
|
|||||||
#[repr(packed(1))] //~ error: the `#[repr(packed(n))]` attribute is experimental
|
#[repr(packed(1))] //~ error: the `#[repr(packed(n))]` attribute is experimental
|
||||||
struct Foo(u64);
|
struct Foo(u64);
|
||||||
|
|
||||||
|
#[repr(C)]
|
||||||
|
#[repr(packed(1))] //~ error: the `#[repr(packed(n))]` attribute is experimental
|
||||||
|
struct Bar(u64);
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -6,6 +6,14 @@ LL | #[repr(packed(1))] //~ error: the `#[repr(packed(n))]` attribute is experim
|
|||||||
|
|
|
|
||||||
= help: add #![feature(repr_packed)] to the crate attributes to enable
|
= help: add #![feature(repr_packed)] to the crate attributes to enable
|
||||||
|
|
||||||
error: aborting due to previous error
|
error[E0658]: the `#[repr(packed(n))]` attribute is experimental (see issue #33158)
|
||||||
|
--> $DIR/feature-gate-repr_packed.rs:15:1
|
||||||
|
|
|
||||||
|
LL | #[repr(packed(1))] //~ error: the `#[repr(packed(n))]` attribute is experimental
|
||||||
|
| ^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= help: add #![feature(repr_packed)] to the crate attributes to enable
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0658`.
|
For more information about this error, try `rustc --explain E0658`.
|
||||||
|
Loading…
Reference in New Issue
Block a user