about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/doc/guide-unsafe.md7
-rw-r--r--src/liballoc/lib.rs3
-rw-r--r--src/libcore/lib.rs4
-rw-r--r--src/libnative/lib.rs2
-rw-r--r--src/librlibc/lib.rs2
-rw-r--r--src/librustc/front/feature_gate.rs49
-rw-r--r--src/librustrt/lib.rs3
-rw-r--r--src/libstd/lib.rs5
-rw-r--r--src/test/auxiliary/cci_intrinsic.rs2
-rw-r--r--src/test/auxiliary/lang-item-public.rs1
-rw-r--r--src/test/compile-fail/attr.rs2
-rw-r--r--src/test/compile-fail/bad-mid-path-type-params.rs1
-rw-r--r--src/test/compile-fail/feature-gate-intrinsics-and-lang-items.rs23
-rw-r--r--src/test/compile-fail/lint-dead-code-1.rs1
-rw-r--r--src/test/compile-fail/privacy1.rs2
-rw-r--r--src/test/run-pass/intrinsic-alignment.rs1
-rw-r--r--src/test/run-pass/intrinsic-atomics.rs2
-rw-r--r--src/test/run-pass/intrinsic-move-val.rs2
-rw-r--r--src/test/run-pass/intrinsic-uninit.rs2
-rw-r--r--src/test/run-pass/intrinsics-integer.rs2
-rw-r--r--src/test/run-pass/intrinsics-math.rs2
-rw-r--r--src/test/run-pass/rec-align-u32.rs2
-rw-r--r--src/test/run-pass/rec-align-u64.rs2
-rw-r--r--src/test/run-pass/smallest-hello-world.rs1
24 files changed, 106 insertions, 17 deletions
diff --git a/src/doc/guide-unsafe.md b/src/doc/guide-unsafe.md
index def96c62deb..d069cb4d093 100644
--- a/src/doc/guide-unsafe.md
+++ b/src/doc/guide-unsafe.md
@@ -451,6 +451,7 @@ in the same format as a C:
 
 ```
 #![no_std]
+#![feature(lang_items)]
 
 // Pull in the system libc library for what crt0.o likely requires
 extern crate libc;
@@ -477,6 +478,7 @@ compiler's name mangling too:
 ```ignore
 #![no_std]
 #![no_main]
+#![feature(lang_items)]
 
 extern crate libc;
 
@@ -528,6 +530,7 @@ vectors provided from C, using idiomatic Rust practices.
 ```
 #![no_std]
 #![feature(globs)]
+#![feature(lang_items)]
 
 # extern crate libc;
 extern crate core;
@@ -619,6 +622,9 @@ perform efficient pointer arithmetic, one would import those functions
 via a declaration like
 
 ```
