]> git.lizzy.rs Git - rust.git/blobdiff - src/libsyntax/feature_gate.rs
Control usage of `!` through a feature gate.
[rust.git] / src / libsyntax / feature_gate.rs
index ad52184a6dcb0cd658cb607b31fc5a97352ad3b6..efedc7229e64c951e3536bd2b36cec1a7d207449 100644 (file)
@@ -284,7 +284,10 @@ pub fn new() -> Features {
 
     // Allows tuple structs and variants in more contexts,
     // Permits numeric fields in struct expressions and patterns.
-    (active, relaxed_adts, "1.12.0", Some(35626))
+    (active, relaxed_adts, "1.12.0", Some(35626)),
+
+    // The `!` type
+    (active, bang_type, "1.13.0", Some(35121))
 );
 
 declare_features! (
@@ -963,11 +966,25 @@ fn visit_ty(&mut self, ty: &ast::Ty) {
                 gate_feature_post!(&self, conservative_impl_trait, ty.span,
                                    "`impl Trait` is experimental");
             }
+            ast::TyKind::Empty => {
+                gate_feature_post!(&self, bang_type, ty.span,
+                                   "The `!` type is experimental");
+            },
             _ => {}
         }
         visit::walk_ty(self, ty)
     }
 
+    fn visit_fn_ret_ty(&mut self, ret_ty: &ast::FunctionRetTy) {
+        if let ast::FunctionRetTy::Ty(ref output_ty) = *ret_ty {
+            match output_ty.node {
+                ast::TyKind::Empty => return,
+                _ => (),
+            };
+            visit::walk_ty(self, output_ty)
+        }
+    }
+
     fn visit_expr(&mut self, e: &ast::Expr) {
         match e.node {
             ast::ExprKind::Box(_) => {