Skip to content

Commit

Permalink
Rollup merge of rust-lang#99332 - jyn514:stabilize-label-break-value,…
Browse files Browse the repository at this point in the history
… r=petrochenkov

Stabilize `#![feature(label_break_value)]`

See the stabilization report in rust-lang#48594 (comment).
  • Loading branch information
JohnTitor authored Aug 24, 2022
2 parents addacb5 + 31e3944 commit bf3fc63
Show file tree
Hide file tree
Showing 39 changed files with 61 additions and 108 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_ast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#![feature(const_default_impls)]
#![feature(const_trait_impl)]
#![feature(if_let_guard)]
#![feature(label_break_value)]
#![cfg_attr(bootstrap, feature(label_break_value))]
#![feature(min_specialization)]
#![feature(negative_impls)]
#![feature(slice_internals)]
Expand Down
9 changes: 0 additions & 9 deletions compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -647,14 +647,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
ast::ExprKind::TryBlock(_) => {
gate_feature_post!(&self, try_blocks, e.span, "`try` expression is experimental");
}
ast::ExprKind::Block(_, Some(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 @@ -823,7 +815,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session) {
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");
gate_all!(box_syntax, "box expression syntax is experimental; you can call `Box::new` instead");
gate_all!(type_ascription, "type ascription is experimental");

Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_error_codes/src/error_codes/E0695.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ A `break` statement without a label appeared inside a labeled block.
Erroneous code example:

```compile_fail,E0695
# #![feature(label_break_value)]
loop {
'a: {
break;
Expand All @@ -14,7 +13,6 @@ loop {
Make sure to always label the `break`:

```
# #![feature(label_break_value)]
'l: loop {
'a: {
break 'l;
Expand All @@ -25,7 +23,6 @@ Make sure to always label the `break`:
Or if you want to `break` the labeled block:

```
# #![feature(label_break_value)]
loop {
'a: {
break 'a;
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ declare_features! (
/// Allows some increased flexibility in the name resolution rules,
/// especially around globs and shadowing (RFC 1560).
(accepted, item_like_imports, "1.15.0", Some(35120), None),
/// Allows `'a: { break 'a; }`.
(accepted, label_break_value, "1.65.0", Some(48594), None),
/// Allows `if/while p && let q = r && ...` chains.
(accepted, let_chains, "1.64.0", Some(53667), None),
/// Allows `break {expr}` with a value inside `loop`s.
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,6 @@ declare_features! (
(active, intra_doc_pointers, "1.51.0", Some(80896), None),
/// Allows `#[instruction_set(_)]` attribute
(active, isa_attribute, "1.48.0", Some(74727), None),
/// Allows `'a: { break 'a; }`.
(active, label_break_value, "1.28.0", Some(48594), None),
// Allows setting the threshold for the `large_assignments` lint.
(active, large_assignments, "1.52.0", Some(83518), None),
/// Allows `let...else` statements.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#![feature(box_patterns)]
#![feature(control_flow_enum)]
#![feature(extend_one)]
#![feature(label_break_value)]
#![cfg_attr(bootstrap, feature(label_break_value))]
#![feature(let_else)]
#![feature(min_specialization)]
#![feature(never_type)]
Expand Down
4 changes: 0 additions & 4 deletions compiler/rustc_parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2014,10 +2014,6 @@ impl<'a> Parser<'a> {
}
}

if let Some(label) = opt_label {
self.sess.gated_spans.gate(sym::label_break_value, label.ident.span);
}

