Allow try-blocks in places where an open delim is expected#70657
Merged
bors merged 2 commits intorust-lang:masterfrom Apr 15, 2020
Merged
Allow try-blocks in places where an open delim is expected#70657bors merged 2 commits intorust-lang:masterfrom
try-blocks in places where an open delim is expected#70657bors merged 2 commits intorust-lang:masterfrom
Conversation
Centril
reviewed
Apr 2, 2020
src/librustc_lint/unused.rs
Outdated
Contributor
There was a problem hiding this comment.
This feels like a parser bug to me. We have:
fn is_try_block(&self) -> bool {
self.token.is_keyword(kw::Try) &&
self.look_ahead(1, |t| *t == token::OpenDelim(token::Brace)) &&
self.token.uninterpolated_span().rust_2018() &&
// Prevent `while try {} {}`, `if try {} {} else {}`, etc.
!self.restrictions.contains(Restrictions::NO_STRUCT_LITERAL)
}but we allow this for unsafe {}, async {}, etc.
This comment has been minimized.
This comment has been minimized.
Contributor
Author
|
Waited for a comment by @petrochenkov on this, as this changes the purpose of this PR. I changed the parser to allow try in scrutinee position/in places where open braces are expected. // This now compiles
match try {} {
Ok(()) | Err(()) => (),
} |
try-blocks in places where an open delim is expected
Contributor
|
Did you intend to include that submodule bump? |
Contributor
Author
|
I rarely do 😆 thank you for catching this |
4010c1d to
f74e466
Compare
Contributor
Collaborator
|
📌 Commit f74e466771ad79410b84b2034d45cc3cc1d84855 has been approved by |
Contributor
|
@bors r+ |
Collaborator
|
📌 Commit 81a3cd7 has been approved by |
Dylan-DPC-zz
pushed a commit
to Dylan-DPC-zz/rust
that referenced
this pull request
Apr 14, 2020
Allow `try`-blocks in places where an open delim is expected Closes rust-lang#70490 Closes rust-lang#56828 r? @Centril
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Apr 15, 2020
Rollup of 8 pull requests Successful merges: - rust-lang#70657 (Allow `try`-blocks in places where an open delim is expected) - rust-lang#70947 (tighten CTFE safety net for accesses to globals) - rust-lang#70949 (simplify `vec!` macro) - rust-lang#71002 (fix target & runtool args order) - rust-lang#71082 (ptr: introduce len() method on raw slices) - rust-lang#71128 (Remove unused single_step flag) - rust-lang#71133 (Tighten time complexity on the doc of sort_by_key) - rust-lang#71135 (Update books) Failed merges: r? @ghost
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #70490
Closes #56828
r? @Centril