+# #![feature(intrinsics)]
+# fn main() {}
+
 extern "rust-intrinsic" {
     fn transmute<T, U>(x: T) -> U;
 
@@ -647,6 +653,7 @@ sugar for dynamic allocations via `malloc` and `free`:
 
 ```
 #![no_std]
+#![feature(lang_items)]
 
 extern crate libc;
 
diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs
index 5368c1d0dc5..e89a9c019bb 100644
--- a/src/liballoc/lib.rs
+++ b/src/liballoc/lib.rs
@@ -69,7 +69,8 @@
        html_root_url = "http://doc.rust-lang.org/")]
 
 #![no_std]
-#![feature(phase, unsafe_destructor)]
+#![feature(lang_items, phase, unsafe_destructor)]
+#![allow(unknown_features)] // NOTE: remove after a stage0 snap
 
 #[phase(plugin, link)]
 extern crate core;
diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs
index 75663d66e61..aa55f204f45 100644
--- a/src/libcore/lib.rs
+++ b/src/libcore/lib.rs
@@ -55,8 +55,10 @@
        html_playground_url = "http://play.rust-lang.org/")]
 
 #![no_std]
-#![feature(globs, macro_rules, managed_boxes, phase, simd, unsafe_destructor)]
+#![feature(globs, intrinsics, lang_items, macro_rules, managed_boxes, phase)]
+#![feature(simd, unsafe_destructor)]
 #![deny(missing_doc)]
+#![allow(unknown_features)] // NOTE: remove after stage0 snapshot
 
 #[cfg(test)] extern crate realcore = "core";
 #[cfg(test)] extern crate libc;
diff --git a/src/libnative/lib.rs b/src/libnative/lib.rs
index 48d03e41848..3438661ffb3 100644
--- a/src/libnative/lib.rs
+++ b/src/libnative/lib.rs
@@ -55,6 +55,8 @@
 
 #![deny(unused_result, unused_must_use)]
 #![allow(non_camel_case_types, deprecated)]
+#![allow(unknown_features)] // NOTE: remove after a stage0 snap
+#![feature(default_type_params, lang_items)]
 
 // NB this crate explicitly does *not* allow glob imports, please seriously
 //    consider whether they're needed before adding that feature here (the
diff --git a/src/librlibc/lib.rs b/src/librlibc/lib.rs
index 8c804d4d254..0d917e20c25 100644
--- a/src/librlibc/lib.rs
+++ b/src/librlibc/lib.rs
@@ -26,6 +26,8 @@
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
        html_root_url = "http://doc.rust-lang.org/")]
+#![feature(intrinsics)]
+#![allow(unknown_features)] // NOTE: remove after stage0 snapshot
 
 #![no_std]
 #![experimental]
diff --git a/src/librustc/front/feature_gate.rs b/src/librustc/front/feature_gate.rs
index 07715684db3..59e52b9359f 100644
--- a/src/librustc/front/feature_gate.rs
+++ b/src/librustc/front/feature_gate.rs
@@ -20,6 +20,8 @@
 
 use middle::lint;
 
+use syntax::abi::RustIntrinsic;
+use syntax::ast::NodeId;
 use syntax::ast;
 use syntax::attr;
 use syntax::attr::AttrMetaMethods;
@@ -51,6 +53,8 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
     ("trace_macros", Active),
     ("concat_idents", Active),
     ("unsafe_destructor", Active),
+    ("intrinsics", Active),
+    ("lang_items", Active),
 
     ("simd", Active),
     ("default_type_params", Active),
@@ -187,13 +191,18 @@ impl<'a> Visitor<()> for Context<'a> {
                 }
             }
 
-            ast::ItemForeignMod(..) => {
+            ast::ItemForeignMod(ref foreign_module) => {
                 if attr::contains_name(i.attrs.as_slice(), "link_args") {
                     self.gate_feature("link_args", i.span,
                                       "the `link_args` attribute is not portable \
                                        across platforms, it is recommended to \
                                        use `#[link(name = \"foo\")]` instead")
                 }
+                if foreign_module.abi == RustIntrinsic {
+                    self.gate_feature("intrinsics",
+                                      i.span,
+                                      "intrinsics are subject to change")
+                }
             }
 
             ast::ItemFn(..) => {
@@ -283,14 +292,10 @@ impl<'a> Visitor<()> for Context<'a> {
     }
 
     fn visit_foreign_item(&mut self, i: &ast::ForeignItem, _: ()) {
-        match i.node {
-            ast::ForeignItemFn(..) | ast::ForeignItemStatic(..) => {
-                if attr::contains_name(i.attrs.as_slice(), "linkage") {
-                    self.gate_feature("linkage", i.span,
-                                      "the `linkage` attribute is experimental \
-                                       and not portable across platforms")
-                }
-            }
+        if attr::contains_name(i.attrs.as_slice(), "linkage") {
+            self.gate_feature("linkage", i.span,
+                              "the `linkage` attribute is experimental \
+                               and not portable across platforms")
         }
         visit::walk_foreign_item(self, i, ())
     }
@@ -338,6 +343,32 @@ impl<'a> Visitor<()> for Context<'a> {
         }
         visit::walk_generics(self, generics, ());
     }
+
+    fn visit_attribute(&mut self, attr: &ast::Attribute, _: ()) {
+        if attr::contains_name([*attr], "lang") {
+            self.gate_feature("lang_items",
+                              attr.span,
+                              "language items are subject to change");
+        }
+    }
+
+    fn visit_fn(&mut self,
+                fn_kind: &visit::FnKind,
+                fn_decl: &ast::FnDecl,
+                block: &ast::Block,
+                span: Span,
+                _: NodeId,
+                (): ()) {
+        match *fn_kind {
+            visit::FkItemFn(_, _, _, ref abi) if *abi == RustIntrinsic => {
+                self.gate_feature("intrinsics",
+                                  span,
+                                  "intrinsics are subject to change")
+            }
+            _ => {}
+        }
+        visit::walk_fn(self, fn_kind, fn_decl, block, span, ());
+    }
 }
 
 pub fn check_crate(sess: &Session, krate: &ast::Crate) {
diff --git a/src/librustrt/lib.rs b/src/librustrt/lib.rs
index 3fdbc962603..34898ea64ac 100644
--- a/src/librustrt/lib.rs
+++ b/src/librustrt/lib.rs
@@ -17,7 +17,8 @@
        html_root_url = "http://doc.rust-lang.org/")]
 
 #![feature(macro_rules, phase, globs, thread_local, managed_boxes, asm)]
