about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/test/compile-fail-fulldeps/gated-quote.rs50
-rw-r--r--src/test/compile-fail/gated-link-args.rs19
-rw-r--r--src/test/compile-fail/gated-link-llvm-intrinsics.rs19
-rw-r--r--src/test/compile-fail/gated-plugin_registrar.rs8
-rw-r--r--src/test/compile-fail/gated-thread-local.rs25
-rw-r--r--src/test/compile-fail/gated-unsafe-destructor.rs23
6 files changed, 142 insertions, 2 deletions
diff --git a/src/test/compile-fail-fulldeps/gated-quote.rs b/src/test/compile-fail-fulldeps/gated-quote.rs
new file mode 100644
index 00000000000..6a5cd88a591
--- /dev/null
+++ b/src/test/compile-fail-fulldeps/gated-quote.rs
@@ -0,0 +1,50 @@
+// 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.
+
+// Test that `quote`-related macro are gated by `quote` feature gate.
+
+// (To sanity-check the code, uncomment this.)
+// #![feature(quote)]
+
+// FIXME the error message that is current emitted seems pretty bad.
+
+#![feature(rustc_private)]
+#![allow(dead_code, unused_imports, unused_variables)]
+
+#[macro_use]
+extern crate syntax;
+
+use syntax::ast;
+use syntax::codemap::Span;
+use syntax::parse;
+
+struct ParseSess;
+
+impl ParseSess {
+    fn cfg(&self) -> ast::CrateConfig { loop { } }
+    fn parse_sess<'a>(&'a self) -> &'a parse::ParseSess { loop { } }
+    fn call_site(&self) -> Span { loop { } }
+    fn ident_of(&self, st: &str) -> ast::Ident { loop { } }
+    fn name_of(&self, st: &str) -> ast::Name { loop { } }
+}
+
+pub fn main() {
+    let ecx = &ParseSess;
+    let x = quote_tokens!(ecx, 3);   //~ ERROR macro undefined: 'quote_tokens!'
+    let x = quote_expr!(ecx, 3);     //~ ERROR macro undefined: 'quote_expr!'
+    let x = quote_ty!(ecx, 3);       //~ ERROR macro undefined: 'quote_ty!'
+    let x = quote_method!(ecx, 3);   //~ ERROR macro undefined: 'quote_method!'
+    let x = quote_item!(ecx, 3);     //~ ERROR macro undefined: 'quote_item!'
+    let x = quote_pat!(ecx, 3);      //~ ERROR macro undefined: 'quote_pat!'
+    let x = quote_arm!(ecx, 3);      //~ ERROR macro undefined: 'quote_arm!'
+    let x = quote_stmt!(ecx, 3);     //~ ERROR macro undefined: 'quote_stmt!'
+    let x = quote_matcher!(ecx, 3);  //~ ERROR macro undefined: 'quote_matcher!'
+    let x = quote_attr!(ecx, 3);     //~ ERROR macro undefined: 'quote_attr!'
+}
diff --git a/src/test/compile-fail/gated-link-args.rs b/src/test/compile-fail/gated-link-args.rs
new file mode 100644
index 00000000000..c8845ced2fc
--- /dev/null
+++ b/src/test/compile-fail/gated-link-args.rs
@@ -0,0 +1,19 @@
+// 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.
+
+// Test that `#[link_args]` attribute is gated by `link_args`
+// feature gate.
+
+#[link_args = "aFdEfSeVEEE"]
+extern {}
+//~^ ERROR the `link_args` attribute is not portable across platforms
+//~| HELP add #![feature(link_args)] to the crate attributes to enable
+
+fn main() { }
diff --git a/src/test/compile-fail/gated-link-llvm-intrinsics.rs b/src/test/compile-fail/gated-link-llvm-intrinsics.rs
new file mode 100644
index 00000000000..716ea9f8dba
--- /dev/null
+++ b/src/test/compile-fail/gated-link-llvm-intrinsics.rs
@@ -0,0 +1,19 @@
+// 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.
+
+extern {
+    #[link_name = "llvm.sqrt.f32"]
+    fn sqrt(x: f32) -> f32;
+    //~^ ERROR linking to LLVM intrinsics is experimental
+    //~| HELP add #![feature(link_llvm_intrinsics)] to the crate attributes
+}
+
+fn main(){
+}
diff --git a/src/test/compile-fail/gated-plugin_registrar.rs b/src/test/compile-fail/gated-plugin_registrar.rs
index f6e11ffd9e5..d716c53e1d1 100644
--- a/src/test/compile-fail/gated-plugin_registrar.rs
+++ b/src/test/compile-fail/gated-plugin_registrar.rs
@@ -8,8 +8,12 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// Test that `#[plugin_registrar]` attribute is gated by `plugin_registrar`
+// feature gate.
+
 // the registration function isn't typechecked yet
 #[plugin_registrar]
-pub fn registrar() {} //~ ERROR compiler plugins are experimental
-
+pub fn registrar() {}
+//~^ ERROR compiler plugins are experimental
+//~| HELP add #![feature(plugin_registrar)] to the crate attributes to enable
 fn main() {}
diff --git a/src/test/compile-fail/gated-thread-local.rs b/src/test/compile-fail/gated-thread-local.rs
new file mode 100644
index 00000000000..f355c6562c8
--- /dev/null
+++ b/src/test/compile-fail/gated-thread-local.rs
@@ -0,0 +1,25 @@
+// 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.
+
+// Test that `#[thread_local]` attribute is gated by `thread_local`
+// feature gate.
+//
+// (Note that the `thread_local!` macro is explicitly *not* gated; it
+// is given permission to expand into this unstable attribute even
+// when the surrounding context does not have permission to use it.)
+
+#[thread_local] //~ ERROR `#[thread_local]` is an experimental feature
+static FOO: i32 = 3;
+
+pub fn main() {
+    FOO.with(|x| {
+        println!("x: {}", x);
+    });
+}
diff --git a/src/test/compile-fail/gated-unsafe-destructor.rs b/src/test/compile-fail/gated-unsafe-destructor.rs
new file mode 100644
index 00000000000..6024fef9fb8
--- /dev/null
+++ b/src/test/compile-fail/gated-unsafe-destructor.rs
@@ -0,0 +1,23 @@
+// 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.
+
+// Test that `#[unsafe_destructor]` attribute is gated by `unsafe_destructor`
+// feature gate.
+
+struct D<'a>(&'a u32);
+
+#[unsafe_destructor]
+impl<'a> Drop for D<'a> {
+    //~^ ERROR `#[unsafe_destructor]` allows too many unsafe patterns
+    fn drop(&mut self) { }
+}
+//~^ HELP: add #![feature(unsafe_destructor)] to the crate attributes to enable
+
+pub fn main() { }