Skip to content

Commit 8cf9bd0

Browse files
authored
Rollup merge of rust-lang#114819 - estebank:issue-78124, r=compiler-errors
Point at return type when it influences non-first `match` arm When encountering code like ```rust fn foo() -> i32 { match 0 { 1 => return 0, 2 => "", _ => 1, } } ``` Point at the return type and not at the prior arm, as that arm has type `!` which isn't influencing the arm corresponding to arm `2`. Fix rust-lang#78124.
2 parents 2d64446 + 58aa903 commit 8cf9bd0

File tree

38 files changed

+157
-73
lines changed

38 files changed

+157
-73
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: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +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 => (arm_span, ObligationCauseCode::BlockTailExpression(arm.body.hir_id)),
110+
None => {
111+
(arm_span, ObligationCauseCode::BlockTailExpression(arm.body.hir_id, match_src))
112+
}
111113
Some((prior_arm_block_id, prior_arm_ty, prior_arm_span)) => (
112114
expr.span,
113115
ObligationCauseCode::MatchExpressionArm(Box::new(MatchExpressionArmCause {
@@ -120,7 +122,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
120122
scrut_span: scrut.span,
121123
source: match_src,
122124
prior_arms: other_arms.clone(),
123-
scrut_hir_id: scrut.hir_id,
124125
opt_suggest_box_span,
125126
})),
126127
),
@@ -145,7 +146,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
145146
other_arms.remove(0);
146147
}
147148

148-
prior_arm = Some((arm_block_id, arm_ty, arm_span));
149+
if !arm_ty.is_never() {
150+
// When a match arm has type `!`, then it doesn't influence the expected type for
151+
// the following arm. If all of the prior arms are `!`, then the influence comes
152+
// from elsewhere and we shouldn't point to any previous arm.
153+
prior_arm = Some((arm_block_id, arm_ty, arm_span));
154+
}
149155
}
150156

151157
// If all of the arms in the `match` diverge,

