about summary refs log tree commit diff
path: root/src/libsyntax/ext
diff options
context:
space:
mode:
authorJared Roesch <roeschinc@gmail.com>2015-07-28 09:00:32 -0700
committerJared Roesch <roeschinc@gmail.com>2015-08-04 16:05:07 -0700
commit15e7aa79f5280047a34e47628fb50c3eb3c898ad (patch)
treeeb51b90108465e517b574bb07ee0bd30825999dd /src/libsyntax/ext
parent0bb5a1a8249e3c5b97b4e60a2ab37cc5a2300306 (diff)
downloadrust-15e7aa79f5280047a34e47628fb50c3eb3c898ad.tar.gz
rust-15e7aa79f5280047a34e47628fb50c3eb3c898ad.zip
Add feature gate
Diffstat (limited to 'src/libsyntax/ext')
-rw-r--r--src/libsyntax/ext/expand.rs48
1 files changed, 29 insertions, 19 deletions
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index cd340fc9189..aadc3cfbafe 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -1555,29 +1555,39 @@ fn expand_and_rename_method(sig: ast::MethodSig, body: P<ast::Block>,
 pub fn expand_type(t: P<ast::Ty>, fld: &mut MacroExpander) -> P<ast::Ty> {
     let t = match t.node.clone() {
         ast::Ty_::TyMac(mac) => {
-            let expanded_ty = match expand_mac_invoc(mac, t.span,
-                                                     |r| r.make_ty(),
-                                                     mark_ty,
-                                                     fld) {
-                Some(ty) => ty,
-                None => {
-                    return DummyResult::raw_ty(t.span);
-                }
-            };
-
-            // Keep going, outside-in.
-            //
-            let fully_expanded = fld.fold_ty(expanded_ty);
-            fld.cx.bt_pop();
+            if fld.cx.ecfg.features.unwrap().type_macros {
+                let expanded_ty = match expand_mac_invoc(mac, t.span,
+                                                         |r| r.make_ty(),
+                                                         mark_ty,
+                                                         fld) {
+                    Some(ty) => ty,
+                    None => {
+                        return DummyResult::raw_ty(t.span);
+                    }
+                };
 
-            fully_expanded.map(|t| ast::Ty {
-                id: ast::DUMMY_NODE_ID,
-                node: t.node,
-                span: t.span,
-            })
+                // Keep going, outside-in.
+                //
+                let fully_expanded = fld.fold_ty(expanded_ty);
+                fld.cx.bt_pop();
+
+                fully_expanded.map(|t| ast::Ty {
+                    id: ast::DUMMY_NODE_ID,
+                    node: t.node,
+                    span: t.span,
+                    })
+            } else {
+                feature_gate::emit_feature_err(
+                    &fld.cx.parse_sess.span_diagnostic,
+                    "type_macros",
+                    t.span,
+                    "type macros are experimental (see tracking issue: 27336)");
+                t
+            }
         }
         _ => t
     };
+
     fold::noop_fold_ty(t, fld)
 }