<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rust/src/test/ui/for-loop-while, branch auto</title>
<subtitle>https://github.com/rust-lang/rust
</subtitle>
<id>http://git.dreamy.place/mirrors/rust/atom?h=auto</id>
<link rel='self' href='http://git.dreamy.place/mirrors/rust/atom?h=auto'/>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/'/>
<updated>2023-01-11T09:32:08+00:00</updated>
<entry>
<title>Move /src/test to /tests</title>
<updated>2023-01-11T09:32:08+00:00</updated>
<author>
<name>Albert Larsan</name>
<email>74931857+albertlarsan68@users.noreply.github.com</email>
</author>
<published>2023-01-05T08:13:28+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=cf2dff2b1e3fa55fa5415d524200070d0d7aacfe'/>
<id>urn:sha1:cf2dff2b1e3fa55fa5415d524200070d0d7aacfe</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Specify that `break` cannot be used outside of loop *or* labeled block</title>
<updated>2022-11-05T01:12:58+00:00</updated>
<author>
<name>clubby789</name>
<email>jamie@hill-daniel.co.uk</email>
</author>
<published>2022-11-05T01:11:50+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=2f882c014f3bfabb811177d24bfb72e3f6b6d271'/>
<id>urn:sha1:2f882c014f3bfabb811177d24bfb72e3f6b6d271</id>
<content type='text'>
</content>
</entry>
<entry>
<title>bless ui tests</title>
<updated>2022-10-01T10:03:06+00:00</updated>
<author>
<name>Maybe Waffle</name>
<email>waffle.lapkin@gmail.com</email>
</author>
<published>2022-09-18T15:55:36+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=13b67fb9d2849b4e59d5651b0e4fc82ef8b088aa'/>
<id>urn:sha1:13b67fb9d2849b4e59d5651b0e4fc82ef8b088aa</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Stabilize `#![feature(label_break_value)]`</title>
<updated>2022-08-24T02:14:12+00:00</updated>
<author>
<name>Joshua Nelson</name>
<email>jnelson@cloudflare.com</email>
</author>
<published>2022-07-14T13:30:38+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=31e39446ec2f251efbcaf9eb22c80e93021f9bbc'/>
<id>urn:sha1:31e39446ec2f251efbcaf9eb22c80e93021f9bbc</id>
<content type='text'>
 # Stabilization proposal

The feature was implemented in https://github.com/rust-lang/rust/pull/50045 by est31 and has been in nightly since 2018-05-16 (over 4 years now).
There are [no open issues][issue-label] other than the tracking issue. There is a strong consensus that `break` is the right keyword and we should not use `return`.

There have been several concerns raised about this feature on the tracking issue (other than the one about tests, which has been fixed, and an interaction with try blocks, which has been fixed).
1. nrc's original comment about cost-benefit analysis: https://github.com/rust-lang/rust/issues/48594#issuecomment-422235234
2. joshtriplett's comments about seeing use cases: https://github.com/rust-lang/rust/issues/48594#issuecomment-422281176
3. withoutboats's comments that Rust does not need more control flow constructs: https://github.com/rust-lang/rust/issues/48594#issuecomment-450050630

Many different examples of code that's simpler using this feature have been provided:
- A lexer by rpjohnst which must repeat code without label-break-value: https://github.com/rust-lang/rust/issues/48594#issuecomment-422502014
- A snippet by SergioBenitez which avoids using a new function and adding several new return points to a function: https://github.com/rust-lang/rust/issues/48594#issuecomment-427628251. This particular case would also work if `try` blocks were stabilized (at the cost of making the code harder to optimize).
- Several examples by JohnBSmith: https://github.com/rust-lang/rust/issues/48594#issuecomment-434651395
- Several examples by Centril: https://github.com/rust-lang/rust/issues/48594#issuecomment-440154733
- An example by petrochenkov where this is used in the compiler itself to avoid duplicating error checking code: https://github.com/rust-lang/rust/issues/48594#issuecomment-443557569
- Amanieu recently provided another example related to complex conditions, where try blocks would not have helped: https://github.com/rust-lang/rust/issues/48594#issuecomment-1184213006

Additionally, petrochenkov notes that this is strictly more powerful than labelled loops due to macros which accidentally exit a loop instead of being consumed by the macro matchers: https://github.com/rust-lang/rust/issues/48594#issuecomment-450246249

