Skip to content

Commit 5021dde

Browse files
committed
Move scrutinee HirId into MatchSource::TryDesugar
1 parent 55f8c66 commit 5021dde

File tree

29 files changed

+41
-49
lines changed

29 files changed

+41
-49
lines changed

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1648,7 +1648,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
16481648
hir::ExprKind::Match(
16491649
scrutinee,
16501650
arena_vec![self; break_arm, continue_arm],
1651-
hir::MatchSource::TryDesugar,
1651+
hir::MatchSource::TryDesugar(scrutinee.hir_id),
16521652
)
16531653
}
16541654

compiler/rustc_hir/src/hir.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2148,7 +2148,7 @@ pub enum MatchSource {
21482148
/// A desugared `for _ in _ { .. }` loop.
21492149
ForLoopDesugar,
21502150
/// A desugared `?` operator.
2151-
TryDesugar,
2151+
TryDesugar(HirId),
21522152
/// A desugared `<expr>.await`.
21532153
AwaitDesugar,
21542154
/// A desugared `format_args!()`.
@@ -2162,7 +2162,7 @@ impl MatchSource {
21622162
match self {
21632163
Normal => "match",
21642164
ForLoopDesugar => "for",
2165-
TryDesugar => "?",
2165+
TryDesugar(_) => "?",
21662166
AwaitDesugar => ".await",
21672167
FormatArgs => "format_args!()",
21682168
}

compiler/rustc_hir_typeck/src/_match.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
107107
let (span, code) = match prior_arm {
108108
// The reason for the first arm to fail is not that the match arms diverge,
109109
// but rather that there's a prior obligation that doesn't hold.
110-
None => (
111-
arm_span,
112-
ObligationCauseCode::BlockTailExpression(
113-
arm.body.hir_id,
114-
scrut.hir_id,
115-
match_src,
116-
),
117-
),
110+
None => {
111+
(arm_span, ObligationCauseCode::BlockTailExpression(arm.body.hir_id, match_src))
112+
}
118113
Some((prior_arm_block_id, prior_arm_ty, prior_arm_span)) => (
119114
expr.span,
120115
ObligationCauseCode::MatchExpressionArm(Box::new(MatchExpressionArmCause {
@@ -127,7 +122,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
127122
scrut_span: scrut.span,
128123
source: match_src,
129124
prior_arms: other_arms.clone(),
130-
scrut_hir_id: scrut.hir_id,
131125
opt_suggest_box_span,
132126
})),
133127
),

compiler/rustc_hir_typeck/src/coercion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1751,7 +1751,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
17511751
) && !in_external_macro(fcx.tcx.sess, cond_expr.span)
17521752
&& !matches!(
17531753
cond_expr.kind,
1754-
hir::ExprKind::Match(.., hir::MatchSource::TryDesugar)
1754+
hir::ExprKind::Match(.., hir::MatchSource::TryDesugar(_))
17551755
)
17561756
{
17571757
err.span_label(cond_expr.span, "expected this to be `()`");

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,11 +1582,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15821582
let span = self.get_expr_coercion_span(tail_expr);
15831583
let cause = self.cause(
15841584
span,
1585-
ObligationCauseCode::BlockTailExpression(
1586-
blk.hir_id,
1587-
blk.hir_id,
1588-
hir::MatchSource::Normal,
1589-
),
1585+
ObligationCauseCode::BlockTailExpression(blk.hir_id, hir::MatchSource::Normal),
15901586
);
15911587
let ty_for_diagnostic = coerce.merged_ty();
15921588
// We use coerce_inner here because we want to augment the error

compiler/rustc_infer/src/infer/error_reporting/mod.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -745,8 +745,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
745745
}
746746
ObligationCauseCode::BlockTailExpression(
747747
_,
748-
scrut_hir_id,
749-
hir::MatchSource::TryDesugar,
748+
hir::MatchSource::TryDesugar(scrut_hir_id),
750749
) => {
751750
if let Some(ty::error::ExpectedFound { expected, .. }) = exp_found {
752751
let scrut_expr = self.tcx.hir().expect_expr(scrut_hir_id);
@@ -782,12 +781,11 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
782781
prior_arm_ty,
783782
source,
784783
ref prior_arms,
785-
scrut_hir_id,
786784
opt_suggest_box_span,
787785
scrut_span,
788786
..
789787
}) => match source {
790-
hir::MatchSource::TryDesugar => {
788+
hir::MatchSource::TryDesugar(scrut_hir_id) => {
791789
if let Some(ty::error::ExpectedFound { expected, .. }) = exp_found {
792790
let scrut_expr = self.tcx.hir().expect_expr(scrut_hir_id);
793791
let scrut_ty = if let hir::ExprKind::Call(_, args) = &scrut_expr.kind {
@@ -2077,7 +2075,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
20772075
if let &(MatchExpressionArm(box MatchExpressionArmCause { source, .. })
20782076
| BlockTailExpression(.., source)
20792077
) = code
2080-
&& let hir::MatchSource::TryDesugar = source
2078+
&& let hir::MatchSource::TryDesugar(_) = source
20812079
&& let Some((expected_ty, found_ty, _, _)) = self.values_str(trace.values)
20822080
{
20832081
suggestions.push(TypeErrorAdditionalDiags::TryCannotConvert {
@@ -2954,11 +2952,11 @@ impl<'tcx> ObligationCauseExt<'tcx> for ObligationCause<'tcx> {
29542952
CompareImplItemObligation { kind: ty::AssocKind::Const, .. } => {
29552953
ObligationCauseFailureCode::ConstCompat { span, subdiags }
29562954
}
2957-
BlockTailExpression(.., hir::MatchSource::TryDesugar) => {
2955+
BlockTailExpression(.., hir::MatchSource::TryDesugar(_)) => {
29582956
ObligationCauseFailureCode::TryCompat { span, subdiags }
29592957
}
29602958
MatchExpressionArm(box MatchExpressionArmCause { source, .. }) => match source {
2961-
hir::MatchSource::TryDesugar => {
2959+
hir::MatchSource::TryDesugar(_) => {
29622960
ObligationCauseFailureCode::TryCompat { span, subdiags }
29632961
}
29642962
_ => ObligationCauseFailureCode::MatchCompat { span, subdiags },

compiler/rustc_middle/src/thir.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ pub enum ExprKind<'tcx> {
346346
/// A `match` expression.
347347
Match {
348348
scrutinee: ExprId,
349+
scrutinee_hir_id: hir::HirId,
349350
arms: Box<[ArmId]>,
350351
},
351352
/// A block.

compiler/rustc_middle/src/thir/visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub fn walk_expr<'a, 'tcx: 'a, V: Visitor<'a, 'tcx>>(visitor: &mut V, expr: &Exp
7070
visitor.visit_expr(&visitor.thir()[expr]);
7171
}
7272
Loop { body } => visitor.visit_expr(&visitor.thir()[body]),
73-
Match { scrutinee, ref arms } => {
73+
Match { scrutinee, ref arms, .. } => {
7474
visitor.visit_expr(&visitor.thir()[scrutinee]);
7575
for &arm in &**arms {
7676
visitor.visit_arm(&visitor.thir()[arm]);

compiler/rustc_middle/src/traits/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ pub enum ObligationCauseCode<'tcx> {
402402
OpaqueReturnType(Option<(Ty<'tcx>, Span)>),
403403

404404
/// Block implicit return
405-
BlockTailExpression(hir::HirId, hir::HirId, hir::MatchSource),
405+
BlockTailExpression(hir::HirId, hir::MatchSource),
406406

407407
/// #[feature(trivial_bounds)] is not enabled
408408
TrivialBound,
@@ -543,7 +543,6 @@ pub struct MatchExpressionArmCause<'tcx> {
543543
pub scrut_span: Span,
544544
pub source: hir::MatchSource,
545545
pub prior_arms: Vec<Span>,
546-
pub scrut_hir_id: hir::HirId,
547546
pub opt_suggest_box_span: Option<Span>,
548547
}
549548

compiler/rustc_mir_build/src/build/custom/parse/instruction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
6565
let target = self.parse_block(args[1])?;
6666
self.parse_call(args[2], destination, target)
6767
},
68-
ExprKind::Match { scrutinee, arms } => {
68+
ExprKind::Match { scrutinee, arms, .. } => {
6969
let discr = self.parse_operand(*scrutinee)?;
7070
self.parse_match(arms, expr.span).map(|t| TerminatorKind::SwitchInt { discr, targets: t })
7171
},

compiler/rustc_mir_build/src/build/expr/into.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
4747
ExprKind::Block { block: ast_block } => {
4848
this.ast_block(destination, block, ast_block, source_info)
4949
}
50-
ExprKind::Match { scrutinee, ref arms } => {
50+
ExprKind::Match { scrutinee, ref arms, .. } => {
5151
this.match_expr(destination, expr_span, block, &this.thir[scrutinee], arms)
5252
}
5353
ExprKind::If { cond, then, else_opt, if_then_scope } => {

compiler/rustc_mir_build/src/thir/cx/expr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,7 @@ impl<'tcx> Cx<'tcx> {
733733
},
734734
hir::ExprKind::Match(ref discr, ref arms, _) => ExprKind::Match {
735735
scrutinee: self.mirror_expr(discr),
736+
scrutinee_hir_id: discr.hir_id,
736737
arms: arms.iter().map(|a| self.convert_arm(a)).collect(),
737738
},
738739
hir::ExprKind::Loop(ref body, ..) => {

compiler/rustc_mir_build/src/thir/pattern/check_match.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,12 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for MatchVisitor<'a, '_, 'tcx> {
135135
});
136136
return;
137137
}
138-
ExprKind::Match { scrutinee, box ref arms } => {
138+
ExprKind::Match { scrutinee, scrutinee_hir_id, box ref arms } => {
139139
let source = match ex.span.desugaring_kind() {
140140
Some(DesugaringKind::ForLoop) => hir::MatchSource::ForLoopDesugar,
141-
Some(DesugaringKind::QuestionMark) => hir::MatchSource::TryDesugar,
141+
Some(DesugaringKind::QuestionMark) => {
142+
hir::MatchSource::TryDesugar(scrutinee_hir_id)
143+
}
142144
Some(DesugaringKind::Await) => hir::MatchSource::AwaitDesugar,
143145
_ => hir::MatchSource::Normal,
144146
};
@@ -277,7 +279,7 @@ impl<'p, 'tcx> MatchVisitor<'_, 'p, 'tcx> {
277279
| hir::MatchSource::FormatArgs => report_arm_reachability(&cx, &report),
278280
// Unreachable patterns in try and await expressions occur when one of
279281
// the arms are an uninhabited type. Which is OK.
280-
hir::MatchSource::AwaitDesugar | hir::MatchSource::TryDesugar => {}
282+
hir::MatchSource::AwaitDesugar | hir::MatchSource::TryDesugar(_) => {}
281283
}
282284

283285
// Check if the match is exhaustive.

compiler/rustc_mir_build/src/thir/print.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
321321
print_indented!(self, format!("pat: {:?}", pat), depth_lvl + 1);
322322
print_indented!(self, "}", depth_lvl);
323323
}
324-
Match { scrutinee, arms } => {
324+
Match { scrutinee, arms, .. } => {
325325
print_indented!(self, "Match {", depth_lvl);
326326
print_indented!(self, "scrutinee:", depth_lvl + 1);
327327
self.print_expr(*scrutinee, depth_lvl + 2);

compiler/rustc_passes/src/check_const.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl NonConstExpr {
4545

4646
Self::Loop(ForLoop) | Self::Match(ForLoopDesugar) => &[sym::const_for],
4747

48-
Self::Match(TryDesugar) => &[sym::const_try],
48+
Self::Match(TryDesugar(_)) => &[sym::const_try],
4949

5050
// All other expressions are allowed.
5151
Self::Loop(Loop | While) | Self::Match(Normal | FormatArgs) => &[],

src/tools/clippy/clippy_lints/src/dereference.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,8 @@ fn in_postfix_position<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'tcx>) -> boo
802802
match parent.kind {
803803
ExprKind::Call(child, _) | ExprKind::MethodCall(_, child, _, _) | ExprKind::Index(child, _, _)
804804
if child.hir_id == e.hir_id => true,
805-
ExprKind::Field(_, _) | ExprKind::Match(_, _, MatchSource::TryDesugar | MatchSource::AwaitDesugar) => true,
805+
ExprKind::Match(.., MatchSource::TryDesugar(_) | MatchSource::AwaitDesugar)
806+
| ExprKind::Field(_, _) => true,
806807
_ => false,
807808
}
808809
} else {

src/tools/clippy/clippy_lints/src/matches/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,7 @@ impl<'tcx> LateLintPass<'tcx> for Matches {
10381038
wild_in_or_pats::check(cx, arms);
10391039
}
10401040

1041-
if source == MatchSource::TryDesugar {
1041+
if let MatchSource::TryDesugar(_) = source {
10421042
try_err::check(cx, expr, ex);
10431043
}
10441044

src/tools/clippy/clippy_lints/src/matches/try_err.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, scrutine
8080

8181
/// Finds function return type by examining return expressions in match arms.
8282
fn find_return_type<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx ExprKind<'_>) -> Option<Ty<'tcx>> {
83-
if let ExprKind::Match(_, arms, MatchSource::TryDesugar) = expr {
83+
if let ExprKind::Match(_, arms, MatchSource::TryDesugar(_)) = expr {
8484
for arm in *arms {
8585
if let ExprKind::Ret(Some(ret)) = arm.body.kind {
8686
return Some(cx.typeck_results().expr_ty(ret));

src/tools/clippy/clippy_lints/src/methods/clone_on_copy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub(super) fn check(
6464
ExprKind::Path(QPath::LangItem(rustc_hir::LangItem::TryTraitBranch, _, _))
6565
),
6666
ExprKind::MethodCall(_, self_arg, ..) if expr.hir_id == self_arg.hir_id => true,
67-
ExprKind::Match(_, _, MatchSource::TryDesugar | MatchSource::AwaitDesugar)
67+
ExprKind::Match(_, _, MatchSource::TryDesugar(_) | MatchSource::AwaitDesugar)
6868
| ExprKind::Field(..)
6969
| ExprKind::Index(..) => true,
7070
_ => false,

src/tools/clippy/clippy_lints/src/methods/str_splitn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ fn indirect_usage<'tcx>(
236236
!matches!(
237237
node,
238238
Node::Expr(Expr {
239-
kind: ExprKind::Match(.., MatchSource::TryDesugar),
239+
kind: ExprKind::Match(.., MatchSource::TryDesugar(_)),
240240
..
241241
})
242242
)

src/tools/clippy/clippy_lints/src/needless_question_mark.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ fn check(cx: &LateContext<'_>, expr: &Expr<'_>) {
122122
} else {
123123
return;
124124
};
125-
if let ExprKind::Match(inner_expr_with_q, _, MatchSource::TryDesugar) = &arg.kind;
125+
if let ExprKind::Match(inner_expr_with_q, _, MatchSource::TryDesugar(_)) = &arg.kind;
126126
if let ExprKind::Call(called, [inner_expr]) = &inner_expr_with_q.kind;
127127
if let ExprKind::Path(QPath::LangItem(LangItem::TryTraitBranch, ..)) = &called.kind;
128128
if expr.span.ctxt() == inner_expr.span.ctxt();

src/tools/clippy/clippy_lints/src/question_mark_used.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ declare_lint_pass!(QuestionMarkUsed => [QUESTION_MARK_USED]);
3434

3535
impl<'tcx> LateLintPass<'tcx> for QuestionMarkUsed {
3636
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
37-
if let ExprKind::Match(_, _, MatchSource::TryDesugar) = expr.kind {
37+
if let ExprKind::Match(_, _, MatchSource::TryDesugar(_)) = expr.kind {
3838
if !span_is_local(expr.span) {
3939
return;
4040
}

src/tools/clippy/clippy_lints/src/redundant_closure_call.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl ReturnVisitor {
5252

5353
impl<'tcx> Visitor<'tcx> for ReturnVisitor {
5454
fn visit_expr(&mut self, ex: &'tcx hir::Expr<'tcx>) {
55-
if let hir::ExprKind::Ret(_) | hir::ExprKind::Match(.., hir::MatchSource::TryDesugar) = ex.kind {
55+
if let hir::ExprKind::Ret(_) | hir::ExprKind::Match(.., hir::MatchSource::TryDesugar(_)) = ex.kind {
5656
self.found_return = true;
5757
} else {
5858
hir_visit::walk_expr(self, ex);

src/tools/clippy/clippy_lints/src/returns.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ impl<'tcx> LateLintPass<'tcx> for Return {
164164
if !in_external_macro(cx.sess(), stmt.span)
165165
&& let StmtKind::Semi(expr) = stmt.kind
166166
&& let ExprKind::Ret(Some(ret)) = expr.kind
167-
&& let ExprKind::Match(.., MatchSource::TryDesugar) = ret.kind
167+
&& let ExprKind::Match(.., MatchSource::TryDesugar(_)) = ret.kind
168168
// Ensure this is not the final stmt, otherwise removing it would cause a compile error
169169
&& let OwnerNode::Item(item) = cx.tcx.hir().owner(cx.tcx.hir().get_parent_item(expr.hir_id))
170170
&& let ItemKind::Fn(_, _, body) = item.kind

src/tools/clippy/clippy_lints/src/unit_types/unit_arg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
4242
if cx.typeck_results().expr_ty(arg).is_unit() && !utils::is_unit_literal(arg) {
4343
!matches!(
4444
&arg.kind,
45-
ExprKind::Match(.., MatchSource::TryDesugar) | ExprKind::Path(..)
45+
ExprKind::Match(.., MatchSource::TryDesugar(_)) | ExprKind::Path(..)
4646
)
4747
} else {
4848
false

src/tools/clippy/clippy_lints/src/useless_conversion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion {
113113
}
114114

115115
match e.kind {
116-
ExprKind::Match(_, arms, MatchSource::TryDesugar) => {
116+
ExprKind::Match(_, arms, MatchSource::TryDesugar(_)) => {
117117
let (ExprKind::Ret(Some(e)) | ExprKind::Break(_, Some(e))) = arms[0].body.kind else {
118118
return;
119119
};

src/tools/clippy/clippy_utils/src/check_proc_macro.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ fn expr_search_pat(tcx: TyCtxt<'_>, e: &Expr<'_>) -> (Pat, Pat) {
149149
(Pat::Str("for"), Pat::Str("}"))
150150
},
151151
ExprKind::Match(_, _, MatchSource::Normal) => (Pat::Str("match"), Pat::Str("}")),
152-
ExprKind::Match(e, _, MatchSource::TryDesugar) => (expr_search_pat(tcx, e).0, Pat::Str("?")),
152+
ExprKind::Match(e, _, MatchSource::TryDesugar(_)) => (expr_search_pat(tcx, e).0, Pat::Str("?")),
153153
ExprKind::Match(e, _, MatchSource::AwaitDesugar) | ExprKind::Yield(e, YieldSource::Await { .. }) => {
154154
(expr_search_pat(tcx, e).0, Pat::Str("await"))
155155
},

src/tools/clippy/clippy_utils/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1765,7 +1765,7 @@ pub fn is_try<'tcx>(cx: &LateContext<'_>, expr: &'tcx Expr<'tcx>) -> Option<&'tc
17651765

17661766
if let ExprKind::Match(_, arms, ref source) = expr.kind {
17671767
// desugared from a `?` operator
1768-
if *source == MatchSource::TryDesugar {
1768+
if let MatchSource::TryDesugar(_) = *source {
17691769
return Some(expr);
17701770
}
17711771

src/tools/clippy/clippy_utils/src/visitors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ pub fn for_each_expr_with_closures<'tcx, B, C: Continue>(
161161
/// returns `true` if expr contains match expr desugared from try
162162
fn contains_try(expr: &hir::Expr<'_>) -> bool {
163163
for_each_expr(expr, |e| {
164-
if matches!(e.kind, hir::ExprKind::Match(_, _, hir::MatchSource::TryDesugar)) {
164+
if matches!(e.kind, hir::ExprKind::Match(_, _, hir::MatchSource::TryDesugar(_))) {
165165
ControlFlow::Break(())
166166
} else {
167167
ControlFlow::Continue(())

0 commit comments

Comments
 (0)