variants: Vec<VariantDefData<'tcx, 'container>>) -> Self {
let mut flags = AdtFlags::NO_ADT_FLAGS;
let attrs = tcx.get_attrs(did);
- if attrs.iter().any(|item| item.check_name("fundamental")) {
+ if attr::contains_name(&attrs, "fundamental") {
flags = flags | AdtFlags::IS_FUNDAMENTAL;
}
- if attrs.iter().any(|item| item.check_name("simd")) {
+ if tcx.lookup_simd(did) {
flags = flags | AdtFlags::IS_SIMD;
}
if Some(did) == tcx.lang_items.phantom_data() {
/// Determine whether an item is annotated with `#[simd]`
pub fn lookup_simd(&self, did: DefId) -> bool {
self.has_attr(did, "simd")
+ || self.lookup_repr_hints(did).contains(&attr::ReprSimd)
}
/// Obtain the representation annotation for a struct definition.
attr::ReprPacked => {
cx.tcx().sess.bug("range_to_inttype: found ReprPacked on an enum");
}
+ attr::ReprSimd => {
+ cx.tcx().sess.bug("range_to_inttype: found ReprSimd on an enum");
+ }
}
for &ity in attempts {
if bounds_usable(cx, ity, bounds) {
"discriminant type specified here");
}
}
+ attr::ReprSimd => {
+ ccx.tcx.sess.bug("range_to_inttype: found ReprSimd on an enum");
+ }
attr::ReprPacked => {
ccx.tcx.sess.bug("range_to_inttype: found ReprPacked on an enum");
}
// Can't use "extern" because it's not a lexical identifier.
"C" => Some(ReprExtern),
"packed" => Some(ReprPacked),
+ "simd" => Some(ReprSimd),
_ => match int_type_of_word(&word) {
Some(ity) => Some(ReprInt(item.span, ity)),
None => {
ReprInt(Span, IntType),
ReprExtern,
ReprPacked,
+ ReprSimd,
}
impl ReprAttr {
ReprAny => false,
ReprInt(_sp, ity) => ity.is_ffi_safe(),
ReprExtern => true,
- ReprPacked => false
+ ReprPacked => false,
+ ReprSimd => true,
}
}
}
for a in type_attrs {
for r in &attr::find_repr_attrs(diagnostic, a) {
repr_type_name = match *r {
- attr::ReprAny | attr::ReprPacked => continue,
+ attr::ReprAny | attr::ReprPacked | attr::ReprSimd => continue,
attr::ReprExtern => "i32",
attr::ReprInt(_, attr::SignedInt(ast::TyIs)) => "isize",
// Allows macros to appear in the type position.
("type_macros", "1.3.0", Active),
+
+ // allow `repr(simd)`, and importing the various simd intrinsics
+ ("simd_basics", "1.3.0", Active),
];
// (changing above list without updating src/doc/reference.md makes @cmr sad)
pub allow_box: bool,
pub allow_pushpop_unsafe: bool,
pub simd_ffi: bool,
+ pub simd_basics: bool,
pub unmarked_api: bool,
pub negate_unsigned: bool,
/// spans of #![feature] attrs for stable language features. for error reporting
allow_box: false,
allow_pushpop_unsafe: false,
simd_ffi: false,
+ simd_basics: false,
unmarked_api: false,
negate_unsigned: false,
declared_stable_lang_features: Vec::new(),
if attr::contains_name(&i.attrs[..], "simd") {
self.gate_feature("simd", i.span,
"SIMD types are experimental and possibly buggy");
+ self.context.span_handler.span_warn(i.span,
+ "the `#[simd]` attribute is deprecated, \
+ use `#[repr(simd)]` instead");
+ }
+ for attr in &i.attrs {
+ if attr.name() == "repr" {
+ for item in attr.meta_item_list().unwrap_or(&[]) {
+ if item.name() == "simd" {
+ self.gate_feature("simd_basics", i.span,
+ "SIMD types are experimental and possibly buggy");
+
+ }
+ }
+ }
}
}
allow_box: cx.has_feature("box_syntax"),
allow_pushpop_unsafe: cx.has_feature("pushpop_unsafe"),
simd_ffi: cx.has_feature("simd_ffi"),
+ simd_basics: cx.has_feature("simd_basics"),
unmarked_api: cx.has_feature("unmarked_api"),
negate_unsigned: cx.has_feature("negate_unsigned"),
declared_stable_lang_features: accepted_features,
--- /dev/null
+// 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[repr(simd)]
+struct Foo(u64, u64); //~ error: SIMD types are experimental
+
+fn main() {}