about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlavio Percoco <flaper87@gmail.com>2014-12-29 13:52:43 +0100
committerFlavio Percoco <flaper87@gmail.com>2015-01-04 23:16:14 +0100
commitc062fac835e64c1ebf71da784714de562eac732c (patch)
tree3075cf76bce0387becc1d852354303b45fbf72ab
parent8b883ab2681e34ef94575f45c6c0e6c2bca23ab7 (diff)
downloadrust-c062fac835e64c1ebf71da784714de562eac732c.tar.gz
rust-c062fac835e64c1ebf71da784714de562eac732c.zip
Put negative trait implemtations behind a feature gate
-rw-r--r--src/libsyntax/feature_gate.rs15
-rw-r--r--src/test/compile-fail/syntax-trait-polarity-feature-gate.rs20
-rw-r--r--src/test/compile-fail/syntax-trait-polarity.rs2
-rw-r--r--src/test/pretty/trait-polarity.rs2
-rw-r--r--src/test/run-pass/syntax-trait-polarity.rs2
5 files changed, 40 insertions, 1 deletions
diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs
index 29f8ff9e812..f8ac34cfe29 100644
--- a/src/libsyntax/feature_gate.rs
+++ b/src/libsyntax/feature_gate.rs
@@ -84,6 +84,9 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
     // A way to temporarily opt out of the new orphan rules. This will *never* be accepted.
     ("old_orphan_check", Deprecated),
 
+    // OIBIT specific features
+    ("optin_builtin_traits", Active),
+
     // These are used to test this portion of the compiler, they don't actually
     // mean anything
     ("test_accepted_feature", Accepted),
@@ -291,7 +294,17 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
                 }
             }
 
-            ast::ItemImpl(_, _, _, _, _, ref items) => {
+            ast::ItemImpl(_, polarity, _, _, _, ref items) => {
+                match polarity {
+                    ast::ImplPolarity::Negative => {
+                        self.gate_feature("optin_builtin_traits",
+                                          i.span,
+                                          "negative trait bounds are not yet fully implemented; \
+                                          use marker types for now");
+                    },
+                    _ => {}
+                }
+
                 if attr::contains_name(i.attrs[],
                                        "unsafe_destructor") {
                     self.gate_feature("unsafe_destructor",
diff --git a/src/test/compile-fail/syntax-trait-polarity-feature-gate.rs b/src/test/compile-fail/syntax-trait-polarity-feature-gate.rs
new file mode 100644
index 00000000000..e6dc712137f
--- /dev/null
+++ b/src/test/compile-fail/syntax-trait-polarity-feature-gate.rs
@@ -0,0 +1,20 @@
+// 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.
+
+use std::kinds::Send;
+
+struct TestType;
+
+trait TestTrait {}
+
+unsafe impl !Send for TestType {}
+//~^ ERROR negative trait bounds
+
+fn main() {}
diff --git a/src/test/compile-fail/syntax-trait-polarity.rs b/src/test/compile-fail/syntax-trait-polarity.rs
index dc01fbaefbd..3c84bc26298 100644
--- a/src/test/compile-fail/syntax-trait-polarity.rs
+++ b/src/test/compile-fail/syntax-trait-polarity.rs
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#![feature(optin_builtin_traits)]
+
 use std::kinds::Send;
 
 struct TestType;
diff --git a/src/test/pretty/trait-polarity.rs b/src/test/pretty/trait-polarity.rs
index dbc4c263571..47c36ac7a40 100644
--- a/src/test/pretty/trait-polarity.rs
+++ b/src/test/pretty/trait-polarity.rs
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#![feature(optin_builtin_traits)]
+
 // pp-exact
 
 trait UnsafeTrait {
diff --git a/src/test/run-pass/syntax-trait-polarity.rs b/src/test/run-pass/syntax-trait-polarity.rs
index 263fc4c0231..021cfedf06f 100644
--- a/src/test/run-pass/syntax-trait-polarity.rs
+++ b/src/test/run-pass/syntax-trait-polarity.rs
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#![feature(optin_builtin_traits)]
+
 use std::kinds::Send;
 
 struct TestType;