Rollup merge of #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 #78124.
This commit is contained in:
commit
8db5a6d8ee
38 changed files with 157 additions and 73 deletions
|
@ -346,6 +346,7 @@ pub enum ExprKind<'tcx> {
|
|||
/// A `match` expression.
|
||||
Match {
|
||||
scrutinee: ExprId,
|
||||
scrutinee_hir_id: hir::HirId,
|
||||
arms: Box<[ArmId]>,
|
||||
},
|
||||
/// A block.
|
||||
|
|
|
@ -70,7 +70,7 @@ pub fn walk_expr<'a, 'tcx: 'a, V: Visitor<'a, 'tcx>>(visitor: &mut V, expr: &Exp
|
|||
visitor.visit_expr(&visitor.thir()[expr]);
|
||||
}
|
||||
Loop { body } => visitor.visit_expr(&visitor.thir()[body]),
|
||||
Match { scrutinee, ref arms } => {
|
||||
Match { scrutinee, ref arms, .. } => {
|
||||
visitor.visit_expr(&visitor.thir()[scrutinee]);
|
||||
for &arm in &**arms {
|
||||
visitor.visit_arm(&visitor.thir()[arm]);
|
||||
|
|
|
@ -402,7 +402,7 @@ pub enum ObligationCauseCode<'tcx> {
|
|||
OpaqueReturnType(Option<(Ty<'tcx>, Span)>),
|
||||
|
||||
/// Block implicit return
|
||||
BlockTailExpression(hir::HirId),
|
||||
BlockTailExpression(hir::HirId, hir::MatchSource),
|
||||
|
||||
/// #[feature(trivial_bounds)] is not enabled
|
||||
TrivialBound,
|
||||
|
@ -543,7 +543,6 @@ pub struct MatchExpressionArmCause<'tcx> {
|
|||
pub scrut_span: Span,
|
||||
pub source: hir::MatchSource,
|
||||
pub prior_arms: Vec<Span>,
|
||||
pub scrut_hir_id: hir::HirId,
|
||||
pub opt_suggest_box_span: Option<Span>,
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue