Rollup merge of #149489 - scottmcm:try-bikeshed, r=nnethercote

Experimentally add *heterogeneous* `try` blocks

rust-lang/rust#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/rust#149025 by letting them move to this syntax instead.

New tracking issue: rust-lang/rust#149488
Related RFC: https://github.com/rust-lang/rfcs/pull/3721#issuecomment-3208342727 (specifically about experimenting)
This commit is contained in:
Matthias Krüger 2025-12-10 17:16:47 +01:00 committed by GitHub
commit d196db781e
2 changed files with 2 additions and 2 deletions

View file

@ -545,7 +545,7 @@ fn ident_difference_expr_with_base_location(
| (Field(_, _), Field(_, _))
| (AssignOp(_, _, _), AssignOp(_, _, _))
| (Assign(_, _, _), Assign(_, _, _))
| (TryBlock(_), TryBlock(_))
| (TryBlock(_, _), TryBlock(_, _))
| (Await(_, _), Await(_, _))
| (Gen(_, _, _, _), Gen(_, _, _, _))
| (Block(_, _), Block(_, _))

View file

@ -199,7 +199,7 @@ pub fn eq_expr(l: &Expr, r: &Expr) -> bool {
) => eq_label(ll.as_ref(), rl.as_ref()) && eq_pat(lp, rp) && eq_expr(li, ri) && eq_block(lt, rt) && lk == rk,
(Loop(lt, ll, _), Loop(rt, rl, _)) => eq_label(ll.as_ref(), rl.as_ref()) && eq_block(lt, rt),
(Block(lb, ll), Block(rb, rl)) => eq_label(ll.as_ref(), rl.as_ref()) && eq_block(lb, rb),
(TryBlock(l), TryBlock(r)) => eq_block(l, r),
(TryBlock(lb, lt), TryBlock(rb, rt)) => eq_block(lb, rb) && both(lt.as_deref(), rt.as_deref(), eq_ty),
(Yield(l), Yield(r)) => eq_expr_opt(l.expr().map(Box::as_ref), r.expr().map(Box::as_ref)) && l.same_kind(r),
(Ret(l), Ret(r)) => eq_expr_opt(l.as_deref(), r.as_deref()),
(Break(ll, le), Break(rl, re)) => {