-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix ICE when there is a continue in a labeled block #121682
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f2e19d0
Continue inside a labeled block now lowers to a error when to lowerin…
SarthakSingh31 06f33dc
Removed redundant check for label being block for continue
SarthakSingh31 d5b4bb1
Updated stderr outputs
SarthakSingh31 f490a0e
Removed unused feature from test
SarthakSingh31 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
tests/ui/lowering/cont-in-block/cont-in-fn-issue-113379.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Fixes: #113379 | ||
|
||
trait Trait<const S: usize> {} | ||
|
||
struct Bug<T> | ||
where | ||
T: Trait< | ||
{ | ||
'b: { | ||
//~^ ERROR [E0308] | ||
continue 'b; //~ ERROR [E0696] | ||
} | ||
}, | ||
>, | ||
{ | ||
t: T, | ||
} | ||
|
||
fn f() -> impl Sized { | ||
'b: { | ||
continue 'b; | ||
//~^ ERROR [E0696] | ||
} | ||
} | ||
|
||
fn main() { | ||
f(); | ||
} |
33 changes: 33 additions & 0 deletions
33
tests/ui/lowering/cont-in-block/cont-in-fn-issue-113379.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
error[E0696]: `continue` pointing to a labeled block | ||
--> $DIR/cont-in-fn-issue-113379.rs:11:17 | ||
| | ||
LL | / 'b: { | ||
LL | | | ||
LL | | continue 'b; | ||
| | ^^^^^^^^^^^ labeled blocks cannot be `continue`'d | ||
LL | | } | ||
| |_____________- labeled block the `continue` points to | ||
|
||
error[E0696]: `continue` pointing to a labeled block | ||
--> $DIR/cont-in-fn-issue-113379.rs:21:9 | ||
| | ||
LL | / 'b: { | ||
LL | | continue 'b; | ||
| | ^^^^^^^^^^^ labeled blocks cannot be `continue`'d | ||
LL | | | ||
LL | | } | ||
| |_____- labeled block the `continue` points to | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/cont-in-fn-issue-113379.rs:9:13 | ||
| | ||
LL | / 'b: { | ||
LL | | | ||
LL | | continue 'b; | ||
LL | | } | ||
| |_____________^ expected `usize`, found `()` | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
Some errors have detailed explanations: E0308, E0696. | ||
For more information about an error, try `rustc --explain E0308`. |
4 changes: 3 additions & 1 deletion
4
tests/crashes/121623.rs → ...n-block/cont-in-match-arm-issue-121623.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
//@ known-bug: #121623 | ||
// Fixes: #121623 | ||
|
||
fn main() { | ||
match () { | ||
_ => 'b: { | ||
continue 'b; | ||
//~^ ERROR [E0696] | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
tests/ui/lowering/cont-in-block/cont-in-match-arm-issue-121623.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error[E0696]: `continue` pointing to a labeled block | ||
--> $DIR/cont-in-match-arm-issue-121623.rs:6:13 | ||
| | ||
LL | _ => 'b: { | ||
| ______________- | ||
LL | | continue 'b; | ||
| | ^^^^^^^^^^^ labeled blocks cannot be `continue`'d | ||
LL | | | ||
LL | | } | ||
| |_________- labeled block the `continue` points to | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0696`. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we do the same thing with
break
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are doing the same for
break
here https://github.com/rust-lang/rust/blob/master/compiler/rustc_ast_lowering/src/expr.rs#L1455There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait, maybe we are not doing it. This just assumes that the label is a loop https://github.com/rust-lang/rust/blob/master/compiler/rustc_ast_lowering/src/expr.rs#L1446-L1448