Move placement_in_syntax gated feature checking from expansion to the post-expansion visitor

This commit is contained in:
Jeffrey Seyfried 2016-05-21 08:39:33 +00:00
parent 82b49cd200
commit ba8b9324d6
2 changed files with 3 additions and 16 deletions

View File

@ -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
@ -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);

View File

@ -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);