Skip to content

Commit ba8b932

Browse files
committed
Move placement_in_syntax gated feature checking from expansion to the post-expansion visitor
1 parent 82b49cd commit ba8b932

File tree

2 files changed

+3
-16
lines changed

2 files changed

+3
-16
lines changed

src/libsyntax/ext/expand.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ impl_macro_generable! {
7070
}
7171

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

7675
// 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> {
7978
expand_mac_invoc(mac, None, attrs.into_attr_vec(), span, fld)
8079
}
8180

82-
ast::ExprKind::InPlace(placer, value_expr) => {
83-
// Ensure feature-gate is enabled
84-
if !fld.cx.ecfg.features.unwrap().placement_in_syntax {
85-
feature_gate::emit_feature_err(
86-
&fld.cx.parse_sess.span_diagnostic, "placement_in_syntax", expr_span,
87-
feature_gate::GateIssue::Language, feature_gate::EXPLAIN_PLACEMENT_IN
88-
);
89-
}
90-
91-
let placer = fld.fold_expr(placer);
92-
let value_expr = fld.fold_expr(value_expr);
93-
fld.cx.expr(span, ast::ExprKind::InPlace(placer, value_expr))
94-
.with_attrs(fold_thin_attrs(attrs, fld))
95-
}
96-
9781
ast::ExprKind::While(cond, body, opt_ident) => {
9882
let cond = fld.fold_expr(cond);
9983
let (body, opt_ident) = expand_loop_block(body, opt_ident, fld);

src/libsyntax/feature_gate.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,9 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
997997
ast::ExprKind::Try(..) => {
998998
gate_feature_post!(&self, question_mark, e.span, "the `?` operator is not stable");
999999
}
1000+
ast::ExprKind::InPlace(..) => {
1001+
gate_feature_post!(&self, placement_in_syntax, e.span, EXPLAIN_PLACEMENT_IN);
1002+
}
10001003
_ => {}
10011004
}
10021005
visit::walk_expr(self, e);

0 commit comments

Comments
 (0)