about summary refs log tree commit diff
diff options
context:
space:
mode:
authorKevin Ballard <kevin@sb.org>2014-08-26 20:00:41 -0700
committerJakub Wieczorek <jakub@jakub.cc>2014-09-30 18:54:03 +0200
commit8a609521007c0c0c37d8d2396085631c08ad5232 (patch)
tree5b3ab3e9d4c89dc07227651e2f952576c2c6010f
parent976438f78fdce8092430f4c81ca272293c48f1a0 (diff)
downloadrust-8a609521007c0c0c37d8d2396085631c08ad5232.tar.gz
rust-8a609521007c0c0c37d8d2396085631c08ad5232.zip
Move `if let` behind a feature gate
-rw-r--r--src/doc/reference.md2
-rw-r--r--src/doc/rust.md2
-rw-r--r--src/libsyntax/feature_gate.rs6
-rw-r--r--src/test/compile-fail/if-let.rs2
-rw-r--r--src/test/compile-fail/lint-unnecessary-parens.rs1
-rw-r--r--src/test/run-pass/if-let.rs2
6 files changed, 13 insertions, 2 deletions
diff --git a/src/doc/reference.md b/src/doc/reference.md
index 21da810a300..04ebcf9a3fb 100644
--- a/src/doc/reference.md
+++ b/src/doc/reference.md
@@ -2441,6 +2441,8 @@ The currently implemented features of the reference compiler are:
 * `default_type_params` - Allows use of default type parameters. The future of
                           this feature is uncertain.
 
+* `if_let` - Allows use of the `if let` desugaring syntax.
+
 * `intrinsics` - Allows use of the "rust-intrinsics" ABI. Compiler intrinsics
                  are inherently unstable and no promise about them is made.
 
diff --git a/src/doc/rust.md b/src/doc/rust.md
index 7f02260cd2c..c5dd95902fc 100644
--- a/src/doc/rust.md
+++ b/src/doc/rust.md
@@ -1,3 +1,3 @@
 % The Rust Reference Manual
 
-The manual has moved, and is now called [the reference](reference.html).
+The manual has moved, and is now called [the reference](reference.html).
\ No newline at end of file
diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs
index 1c6ee8acc94..fac4244228a 100644
--- a/src/libsyntax/feature_gate.rs
+++ b/src/libsyntax/feature_gate.rs
@@ -71,6 +71,8 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
     ("associated_types", Active),
     ("visible_private_types", Active),
 
+    ("if_let", Active),
+
     // if you change this list without updating src/doc/rust.md, cmr will be sad
 
     // A temporary feature gate used to enable parser extensions needed
@@ -356,6 +358,10 @@ impl<'a, 'v> Visitor<'v> for Context<'a> {
                                   e.span,
                                   "tuple indexing is experimental");
             }
+            ast::ExprIfLet(..) => {
+                self.gate_feature("if_let", e.span,
+                                  "`if let` desugaring is experimental");
+            }
             _ => {}
         }
         visit::walk_expr(self, e);
diff --git a/src/test/compile-fail/if-let.rs b/src/test/compile-fail/if-let.rs
index 88b6854bb1d..b82fb7a94c9 100644
--- a/src/test/compile-fail/if-let.rs
+++ b/src/test/compile-fail/if-let.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![feature(macro_rules)]
+#![feature(macro_rules,if_let)]
 
 fn macros() {
     macro_rules! foo{
diff --git a/src/test/compile-fail/lint-unnecessary-parens.rs b/src/test/compile-fail/lint-unnecessary-parens.rs
index 82fb42571af..3c962ebf216 100644
--- a/src/test/compile-fail/lint-unnecessary-parens.rs
+++ b/src/test/compile-fail/lint-unnecessary-parens.rs
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 #![deny(unnecessary_parens)]
+#![feature(if_let)]
 
 #[deriving(Eq, PartialEq)]
 struct X { y: bool }
diff --git a/src/test/run-pass/if-let.rs b/src/test/run-pass/if-let.rs
index a6886bf9850..4bf3a85677c 100644
--- a/src/test/run-pass/if-let.rs
+++ b/src/test/run-pass/if-let.rs
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#![feature(if_let)]
+
 pub fn main() {
     let x = Some(3i);
     if let Some(y) = x {