-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Experimentally add *heterogeneous* try blocks
#149489
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
Conversation
|
r? @nnethercote rustbot has assigned @nnethercote. Use |
This comment has been minimized.
This comment has been minimized.
|
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
This comment has been minimized.
This comment has been minimized.
|
Some changes occurred in src/tools/rustfmt cc @rust-lang/rustfmt |
|
|
||
| #[derive(Copy, Clone, Debug)] | ||
| enum TryBlockScope { | ||
| /// There isn't a `try` block, so the scope is the function or closure or ... |
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.
It took me a few reads to understand this comment. Can it be rephrased? What other possibilities are there?
| /// A try block (`try { ... }`). | ||
| TryBlock(Box<Block>), | ||
| /// A try block (`try { ... }`), if the type is `None`, or | ||
| /// A try block (`try bikeshed Ty { ... }`) if the type is `Some`. |
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.
Nowhere in the PR is an explanation that bikeshed is deliberately ridiculous placeholder syntax. (I assume that's what it is.) Probably worth mentioning at least once. This might be a good spot for it.
|
Standard plumbing, mostly, seems fine. r=me with the nits addressed. |
148725 moved the default to being homogeneous; this adds heterogeneous ones back under an obvious-bikeshed syntax so people can experiment with that as well. Essentially resolves 149025 by letting them move to this syntax instead.
348490d to
35598c1
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@bors r=nnethercote |
| /// We're inside a `try { … }` block, so a `?` will block-break | ||
| /// from that block using a type depending only on the argument. | ||
| Homogeneous(HirId), | ||
| /// We're inside a `try as _ { … }` block, so a `?` will block-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're inside a `try as _ { … }` block, so a `?` will block-break | |
| /// We're inside a `try bikeshed _ { … }` block, so a `?` will block-break |
| ExprKind::TryBlock(body, optional_type) => | ||
| visit_visitable!($($mut)? vis, body, optional_type), |
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.
| ExprKind::TryBlock(body, optional_type) => | |
| visit_visitable!($($mut)? vis, body, optional_type), | |
| ExprKind::TryBlock(body, opt_ty) => | |
| visit_visitable!($($mut)? vis, body, opt_ty), |
(For simpler searching, since other places use opt_ty.)
Rollup of 7 pull requests Successful merges: - #148052 (Stabilize `const_mul_add`) - #149386 (Display funding link in the github overview) - #149489 (Experimentally add *heterogeneous* `try` blocks) - #149764 (Make `--print=backend-has-zstd` work by default on any backend) - #149838 (Build auxiliary in pretty tests) - #149839 (Use `PointeeSized` bound for `TrivialClone` impls) - #149846 (Statically require links to an issue or the edition guide for all FCWs) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 7 pull requests Successful merges: - #148052 (Stabilize `const_mul_add`) - #149386 (Display funding link in the github overview) - #149489 (Experimentally add *heterogeneous* `try` blocks) - #149764 (Make `--print=backend-has-zstd` work by default on any backend) - #149838 (Build auxiliary in pretty tests) - #149839 (Use `PointeeSized` bound for `TrivialClone` impls) - #149846 (Statically require links to an issue or the edition guide for all FCWs) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #149489 - scottmcm:try-bikeshed, r=nnethercote Experimentally add *heterogeneous* `try` blocks #148725 moved the default to being homogeneous; this adds heterogeneous ones back under an obvious-bikeshed syntax so people can experiment with that as well. Essentially resolves #149025 by letting them move to this syntax instead. New tracking issue: #149488 Related RFC: rust-lang/rfcs#3721 (comment) (specifically about experimenting)
Experimentally add *heterogeneous* `try` blocks rust-lang#148725 moved the default to being homogeneous; this adds heterogeneous ones back under an obvious-bikeshed syntax so people can experiment with that as well. Essentially resolves rust-lang#149025 by letting them move to this syntax instead. New tracking issue: rust-lang#149488 Related RFC: rust-lang/rfcs#3721 (comment) (specifically about experimenting)
#148725 moved the default to being homogeneous; this adds heterogeneous ones back under an obvious-bikeshed syntax so people can experiment with that as well.
Essentially resolves #149025 by letting them move to this syntax instead.
New tracking issue: #149488
Related RFC: rust-lang/rfcs#3721 (comment) (specifically about experimenting)