if self.token.is_whole_block() {
self.sess.emit_err(InvalidBlockMacroSegment {
span: self.token.span,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_trait_selection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#![feature(control_flow_enum)]
#![feature(drain_filter)]
#![feature(hash_drain_filter)]
#![feature(label_break_value)]
#![cfg_attr(bootstrap, feature(label_break_value))]
#![feature(let_else)]
#![feature(if_let_guard)]
#![feature(never_type)]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ This API is completely unstable and subject to change.
#![feature(if_let_guard)]
#![feature(is_sorted)]
#![feature(iter_intersperse)]
#![feature(label_break_value)]
#![cfg_attr(bootstrap, feature(label_break_value))]
#![feature(let_else)]
#![feature(min_specialization)]
#![feature(never_type)]
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@
#![feature(dropck_eyepatch)]
#![feature(exhaustive_patterns)]
#![feature(intra_doc_pointers)]
#![feature(label_break_value)]
#![cfg_attr(bootstrap, feature(label_break_value))]
#![feature(lang_items)]
#![feature(let_else)]
#![feature(linkage)]
Expand Down
5 changes: 0 additions & 5 deletions src/test/ui/feature-gates/feature-gate-label_break_value.rs

This file was deleted.

12 changes: 0 additions & 12 deletions src/test/ui/feature-gates/feature-gate-label_break_value.stderr

This file was deleted.

1 change: 0 additions & 1 deletion src/test/ui/for-loop-while/label_break_value.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// run-pass
#![allow(dead_code)]
#![allow(unused_assignments)]
#![feature(label_break_value)]

// Test control flow to follow label_break_value semantics
fn label_break(a: bool, b: bool) -> u32 {
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/for-loop-while/label_break_value_invalid.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![crate_type = "lib"]
#![feature(label_break_value)]

fn lbv_macro_test_hygiene_respected() {
macro_rules! mac2 {
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/for-loop-while/label_break_value_invalid.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0426]: use of undeclared label `'a`
--> $DIR/label_break_value_invalid.rs:7:19
--> $DIR/label_break_value_invalid.rs:6:19
|
LL | break 'a $val;
| ^^ undeclared label `'a`
Expand All @@ -10,7 +10,7 @@ LL | mac2!(2);
= note: this error originates in the macro `mac2` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0426]: use of undeclared label `'a`
--> $DIR/label_break_value_invalid.rs:29:19
--> $DIR/label_break_value_invalid.rs:28:19
|
LL | let x: u8 = mac3!('b: {
| -- a label with a similar name is reachable
Expand All @@ -22,7 +22,7 @@ LL | break 'a 3;
| help: try using similarly named label: `'b`

error[E0426]: use of undeclared label `'a`
--> $DIR/label_break_value_invalid.rs:34:29
--> $DIR/label_break_value_invalid.rs:33:29
|
LL | let x: u8 = mac3!(break 'a 4);
| ^^ undeclared label `'a`
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/issues/issue-62480.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(label_break_value)]

fn main() {
// This used to ICE during liveness check because `target_id` passed to
// `propagate_through_expr` would be the closure and not the `loop`, which wouldn't be found in
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/issues/issue-62480.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0767]: use of unreachable label `'a`
--> $DIR/issue-62480.rs:8:18
--> $DIR/issue-62480.rs:6:18
|
LL | 'a: {
| -- unreachable label defined here
Expand All @@ -9,7 +9,7 @@ LL | || break 'a
= note: labels are unreachable through functions, closures, async blocks and modules

error[E0267]: `break` inside of a closure
--> $DIR/issue-62480.rs:8:12
--> $DIR/issue-62480.rs:6:12
|
LL | || break 'a
| -- ^^^^^^^^ cannot `break` inside of a closure
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/label/label_break_value_continue.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(label_break_value)]
#![allow(unused_labels)]

// Simple continue pointing to an unlabeled break should yield in an error
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/label/label_break_value_continue.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error[E0695]: unlabeled `continue` inside of a labeled block
--> $DIR/label_break_value_continue.rs:7:9
--> $DIR/label_break_value_continue.rs:6:9
|
LL | continue;
| ^^^^^^^^ `continue` statements that would diverge to or through a labeled block need to bear a label

error[E0696]: `continue` pointing to a labeled block
--> $DIR/label_break_value_continue.rs:14:9
--> $DIR/label_break_value_continue.rs:13:9
|
LL | / 'b: {
LL | | continue 'b;
Expand All @@ -14,7 +14,7 @@ LL | | }
| |_____- labeled block the `continue` points to

error[E0695]: unlabeled `continue` inside of a labeled block
--> $DIR/label_break_value_continue.rs:22:13
--> $DIR/label_break_value_continue.rs:21:13
|
LL | continue;
| ^^^^^^^^ `continue` statements that would diverge to or through a labeled block need to bear a label
Expand Down
9 changes: 8 additions & 1 deletion src/test/ui/label/label_break_value_desugared_break.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// compile-flags: --edition 2018
#![feature(label_break_value, try_blocks)]
#![feature(try_blocks)]

// run-pass
fn main() {
Expand All @@ -9,4 +9,11 @@ fn main() {
break 'foo;
}
};

'foo: {
let _: Result<(), ()> = try {
Err(())?;
break 'foo;
};
}
}
1 change: 0 additions & 1 deletion src/test/ui/label/label_break_value_illegal_uses.fixed
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// run-rustfix
#![feature(label_break_value)]

// These are forbidden occurrences of label-break-value

Expand Down
1 change: 0 additions & 1 deletion src/test/ui/label/label_break_value_illegal_uses.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// run-rustfix
#![feature(label_break_value)]

// These are forbidden occurrences of label-break-value

Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/label/label_break_value_illegal_uses.stderr
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
error: block label not supported here
--> $DIR/label_break_value_illegal_uses.rs:8:12
--> $DIR/label_break_value_illegal_uses.rs:7:12
|
LL | unsafe 'b: {}
| ^^^ not supported here

error: block label not supported here
--> $DIR/label_break_value_illegal_uses.rs:12:13
--> $DIR/label_break_value_illegal_uses.rs:11:13
|
LL | if true 'b: {}
| ^^^ not supported here

error: block label not supported here
--> $DIR/label_break_value_illegal_uses.rs:16:21
--> $DIR/label_break_value_illegal_uses.rs:15:21
|
LL | if true {} else 'b: {}
| ^^^ not supported here

error: block label not supported here
--> $DIR/label_break_value_illegal_uses.rs:20:17
--> $DIR/label_break_value_illegal_uses.rs:19:17
|
LL | match false 'b: {
| ^^^ not supported here
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/label/label_break_value_unlabeled_break.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(label_break_value)]
#![allow(unused_labels)]