compiler/rustc_hir_typeck/src/coercion.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,7 +1603,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
16031603
);
16041604
err.span_label(cause.span, "return type is not `()`");
16051605
}
1606-
ObligationCauseCode::BlockTailExpression(blk_id) => {
1606+
ObligationCauseCode::BlockTailExpression(blk_id, ..) => {
16071607
let parent_id = fcx.tcx.hir().parent_id(blk_id);
16081608
err = self.report_return_mismatched_types(
16091609
cause,
@@ -1748,7 +1748,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
17481748
) && !in_external_macro(fcx.tcx.sess, cond_expr.span)
17491749
&& !matches!(
17501750
cond_expr.kind,
1751-
hir::ExprKind::Match(.., hir::MatchSource::TryDesugar)
1751+
hir::ExprKind::Match(.., hir::MatchSource::TryDesugar(_))
17521752
)
17531753
{
17541754
err.span_label(cond_expr.span, "expected this to be `()`");

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1580,7 +1580,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15801580
let coerce = ctxt.coerce.as_mut().unwrap();
15811581
if let Some((tail_expr, tail_expr_ty)) = tail_expr_ty {
15821582
let span = self.get_expr_coercion_span(tail_expr);
1583-
let cause = self.cause(span, ObligationCauseCode::BlockTailExpression(blk.hir_id));
1583+
let cause = self.cause(
1584+
span,
1585+
ObligationCauseCode::BlockTailExpression(blk.hir_id, hir::MatchSource::Normal),
1586+
);
15841587
let ty_for_diagnostic = coerce.merged_ty();
15851588
// We use coerce_inner here because we want to augment the error
15861589
// suggesting to wrap the block in square brackets if it might've

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

Lines changed: 67 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,35 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
743743
ObligationCauseCode::Pattern { origin_expr: false, span: Some(span), .. } => {
744744
err.span_label(span, "expected due to this");
745745
}
746+
ObligationCauseCode::BlockTailExpression(
747+
_,
748+
hir::MatchSource::TryDesugar(scrut_hir_id),
749+
) => {
750+
if let Some(ty::error::ExpectedFound { expected, .. }) = exp_found {
751+
let scrut_expr = self.tcx.hir().expect_expr(scrut_hir_id);
752+
let scrut_ty = if let hir::ExprKind::Call(_, args) = &scrut_expr.kind {
753+
let arg_expr = args.first().expect("try desugaring call w/out arg");
754+
self.typeck_results.as_ref().and_then(|typeck_results| {
755+
typeck_results.expr_ty_opt(arg_expr)
756+
})
757+
} else {
758+
bug!("try desugaring w/out call expr as scrutinee");
759+
};
760+
761+
match scrut_ty {
762+
Some(ty) if expected == ty => {
763+
let source_map = self.tcx.sess.source_map();
764+
err.span_suggestion(
765+
source_map.end_point(cause.span()),
766+
"try removing this `?`",
767+
"",
768+
Applicability::MachineApplicable,
769+
);
770+
}
771+
_ => {}
772+
}
773+
}
774+
},
746775
ObligationCauseCode::MatchExpressionArm(box MatchExpressionArmCause {
747776
arm_block_id,
748777
arm_span,
@@ -752,12 +781,11 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
752781
prior_arm_ty,
753782
source,
754783
ref prior_arms,
755-
scrut_hir_id,
756784
opt_suggest_box_span,
757785
scrut_span,
758786
..
759787
}) => match source {
760-
hir::MatchSource::TryDesugar => {
788+
hir::MatchSource::TryDesugar(scrut_hir_id) => {
761789
if let Some(ty::error::ExpectedFound { expected, .. }) = exp_found {
762790
let scrut_expr = self.tcx.hir().expect_expr(scrut_hir_id);
763791
let scrut_ty = if let hir::ExprKind::Call(_, args) = &scrut_expr.kind {
@@ -1978,7 +2006,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
19782006
trace: &TypeTrace<'tcx>,
19792007
terr: TypeError<'tcx>,
19802008
) -> Vec<TypeErrorAdditionalDiags> {
1981-
use crate::traits::ObligationCauseCode::MatchExpressionArm;
2009+
use crate::traits::ObligationCauseCode::{BlockTailExpression, MatchExpressionArm};
19822010
let mut suggestions = Vec::new();
19832011
let span = trace.cause.span();
19842012
let values = self.resolve_vars_if_possible(trace.values);
@@ -1996,11 +2024,17 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
19962024
// specify a byte literal
19972025
(ty::Uint(ty::UintTy::U8), ty::Char) => {
19982026
if let Ok(code) = self.tcx.sess().source_map().span_to_snippet(span)
1999-
&& let Some(code) = code.strip_prefix('\'').and_then(|s| s.strip_suffix('\''))
2000-
&& !code.starts_with("\\u") // forbid all Unicode escapes
2001-
&& code.chars().next().is_some_and(|c| c.is_ascii()) // forbids literal Unicode characters beyond ASCII
2027+
&& let Some(code) =
2028+
code.strip_prefix('\'').and_then(|s| s.strip_suffix('\''))
2029+
// forbid all Unicode escapes
2030+
&& !code.starts_with("\\u")
2031+
// forbids literal Unicode characters beyond ASCII
2032+
&& code.chars().next().is_some_and(|c| c.is_ascii())
20022033
{
2003-
suggestions.push(TypeErrorAdditionalDiags::MeantByteLiteral { span, code: escape_literal(code) })
2034+
suggestions.push(TypeErrorAdditionalDiags::MeantByteLiteral {
2035+
span,
2036+
code: escape_literal(code),
2037+
})
20042038
}
20052039
}
20062040
// If a character was expected and the found expression is a string literal
@@ -2011,7 +2045,10 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
20112045
&& let Some(code) = code.strip_prefix('"').and_then(|s| s.strip_suffix('"'))
20122046
&& code.chars().count() == 1
20132047
{
2014-
suggestions.push(TypeErrorAdditionalDiags::MeantCharLiteral { span, code: escape_literal(code) })
2048+
suggestions.push(TypeErrorAdditionalDiags::MeantCharLiteral {
2049+
span,
2050+
code: escape_literal(code),
2051+
})
20152052
}
20162053
}
20172054
// If a string was expected and the found expression is a character literal,
@@ -2021,7 +2058,10 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
20212058
if let Some(code) =
20222059
code.strip_prefix('\'').and_then(|s| s.strip_suffix('\''))
20232060
{
2024-
suggestions.push(TypeErrorAdditionalDiags::MeantStrLiteral { span, code: escape_literal(code) })
2061+
suggestions.push(TypeErrorAdditionalDiags::MeantStrLiteral {
2062+
span,
2063+
code: escape_literal(code),
2064+
})
20252065
}
20262066
}
20272067
}
@@ -2030,17 +2070,24 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
20302070
(ty::Bool, ty::Tuple(list)) => if list.len() == 0 {
20312071
suggestions.extend(self.suggest_let_for_letchains(&trace.cause, span));
20322072
}
2033-
(ty::Array(_, _), ty::Array(_, _)) => suggestions.extend(self.suggest_specify_actual_length(terr, trace, span)),
2073+
(ty::Array(_, _), ty::Array(_, _)) => {
2074+
suggestions.extend(self.suggest_specify_actual_length(terr, trace, span))
2075+
}
20342076
_ => {}
20352077
}
20362078
}
20372079
let code = trace.cause.code();
2038-
if let &MatchExpressionArm(box MatchExpressionArmCause { source, .. }) = code
2039-
&& let hir::MatchSource::TryDesugar = source
2040-
&& let Some((expected_ty, found_ty, _, _)) = self.values_str(trace.values)
2041-
{
2042-
suggestions.push(TypeErrorAdditionalDiags::TryCannotConvert { found: found_ty.content(), expected: expected_ty.content() });
2043-
}
2080+
if let &(MatchExpressionArm(box MatchExpressionArmCause { source, .. })
2081+
| BlockTailExpression(.., source)
2082+
) = code
2083+
&& let hir::MatchSource::TryDesugar(_) = source
2084+
&& let Some((expected_ty, found_ty, _, _)) = self.values_str(trace.values)
2085+
{
2086+
suggestions.push(TypeErrorAdditionalDiags::TryCannotConvert {
2087+
found: found_ty.content(),
2088+
expected: expected_ty.content(),
2089+
});
2090+
}
20442091
suggestions
20452092
}
20462093

@@ -2910,8 +2957,11 @@ impl<'tcx> ObligationCauseExt<'tcx> for ObligationCause<'tcx> {
29102957
CompareImplItemObligation { kind: ty::AssocKind::Const, .. } => {
29112958
ObligationCauseFailureCode::ConstCompat { span, subdiags }
29122959
}
2960+
BlockTailExpression(.., hir::MatchSource::TryDesugar(_)) => {
2961+
ObligationCauseFailureCode::TryCompat { span, subdiags }
2962+
}
29132963
MatchExpressionArm(box MatchExpressionArmCause { source, .. }) => match source {
2914-
hir::MatchSource::TryDesugar => {
2964+
hir::MatchSource::TryDesugar(_) => {
29152965
ObligationCauseFailureCode::TryCompat { span, subdiags }
29162966
}
29172967
_ => ObligationCauseFailureCode::MatchCompat { span, subdiags },

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
146146

147147
if let SubregionOrigin::Subtype(box TypeTrace { cause, .. }) = sub_origin {
148148
if let ObligationCauseCode::ReturnValue(hir_id)
149-
| ObligationCauseCode::BlockTailExpression(hir_id) = cause.code()
149+
| ObligationCauseCode::BlockTailExpression(hir_id, ..) = cause.code()
150150
{
151151
let parent_id = tcx.hir().get_parent_item(*hir_id);
152152
if let Some(fn_decl) = tcx.hir().fn_decl_by_hir_id(parent_id.into()) {

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),
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
@@ -732,6 +732,7 @@ impl<'tcx> Cx<'tcx> {
732732
},
733733
hir::ExprKind::Match(ref discr, ref arms, _) => ExprKind::Match {
734734
scrutinee: self.mirror_expr(discr),
735+
scrutinee_hir_id: discr.hir_id,
735736
arms: arms.iter().map(|a| self.convert_arm(a)).collect(),
736737
},
737738
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) => &[],

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2700,7 +2700,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
27002700
| ObligationCauseCode::MatchImpl(..)
27012701
| ObligationCauseCode::ReturnType
27022702
| ObligationCauseCode::ReturnValue(_)
2703-
| ObligationCauseCode::BlockTailExpression(_)
2703+
| ObligationCauseCode::BlockTailExpression(..)
27042704
| ObligationCauseCode::AwaitableExpr(_)
27052705
| ObligationCauseCode::ForLoopIterator
27062706
| ObligationCauseCode::QuestionMark

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));

0 commit comments

Comments
 (0)