Move scrutinee HirId
into MatchSource::TryDesugar
This commit is contained in:
parent
55f8c66a60
commit
5021dde1a0
29 changed files with 41 additions and 49 deletions
|
@ -65,7 +65,7 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
|
|||
let target = self.parse_block(args[1])?;
|
||||
self.parse_call(args[2], destination, target)
|
||||
},
|
||||
ExprKind::Match { scrutinee, arms } => {
|
||||
ExprKind::Match { scrutinee, arms, .. } => {
|
||||
let discr = self.parse_operand(*scrutinee)?;
|
||||
self.parse_match(arms, expr.span).map(|t| TerminatorKind::SwitchInt { discr, targets: t })
|
||||
},
|
||||
|
|
|
@ -47,7 +47,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
ExprKind::Block { block: ast_block } => {
|
||||
this.ast_block(destination, block, ast_block, source_info)
|
||||
}
|
||||
ExprKind::Match { scrutinee, ref arms } => {
|
||||
ExprKind::Match { scrutinee, ref arms, .. } => {
|
||||
this.match_expr(destination, expr_span, block, &this.thir[scrutinee], arms)
|
||||
}
|
||||
ExprKind::If { cond, then, else_opt, if_then_scope } => {
|
||||
|
|
|
@ -733,6 +733,7 @@ impl<'tcx> Cx<'tcx> {
|
|||
},
|
||||
hir::ExprKind::Match(ref discr, ref arms, _) => ExprKind::Match {
|
||||
scrutinee: self.mirror_expr(discr),
|
||||
scrutinee_hir_id: discr.hir_id,
|
||||
arms: arms.iter().map(|a| self.convert_arm(a)).collect(),
|
||||
},
|
||||
hir::ExprKind::Loop(ref body, ..) => {
|
||||
|
|
|
@ -135,10 +135,12 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for MatchVisitor<'a, '_, 'tcx> {
|
|||
});
|
||||
return;
|
||||
}
|
||||
ExprKind::Match { scrutinee, box ref arms } => {
|
||||
ExprKind::Match { scrutinee, scrutinee_hir_id, box ref arms } => {
|
||||
let source = match ex.span.desugaring_kind() {
|
||||
Some(DesugaringKind::ForLoop) => hir::MatchSource::ForLoopDesugar,
|
||||
Some(DesugaringKind::QuestionMark) => hir::MatchSource::TryDesugar,
|
||||
Some(DesugaringKind::QuestionMark) => {
|
||||
hir::MatchSource::TryDesugar(scrutinee_hir_id)
|
||||
}
|
||||
Some(DesugaringKind::Await) => hir::MatchSource::AwaitDesugar,
|
||||
_ => hir::MatchSource::Normal,
|
||||
};
|
||||
|
@ -277,7 +279,7 @@ impl<'p, 'tcx> MatchVisitor<'_, 'p, 'tcx> {
|
|||
| hir::MatchSource::FormatArgs => report_arm_reachability(&cx, &report),
|
||||
// Unreachable patterns in try and await expressions occur when one of
|
||||
// the arms are an uninhabited type. Which is OK.
|
||||
hir::MatchSource::AwaitDesugar | hir::MatchSource::TryDesugar => {}
|
||||
hir::MatchSource::AwaitDesugar | hir::MatchSource::TryDesugar(_) => {}
|
||||
}
|
||||
|
||||
// Check if the match is exhaustive.
|
||||
|
|
|
@ -321,7 +321,7 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
|
|||
print_indented!(self, format!("pat: {:?}", pat), depth_lvl + 1);
|
||||
print_indented!(self, "}", depth_lvl);
|
||||
}
|
||||
Match { scrutinee, arms } => {
|
||||
Match { scrutinee, arms, .. } => {
|
||||
print_indented!(self, "Match {", depth_lvl);
|
||||
print_indented!(self, "scrutinee:", depth_lvl + 1);
|
||||
self.print_expr(*scrutinee, depth_lvl + 2);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue