}
-const EXPLAIN_BOX_SYNTAX: &str =
- "box expression syntax is experimental; you can call `Box::new` instead";
-
pub const EXPLAIN_STMT_ATTR_SYNTAX: &str =
"attributes on expressions are experimental";
fn visit_expr(&mut self, e: &'a ast::Expr) {
match e.kind {
- ast::ExprKind::Box(_) => {
- gate_feature_post!(&self, box_syntax, e.span, EXPLAIN_BOX_SYNTAX);
- }
ast::ExprKind::Type(..) => {
// To avoid noise about type ascription in common syntax errors, only emit if it
// is the *only* error.
gate_all!(exclusive_range_pattern, "exclusive range pattern syntax is experimental");
gate_all!(try_blocks, "`try` blocks are unstable");
gate_all!(label_break_value, "labels on blocks are unstable");
+ gate_all!(box_syntax, "box expression syntax is experimental; you can call `Box::new` instead");
visit::walk_crate(&mut visitor, krate);
}
self.bump();
let e = self.parse_prefix_expr(None);
let (span, e) = self.interpolated_or_expr_span(e)?;
- (lo.to(span), ExprKind::Box(e))
+ let span = lo.to(span);
+ self.sess.gated_spans.box_syntax.borrow_mut().push(span);
+ (span, ExprKind::Box(e))
}
token::Ident(..) if self.token.is_ident_named(sym::not) => {
// `not` is just an ordinary identifier in Rust-the-language,
pub try_blocks: Lock<Vec<Span>>,
/// Spans collected for gating `label_break_value`, e.g. `'label: { ... }`.
pub label_break_value: Lock<Vec<Span>>,
+ /// Spans collected for gating `box_syntax`, e.g. `box $expr`.
+ pub box_syntax: Lock<Vec<Span>>,
}
/// Info about a parsing session.