-#![feature(linkage, unsafe_destructor)]
+#![feature(linkage, lang_items, unsafe_destructor)]
+#![allow(unknown_features)] // NOTE: remove after stage0 snapshot
 #![no_std]
 #![experimental]
 
diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs
index 03e90bf1089..8106d516dad 100644
--- a/src/libstd/lib.rs
+++ b/src/libstd/lib.rs
@@ -104,13 +104,14 @@
        html_root_url = "http://doc.rust-lang.org/",
        html_playground_url = "http://play.rust-lang.org/")]
 
-#![feature(macro_rules, globs, managed_boxes)]
-#![feature(linkage, default_type_params, phase, unsafe_destructor)]
+#![feature(macro_rules, globs, managed_boxes, linkage)]
+#![feature(default_type_params, phase, lang_items, unsafe_destructor)]
 
 // Don't link to std. We are std.
 #![no_std]
 
 #![allow(deprecated)]
+#![allow(unknown_features)] // NOTE: remove after stage0 snapshot
 #![deny(missing_doc)]
 
 // When testing libstd, bring in libuv as the I/O backend so tests can print
diff --git a/src/test/auxiliary/cci_intrinsic.rs b/src/test/auxiliary/cci_intrinsic.rs
index 35d987480c0..a3a3dbac2b5 100644
--- a/src/test/auxiliary/cci_intrinsic.rs
+++ b/src/test/auxiliary/cci_intrinsic.rs
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#![feature(intrinsics)]
+
 pub mod rusti {
     extern "rust-intrinsic" {
         pub fn atomic_xchg<T>(dst: *mut T, src: T) -> T;
diff --git a/src/test/auxiliary/lang-item-public.rs b/src/test/auxiliary/lang-item-public.rs
index 4b19d291b85..7b84e11ef31 100644
--- a/src/test/auxiliary/lang-item-public.rs
+++ b/src/test/auxiliary/lang-item-public.rs
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 #![no_std]
+#![feature(lang_items)]
 
 #[lang="fail_"]
 fn fail(_: &'static str, _: &'static str, _: uint) -> ! { loop {} }
diff --git a/src/test/compile-fail/attr.rs b/src/test/compile-fail/attr.rs
index b1f7a791f09..4bd61412731 100644
--- a/src/test/compile-fail/attr.rs
+++ b/src/test/compile-fail/attr.rs
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#![feature(lang_items)]
+
 fn main() {}
 
 #![lang(foo)] //~ ERROR an inner attribute is not permitted in this context
diff --git a/src/test/compile-fail/bad-mid-path-type-params.rs b/src/test/compile-fail/bad-mid-path-type-params.rs
index 7ce6f7188b8..3a2a7558657 100644
--- a/src/test/compile-fail/bad-mid-path-type-params.rs
+++ b/src/test/compile-fail/bad-mid-path-type-params.rs
@@ -11,6 +11,7 @@
 // ignore-tidy-linelength
 
 #![no_std]
+#![feature(lang_items)]
 
 #[lang="sized"]
 pub trait Sized {}
diff --git a/src/test/compile-fail/feature-gate-intrinsics-and-lang-items.rs b/src/test/compile-fail/feature-gate-intrinsics-and-lang-items.rs
new file mode 100644
index 00000000000..986d52b1787
--- /dev/null
+++ b/src/test/compile-fail/feature-gate-intrinsics-and-lang-items.rs
@@ -0,0 +1,23 @@
+// 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 <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.
+
+#[lang="foo"]   //~ ERROR language items are subject to change
+trait Foo {}
+
+extern "rust-intrinsic" {   //~ ERROR intrinsics are subject to change
+    fn bar();
+}
+
+extern "rust-intrinsic" fn baz() {  //~ ERROR intrinsics are subject to change
+}
+
+fn main() {
+}
+
diff --git a/src/test/compile-fail/lint-dead-code-1.rs b/src/test/compile-fail/lint-dead-code-1.rs
index 25e5ecde02d..b68a2241e1a 100644
--- a/src/test/compile-fail/lint-dead-code-1.rs
+++ b/src/test/compile-fail/lint-dead-code-1.rs
@@ -13,6 +13,7 @@
 #![allow(non_camel_case_types)]
 #![allow(visible_private_types)]
 #![deny(dead_code)]
+#![feature(lang_items)]
 
 #![crate_type="lib"]
 
diff --git a/src/test/compile-fail/privacy1.rs b/src/test/compile-fail/privacy1.rs
index 83141020b29..6df52c394fc 100644
--- a/src/test/compile-fail/privacy1.rs
+++ b/src/test/compile-fail/privacy1.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![feature(globs)]
+#![feature(globs, lang_items)]
 #![no_std] // makes debugging this test *a lot* easier (during resolve)
 
 #[lang="sized"]
diff --git a/src/test/run-pass/intrinsic-alignment.rs b/src/test/run-pass/intrinsic-alignment.rs
index 12385a26437..84593ececd0 100644
--- a/src/test/run-pass/intrinsic-alignment.rs
+++ b/src/test/run-pass/intrinsic-alignment.rs
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#![feature(intrinsics)]
 
 mod rusti {
     extern "rust-intrinsic" {
diff --git a/src/test/run-pass/intrinsic-atomics.rs b/src/test/run-pass/intrinsic-atomics.rs
index 8fa89303fa9..8a856b14eae 100644
--- a/src/test/run-pass/intrinsic-atomics.rs
+++ b/src/test/run-pass/intrinsic-atomics.rs
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#![feature(intrinsics)]
+
 mod rusti {
     extern "rust-intrinsic" {
         pub fn atomic_cxchg<T>(dst: *mut T, old: T, src: T) -> T;
diff --git a/src/test/run-pass/intrinsic-move-val.rs b/src/test/run-pass/intrinsic-move-val.rs
index 752c9464cf6..84b80d43f09 100644
--- a/src/test/run-pass/intrinsic-move-val.rs
+++ b/src/test/run-pass/intrinsic-move-val.rs
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#![feature(intrinsics)]
+
 use std::mem::transmute;
 
 mod rusti {
diff --git a/src/test/run-pass/intrinsic-uninit.rs b/src/test/run-pass/intrinsic-uninit.rs
index ab6904927e8..34fd8effd49 100644
--- a/src/test/run-pass/intrinsic-uninit.rs
+++ b/src/test/run-pass/intrinsic-uninit.rs
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#![feature(intrinsics)]
+
 mod rusti {
     extern "rust-intrinsic" {
         pub fn uninit<T>() -> T;
diff --git a/src/test/run-pass/intrinsics-integer.rs b/src/test/run-pass/intrinsics-integer.rs
index e31b941f956..5121e2185cb 100644
--- a/src/test/run-pass/intrinsics-integer.rs
+++ b/src/test/run-pass/intrinsics-integer.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![feature(globs)]
+#![feature(globs, intrinsics)]
 
 mod rusti {
     extern "rust-intrinsic" {
diff --git a/src/test/run-pass/intrinsics-math.rs b/src/test/run-pass/intrinsics-math.rs
index 94d53f139cf..164a6845a9f 100644
--- a/src/test/run-pass/intrinsics-math.rs
+++ b/src/test/run-pass/intrinsics-math.rs
@@ -9,7 +9,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![feature(globs, macro_rules)]
+#![feature(globs, macro_rules, intrinsics)]
 
 macro_rules! assert_approx_eq(
     ($a:expr, $b:expr) => ({
diff --git a/src/test/run-pass/rec-align-u32.rs b/src/test/run-pass/rec-align-u32.rs
index 69a4c1cd053..d741b80ef5e 100644
--- a/src/test/run-pass/rec-align-u32.rs
+++ b/src/test/run-pass/rec-align-u32.rs
@@ -10,6 +10,8 @@
 
 // Issue #2303
 
+#![feature(intrinsics)]
+
 extern crate debug;
 
 use std::mem;
diff --git a/src/test/run-pass/rec-align-u64.rs b/src/test/run-pass/rec-align-u64.rs
index 399f947df06..cf254d54793 100644
--- a/src/test/run-pass/rec-align-u64.rs
+++ b/src/test/run-pass/rec-align-u64.rs
@@ -10,6 +10,8 @@
 
 // Issue #2303
 
+#![feature(intrinsics)]
+
 extern crate debug;
 
 use std::mem;
diff --git a/src/test/run-pass/smallest-hello-world.rs b/src/test/run-pass/smallest-hello-world.rs
index 0dbd4c67530..bdba5aa9cfe 100644
--- a/src/test/run-pass/smallest-hello-world.rs
+++ b/src/test/run-pass/smallest-hello-world.rs
@@ -13,6 +13,7 @@
 // Smallest "hello world" with a libc runtime
 
 #![no_std]
+#![feature(intrinsics, lang_items)]
 
 extern crate libc;