Skip to content

Commit 137ded8

Browse files
committed
pre-expansion gate label_break_value
1 parent 66995a6 commit 137ded8

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

Diff for: src/libsyntax/feature_gate/check.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -514,12 +514,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
514514
"type ascription is experimental");
515515
}
516516
}
517-
ast::ExprKind::Block(_, opt_label) => {
518-
if let Some(label) = opt_label {
519-
gate_feature_post!(&self, label_break_value, label.ident.span,
520-
"labels on blocks are unstable");
521-
}
522-
}
523517
_ => {}
524518
}
525519
visit::walk_expr(self, e)
@@ -814,6 +808,7 @@ pub fn check_crate(krate: &ast::Crate,
814808
gate_all!(box_patterns, "box pattern syntax is experimental");
815809
gate_all!(exclusive_range_pattern, "exclusive range pattern syntax is experimental");
816810
gate_all!(try_blocks, "`try` blocks are unstable");
811+
gate_all!(label_break_value, "labels on blocks are unstable");
817812

818813
visit::walk_crate(&mut visitor, krate);
819814
}

Diff for: src/libsyntax/parse/parser/expr.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1260,6 +1260,10 @@ impl<'a> Parser<'a> {
12601260
blk_mode: BlockCheckMode,
12611261
outer_attrs: ThinVec<Attribute>,
12621262
) -> PResult<'a, P<Expr>> {
1263+
if let Some(label) = opt_label {
1264+
self.sess.gated_spans.label_break_value.borrow_mut().push(label.ident.span);
1265+
}
1266+
12631267
self.expect(&token::OpenDelim(token::Brace))?;
12641268

12651269
let mut attrs = outer_attrs;

Diff for: src/libsyntax/sess.rs

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ crate struct GatedSpans {
4646
pub exclusive_range_pattern: Lock<Vec<Span>>,
4747
/// Spans collected for gating `try_blocks`, e.g. `try { a? + b? }`.
4848
pub try_blocks: Lock<Vec<Span>>,
49+
/// Spans collected for gating `label_break_value`, e.g. `'label: { ... }`.
50+
pub label_break_value: Lock<Vec<Span>>,
4951
}
5052

5153
/// Info about a parsing session.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
pub fn main() {
1+
#[cfg(FALSE)]
2+
pub fn foo() {
23
'a: { //~ ERROR labels on blocks are unstable
34
break 'a;
45
}
56
}
7+
8+
fn main() {}

Diff for: src/test/ui/feature-gates/feature-gate-label_break_value.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0658]: labels on blocks are unstable
2-
--> $DIR/feature-gate-label_break_value.rs:2:5
2+
--> $DIR/feature-gate-label_break_value.rs:3:5
33
|
44
LL | 'a: {
55
| ^^

0 commit comments

Comments
 (0)