diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-10-23 22:19:13 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-23 22:19:13 +0200 |
| commit | 6bb7449fdb0c1abb597b6a3d3ab77efab466c937 (patch) | |
| tree | 6428b7e5f4b51ee8252c77c1c356d366cc16a5b9 /src/test | |
| parent | a1514b475854e858a3de95b3806d5795e0d6d72e (diff) | |
| parent | 0585475efdd1cac3a1143f4a349f3de057635efc (diff) | |
| download | rust-6bb7449fdb0c1abb597b6a3d3ab77efab466c937.tar.gz rust-6bb7449fdb0c1abb597b6a3d3ab77efab466c937.zip | |
Rollup merge of #65518 - estebank:i-want-to-break-free, r=eddyb
Avoid ICE when checking `Destination` of `break` inside a closure Fix #65383, fix #62480. This is a `[regression-from-stable-to-stable]` and a fairly small change to avoid the ICE by properly handling this case.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/break-outside-loop.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/break-outside-loop.stderr | 10 |
2 files changed, 17 insertions, 1 deletions
diff --git a/src/test/ui/break-outside-loop.rs b/src/test/ui/break-outside-loop.rs index c424c25c646..a6f9d0423d0 100644 --- a/src/test/ui/break-outside-loop.rs +++ b/src/test/ui/break-outside-loop.rs @@ -22,4 +22,12 @@ fn main() { let rs: Foo = Foo{t: pth}; let unconstrained = break; //~ ERROR: `break` outside of a loop + + // This used to ICE because `target_id` passed to `check_expr_break` would be the closure and + // not the `loop`, which failed in the call to `find_breakable`. (#65383) + 'lab: loop { + || { + break 'lab; //~ ERROR `break` inside of a closure + }; + } } diff --git a/src/test/ui/break-outside-loop.stderr b/src/test/ui/break-outside-loop.stderr index 8b686356055..8e300fd848d 100644 --- a/src/test/ui/break-outside-loop.stderr +++ b/src/test/ui/break-outside-loop.stderr @@ -33,7 +33,15 @@ error[E0268]: `break` outside of a loop LL | let unconstrained = break; | ^^^^^ cannot `break` outside of a loop -error: aborting due to 5 previous errors +error[E0267]: `break` inside of a closure + --> $DIR/break-outside-loop.rs:30:13 + | +LL | || { + | -- enclosing closure +LL | break 'lab; + | ^^^^^^^^^^ cannot `break` inside of a closure + +error: aborting due to 6 previous errors Some errors have detailed explanations: E0267, E0268. For more information about an error, try `rustc --explain E0267`. |
