Skip to content

Commit

Permalink
pre-expansion gate label_break_value
Browse files Browse the repository at this point in the history
  • Loading branch information
Centril committed Oct 23, 2019
1 parent 66995a6 commit 137ded8
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
7 changes: 1 addition & 6 deletions src/libsyntax/feature_gate/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,12 +514,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
"type ascription is experimental");
}
}
ast::ExprKind::Block(_, opt_label) => {
if let Some(label) = opt_label {
gate_feature_post!(&self, label_break_value, label.ident.span,
"labels on blocks are unstable");
}
}
_ => {}
}
visit::walk_expr(self, e)
Expand Down Expand Up @@ -814,6 +808,7 @@ pub fn check_crate(krate: &ast::Crate,
gate_all!(box_patterns, "box pattern syntax is experimental");
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");

visit::walk_crate(&mut visitor, krate);
}
Expand Down
4 changes: 4 additions & 0 deletions src/libsyntax/parse/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,10 @@ impl<'a> Parser<'a> {
blk_mode: BlockCheckMode,
outer_attrs: ThinVec<Attribute>,
) -> PResult<'a, P<Expr>> {
if let Some(label) = opt_label {
self.sess.gated_spans.label_break_value.borrow_mut().push(label.ident.span);
}

self.expect(&token::OpenDelim(token::Brace))?;

let mut attrs = outer_attrs;
Expand Down
2 changes: 2 additions & 0 deletions src/libsyntax/sess.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ crate struct GatedSpans {
pub exclusive_range_pattern: Lock<Vec<Span>>,
/// Spans collected for gating `try_blocks`, e.g. `try { a? + b? }`.
pub try_blocks: Lock<Vec<Span>>,
/// Spans collected for gating `label_break_value`, e.g. `'label: { ... }`.
pub label_break_value: Lock<Vec<Span>>,
}

/// Info about a parsing session.
Expand Down
5 changes: 4 additions & 1 deletion src/test/ui/feature-gates/feature-gate-label_break_value.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
pub fn main() {
#[cfg(FALSE)]
pub fn foo() {
'a: { //~ ERROR labels on blocks are unstable
break 'a;
}
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0658]: labels on blocks are unstable
--> $DIR/feature-gate-label_break_value.rs:2:5
--> $DIR/feature-gate-label_break_value.rs:3:5
|
LL | 'a: {
| ^^
Expand Down

0 comments on commit 137ded8

Please sign in to comment.