Skip to content

Commit

Permalink
Move placement_in_syntax gated feature checking from expansion to t…
Browse files Browse the repository at this point in the history
…he post-expansion visitor
  • Loading branch information
jseyfried committed May 21, 2016
1 parent 82b49cd commit ba8b932
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
16 changes: 0 additions & 16 deletions src/libsyntax/ext/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ impl_macro_generable! {
}

pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
let expr_span = e.span;
return e.and_then(|ast::Expr {id, node, span, attrs}| match node {

// expr_mac should really be expr_ext or something; it's the
Expand All @@ -79,21 +78,6 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
expand_mac_invoc(mac, None, attrs.into_attr_vec(), span, fld)
}

ast::ExprKind::InPlace(placer, value_expr) => {
// Ensure feature-gate is enabled
if !fld.cx.ecfg.features.unwrap().placement_in_syntax {
feature_gate::emit_feature_err(
&fld.cx.parse_sess.span_diagnostic, "placement_in_syntax", expr_span,
feature_gate::GateIssue::Language, feature_gate::EXPLAIN_PLACEMENT_IN
);
}

let placer = fld.fold_expr(placer);
let value_expr = fld.fold_expr(value_expr);
fld.cx.expr(span, ast::ExprKind::InPlace(placer, value_expr))
.with_attrs(fold_thin_attrs(attrs, fld))
}

ast::ExprKind::While(cond, body, opt_ident) => {
let cond = fld.fold_expr(cond);
let (body, opt_ident) = expand_loop_block(body, opt_ident, fld);
Expand Down
3 changes: 3 additions & 0 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,9 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
ast::ExprKind::Try(..) => {
gate_feature_post!(&self, question_mark, e.span, "the `?` operator is not stable");
}
ast::ExprKind::InPlace(..) => {
gate_feature_post!(&self, placement_in_syntax, e.span, EXPLAIN_PLACEMENT_IN);
}
_ => {}
}
visit::walk_expr(self, e);
Expand Down

0 comments on commit ba8b932

Please sign in to comment.