// Simple unlabeled break should yield in an error
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/label/label_break_value_unlabeled_break.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error[E0695]: unlabeled `break` inside of a labeled block
--> $DIR/label_break_value_unlabeled_break.rs:7:9
--> $DIR/label_break_value_unlabeled_break.rs:6:9
|
LL | break;
| ^^^^^ `break` statements that would diverge to or through a labeled block need to bear a label

error[E0695]: unlabeled `break` inside of a labeled block
--> $DIR/label_break_value_unlabeled_break.rs:15:13
--> $DIR/label_break_value_unlabeled_break.rs:14:13
|
LL | break;
| ^^^^^ `break` statements that would diverge to or through a labeled block need to bear a label
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/lint/unused_labels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

// check-pass

#![feature(label_break_value)]
#![warn(unused_labels)]

fn main() {
Expand Down
20 changes: 10 additions & 10 deletions src/test/ui/lint/unused_labels.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
warning: label name `'many_used_shadowed` shadows a label name that is already in scope
--> $DIR/unused_labels.rs:62:9
--> $DIR/unused_labels.rs:61:9
|
LL | 'many_used_shadowed: for _ in 0..10 {
| ------------------- first declared here
Expand All @@ -8,55 +8,55 @@ LL | 'many_used_shadowed: for _ in 0..10 {
| ^^^^^^^^^^^^^^^^^^^ label `'many_used_shadowed` already in scope

warning: unused label
--> $DIR/unused_labels.rs:11:5
--> $DIR/unused_labels.rs:10:5
|
LL | 'unused_while_label: while 0 == 0 {
| ^^^^^^^^^^^^^^^^^^^
|
note: the lint level is defined here
--> $DIR/unused_labels.rs:8:9
--> $DIR/unused_labels.rs:7:9
|
LL | #![warn(unused_labels)]
| ^^^^^^^^^^^^^

warning: unused label
--> $DIR/unused_labels.rs:16:5
--> $DIR/unused_labels.rs:15:5
|
LL | 'unused_while_let_label: while let Some(_) = opt {
| ^^^^^^^^^^^^^^^^^^^^^^^

warning: unused label
--> $DIR/unused_labels.rs:20:5
--> $DIR/unused_labels.rs:19:5
|
LL | 'unused_for_label: for _ in 0..10 {
| ^^^^^^^^^^^^^^^^^

warning: unused label
--> $DIR/unused_labels.rs:36:9
--> $DIR/unused_labels.rs:35:9
|
LL | 'unused_loop_label_inner_2: for _ in 0..10 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: unused label
--> $DIR/unused_labels.rs:42:5
--> $DIR/unused_labels.rs:41:5
|
LL | 'unused_loop_label_outer_3: for _ in 0..10 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: unused label
--> $DIR/unused_labels.rs:60:5
--> $DIR/unused_labels.rs:59:5
|
LL | 'many_used_shadowed: for _ in 0..10 {
| ^^^^^^^^^^^^^^^^^^^

warning: unused label
--> $DIR/unused_labels.rs:72:5
--> $DIR/unused_labels.rs:71:5
|
LL | 'unused_loop_label: loop {
| ^^^^^^^^^^^^^^^^^^

warning: unused label
--> $DIR/unused_labels.rs:78:5
--> $DIR/unused_labels.rs:77:5
|
LL | 'unused_block_label: {
| ^^^^^^^^^^^^^^^^^^^
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/macros/stringify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#![feature(decl_macro)]
#![feature(generators)]
#![feature(half_open_range_patterns)]
#![feature(label_break_value)]
#![feature(more_qualified_paths)]
#![feature(raw_ref_op)]
#![feature(trait_alias)]
Expand Down
Loading

0 comments on commit bf3fc63

Please sign in to comment.