From 28b987b99a32dfac004643200a9414ee832afa1c Mon Sep 17 00:00:00 2001 From: David Manescu Date: Thu, 23 Jan 2014 12:25:22 +1100 Subject: [PATCH] Feature gate #[simd] Fixes #11721 --- src/librustc/front/feature_gate.rs | 8 ++++++++ src/libstd/lib.rs | 3 ++- src/libstd/unstable/simd.rs | 10 ++++++++++ src/test/compile-fail/gated-simd.rs | 14 ++++++++++++++ src/test/compile-fail/simd-experimental.rs | 19 +++++++++++++++++++ src/test/compile-fail/simd-type.rs | 2 ++ src/test/run-pass/simd-binop.rs | 2 ++ src/test/run-pass/simd-type.rs | 4 ++++ 8 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 src/test/compile-fail/gated-simd.rs create mode 100644 src/test/compile-fail/simd-experimental.rs diff --git a/src/librustc/front/feature_gate.rs b/src/librustc/front/feature_gate.rs index 3c6a348c900..a0d7b1dee12 100644 --- a/src/librustc/front/feature_gate.rs +++ b/src/librustc/front/feature_gate.rs @@ -47,6 +47,7 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[ ("macro_registrar", Active), ("log_syntax", Active), ("trace_macros", Active), + ("simd", Active), // These are used to test this portion of the compiler, they don't actually // mean anything @@ -171,6 +172,13 @@ impl Visitor<()> for Context { } } + ast::ItemStruct(..) => { + if attr::contains_name(i.attrs, "simd") { + self.gate_feature("simd", i.span, + "SIMD types are experimental and possibly buggy"); + } + } + _ => {} } diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 4f13a517878..17b6c24773a 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -52,13 +52,14 @@ html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://static.rust-lang.org/doc/master")]; -#[feature(macro_rules, globs, asm, managed_boxes, thread_local, link_args)]; +#[feature(macro_rules, globs, asm, managed_boxes, thread_local, link_args, simd)]; // Don't link to std. We are std. #[no_std]; #[deny(non_camel_case_types)]; #[deny(missing_doc)]; +#[allow(unknown_features)]; // When testing libstd, bring in libuv as the I/O backend so tests can print // things and all of the std::io tests have an I/O interface to run on top diff --git a/src/libstd/unstable/simd.rs b/src/libstd/unstable/simd.rs index a05f6e8af5a..1029e5fdbd3 100644 --- a/src/libstd/unstable/simd.rs +++ b/src/libstd/unstable/simd.rs @@ -12,32 +12,42 @@ #[allow(non_camel_case_types)]; +#[experimental] #[simd] pub struct i8x16(i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8); +#[experimental] #[simd] pub struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16); +#[experimental] #[simd] pub struct i32x4(i32, i32, i32, i32); +#[experimental] #[simd] pub struct i64x2(i64, i64); +#[experimental] #[simd] pub struct u8x16(u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8); +#[experimental] #[simd] pub struct u16x8(u16, u16, u16, u16, u16, u16, u16, u16); +#[experimental] #[simd] pub struct u32x4(u32, u32, u32, u32); +#[experimental] #[simd] pub struct u64x2(u64, u64); +#[experimental] #[simd] pub struct f32x4(f32, f32, f32, f32); +#[experimental] #[simd] pub struct f64x2(f64, f64); diff --git a/src/test/compile-fail/gated-simd.rs b/src/test/compile-fail/gated-simd.rs new file mode 100644 index 00000000000..a000b91dfde --- /dev/null +++ b/src/test/compile-fail/gated-simd.rs @@ -0,0 +1,14 @@ +// Copyright 2014 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. + +#[simd] +pub struct i64x2(i64, i64); //~ ERROR: SIMD types are experimental + +fn main() {} \ No newline at end of file diff --git a/src/test/compile-fail/simd-experimental.rs b/src/test/compile-fail/simd-experimental.rs new file mode 100644 index 00000000000..2ed4317d52d --- /dev/null +++ b/src/test/compile-fail/simd-experimental.rs @@ -0,0 +1,19 @@ +// Copyright 2014 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. + +// xfail-test FIXME #11741 tuple structs ignore stability attributes + +#[deny(experimental)]; + +use std::unstable::simd; + +fn main() { + let _ = simd::i64x2(0, 0); //~ ERROR: experimental +} diff --git a/src/test/compile-fail/simd-type.rs b/src/test/compile-fail/simd-type.rs index 8387b2bc723..266c2a9c453 100644 --- a/src/test/compile-fail/simd-type.rs +++ b/src/test/compile-fail/simd-type.rs @@ -1,3 +1,5 @@ +#[feature(simd)]; + #[simd] struct vec4(T, T, T, T); //~ ERROR SIMD vector cannot be generic diff --git a/src/test/run-pass/simd-binop.rs b/src/test/run-pass/simd-binop.rs index 74502b54d8e..ed75924fe89 100644 --- a/src/test/run-pass/simd-binop.rs +++ b/src/test/run-pass/simd-binop.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#[allow(experimental)]; + use std::unstable::simd::{i32x4, f32x4}; fn test_int(e: i32) -> i32 { diff --git a/src/test/run-pass/simd-type.rs b/src/test/run-pass/simd-type.rs index 643daad397c..029478b4d59 100644 --- a/src/test/run-pass/simd-type.rs +++ b/src/test/run-pass/simd-type.rs @@ -1,3 +1,7 @@ +// xfail-fast feature doesn't work + +#[feature(simd)]; + #[simd] struct RGBA { r: f32,