nrc later resolved their concern, mostly because of the aforementioned macro problems.
joshtriplett suggested that macros could be able to generate IR directly
(https://github.com/rust-lang/rust/issues/48594#issuecomment-451685983) but there are no open RFCs,
and the design space seems rather speculative.

joshtriplett later resolved his concerns, due to a symmetry between this feature and existing labelled break: https://github.com/rust-lang/rust/issues/48594#issuecomment-632960804

withoutboats has regrettably left the language team.

joshtriplett later posted that the lang team would consider starting an FCP given a stabilization report: https://github.com/rust-lang/rust/issues/48594#issuecomment-1111269353

[issue-label]: https://github.com/rust-lang/rust/issues?q=is%3Aissue+is%3Aopen+label%3AF-label_break_value+

 ## Report

+ Feature gate:
    - https://github.com/rust-lang/rust/blob/d695a497bbf4b20d2580b75075faa80230d41667/src/test/ui/feature-gates/feature-gate-label_break_value.rs
+ Diagnostics:
    - https://github.com/rust-lang/rust/blob/6b2d3d5f3cd1e553d87b5496632132565b6779d3/compiler/rustc_parse/src/parser/diagnostics.rs#L2629
    - https://github.com/rust-lang/rust/blob/f65bf0b2bb1a99f73095c01a118f3c37d3ee614c/compiler/rustc_resolve/src/diagnostics.rs#L749
    - https://github.com/rust-lang/rust/blob/f65bf0b2bb1a99f73095c01a118f3c37d3ee614c/compiler/rustc_resolve/src/diagnostics.rs#L1001
    - https://github.com/rust-lang/rust/blob/111df9e6eda1d752233482c1309d00d20a4bbf98/compiler/rustc_passes/src/loops.rs#L254
    - https://github.com/rust-lang/rust/blob/d695a497bbf4b20d2580b75075faa80230d41667/compiler/rustc_parse/src/parser/expr.rs#L2079
    - https://github.com/rust-lang/rust/blob/d695a497bbf4b20d2580b75075faa80230d41667/compiler/rustc_parse/src/parser/expr.rs#L1569
+ Tests:
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/label/label_break_value_continue.rs
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/label/label_break_value_unlabeled_break.rs
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/label/label_break_value_illegal_uses.rs
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/lint/unused_labels.rs
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/run-pass/for-loop-while/label_break_value.rs

 ## Interactions with other features

Labels follow the hygiene of local variables.

label-break-value is permitted within `try` blocks:
```rust
let _: Result&lt;(), ()&gt; = try {
    'foo: {
        Err(())?;
        break 'foo;
    }
};
```

label-break-value is disallowed within closures, generators, and async blocks:
```rust
'a: {
    || break 'a
    //~^ ERROR use of unreachable label `'a`
    //~| ERROR `break` inside of a closure
}
```

label-break-value is disallowed on [_BlockExpression_]; it can only occur as a [_LoopExpression_]:
```rust
fn labeled_match() {
    match false 'b: { //~ ERROR block label not supported here
        _ =&gt; {}
    }
}

macro_rules! m {
    ($b:block) =&gt; {
        'lab: $b; //~ ERROR cannot use a `block` macro fragment here
        unsafe $b; //~ ERROR cannot use a `block` macro fragment here
        |x: u8| -&gt; () $b; //~ ERROR cannot use a `block` macro fragment here
    }
}

fn foo() {
    m!({});
}
```

[_BlockExpression_]: https://doc.rust-lang.org/nightly/reference/expressions/block-expr.html
[_LoopExpression_]: https://doc.rust-lang.org/nightly/reference/expressions/loop-expr.html
</content>
</entry>
<entry>
<title>implement #98982</title>
<updated>2022-08-05T17:28:00+00:00</updated>
<author>
<name>Yiming Lei</name>
<email>yiming.lei@futurewei.com</email>
</author>
<published>2022-08-03T04:46:07+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=9815667b8b59e5351c257f7a62f6c0874fabd7ca'/>
<id>urn:sha1:9815667b8b59e5351c257f7a62f6c0874fabd7ca</id>
<content type='text'>
when loop as tail expression for miss match type E0308 error, recursively get
the return statement and add diagnostic information on it
use rustc_hir::intravisit to collect the return expression
	modified:   compiler/rustc_typeck/src/check/coercion.rs
	new file:   src/test/ui/typeck/issue-98982.rs
	new file:   src/test/ui/typeck/issue-98982.stderr
</content>
</entry>
<entry>
<title>Mention first and last macro in backtrace</title>
<updated>2022-07-19T03:07:54+00:00</updated>
<author>
<name>Michael Goulet</name>
<email>michael@errs.io</email>
</author>
<published>2022-06-21T02:25:52+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=01b2379e4902658de68fcdca2a15b48fe4d57875'/>
<id>urn:sha1:01b2379e4902658de68fcdca2a15b48fe4d57875</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Rebase fallout.</title>
<updated>2022-06-02T17:24:32+00:00</updated>
<author>
<name>Camille GILLOT</name>
<email>gillot.camille@gmail.com</email>
</author>
<published>2022-05-05T18:49:48+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=a265c49b252a932b06a94d5715013c8311989139'/>
<id>urn:sha1:a265c49b252a932b06a94d5715013c8311989139</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Add more tests for label-break-value</title>
<updated>2022-05-03T19:09:52+00:00</updated>
<author>
<name>Joshua Nelson</name>
<email>jnelson@cloudflare.com</email>
</author>
<published>2022-05-03T19:07:36+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=cd63b22e80e61fc4deb3da85a733d6c9266783e1'/>
<id>urn:sha1:cd63b22e80e61fc4deb3da85a733d6c9266783e1</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Move some tests to more reasonable directories</title>
<updated>2021-11-18T15:09:34+00:00</updated>
<author>
<name>Caio</name>
<email>c410.f3r@gmail.com</email>
</author>
<published>2021-11-18T15:09:34+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=41d9abd76cd514aca23e3409fe6896a3a7d61d1a'/>
<id>urn:sha1:41d9abd76cd514aca23e3409fe6896a3a7d61d1a</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Move some tests to more reasonable directories</title>
<updated>2021-11-14T17:38:42+00:00</updated>
<author>
<name>Caio</name>
<email>c410.f3r@gmail.com</email>
</author>
<published>2021-11-14T17:38:42+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=ab5434f9b8d3937fe33f813b3f8e1a43a4657781'/>
<id>urn:sha1:ab5434f9b8d3937fe33f813b3f8e1a43a4657781</id>
<content type='text'>
</content>
</entry>
</feed>
