Auto merge of #79328 - c410-f3r:hir-if, r=matthewjasper
Reintroduce hir::ExprKind::If Basically copied and paste #59288/https://github.com/rust-lang/rust-clippy/pull/4080 with some modifications. The vast majority of tests were fixed and now there are only a few remaining. Since I am still unable to figure out the missing pieces, any help with the following list is welcome. - [ ] **Unnecessary `typeck` exception**: [Cheated on this one to make CI green.](https://github.com/rust-lang/rust/pull/79328/files#diff-3faee9ba23fc54a12b7c43364ba81f8c5660045c7e1d7989a02a0cee1c5b2051) - [x] **Incorrect span**: [Span should reference `then` and `else` separately.](https://github.com/rust-lang/rust/pull/79328/files#diff-cf2c46e82222ee4b1037a68fff8a1af3c4f1de7a6b3fd798aacbf3c0475abe3d) - [x] **New note regarding `assert!`**: [Modified but not "wrong". Maybe can be a good thing?](https://github.com/rust-lang/rust/pull/79328/files#diff-9e0d7c89ed0224e2b62060c957177c27db43c30dfe3c2974cb6b5091cda9cfb5) - [x] **Inverted report location**: [Modified but not "wrong". Locations were inverted.](https://github.com/rust-lang/rust/pull/79328/files#diff-f637ce7c1f68d523a165aa9651765df05e36c4d7d279194b1a6b28b48a323691) - [x] **`src/test/ui/point-to-type-err-cause-on-impl-trait-return.rs` has weird errors**: [Not sure why this is happening.](https://github.com/rust-lang/rust/pull/79328/files#diff-c823c09660f5b112f95e97e8ff71f1797b6c7f37dbb3d16f8e98bbaea8072e95) - [x] **Missing diagnostic**: [???](https://github.com/rust-lang/rust/pull/79328/files#diff-6b8ab09360d725ba4513933827f9796b42ff9522b0690f80b76de067143af2fc)
This commit is contained in:
commit
d03fe84169
139 changed files with 3135 additions and 3090 deletions
|
@ -49,9 +49,7 @@ impl NonConstExpr {
|
|||
|
||||
// All other expressions are allowed.
|
||||
Self::Loop(Loop | While | WhileLet)
|
||||
| Self::Match(
|
||||
WhileDesugar | WhileLetDesugar | Normal | IfDesugar { .. } | IfLetDesugar { .. },
|
||||
) => &[],
|
||||
| Self::Match(WhileDesugar | WhileLetDesugar | Normal | IfLetDesugar { .. }) => &[],
|
||||
};
|
||||
|
||||
Some(gates)
|
||||
|
|
|
@ -419,7 +419,7 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> {
|
|||
}
|
||||
|
||||
// live nodes required for interesting control flow:
|
||||
hir::ExprKind::Match(..) | hir::ExprKind::Loop(..) => {
|
||||
hir::ExprKind::If(..) | hir::ExprKind::Match(..) | hir::ExprKind::Loop(..) => {
|
||||
self.add_live_node_for_node(expr.hir_id, ExprNode(expr.span));
|
||||
intravisit::walk_expr(self, expr);
|
||||
}
|
||||
|
@ -846,6 +846,29 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
// at the label ident
|
||||
hir::ExprKind::Loop(ref blk, _, _) => self.propagate_through_loop(expr, &blk, succ),
|
||||
|
||||
hir::ExprKind::If(ref cond, ref then, ref else_opt) => {
|
||||
//
|
||||
// (cond)
|
||||
// |
|
||||
// v
|
||||
// (expr)
|
||||
// / \
|
||||
// | |
|
||||
// v v
|
||||
// (then)(els)
|
||||
// | |
|
||||
// v v
|
||||
// ( succ )
|
||||
//
|
||||
let else_ln =
|
||||
self.propagate_through_opt_expr(else_opt.as_ref().map(|e| &**e), succ);
|
||||
let then_ln = self.propagate_through_expr(&then, succ);
|
||||
let ln = self.live_node(expr.hir_id, expr.span);
|
||||
self.init_from_succ(ln, else_ln);
|
||||
self.merge_from_succ(ln, then_ln);
|
||||
self.propagate_through_expr(&cond, ln)
|
||||
}
|
||||
|
||||
hir::ExprKind::Match(ref e, arms, _) => {
|
||||
//
|
||||
// (e)
|
||||
|
@ -1336,6 +1359,7 @@ fn check_expr<'tcx>(this: &mut Liveness<'_, 'tcx>, expr: &'tcx Expr<'tcx>) {
|
|||
| hir::ExprKind::Tup(..)
|
||||
| hir::ExprKind::Binary(..)
|
||||
| hir::ExprKind::Cast(..)
|
||||
| hir::ExprKind::If(..)
|
||||
| hir::ExprKind::DropTemps(..)
|
||||
| hir::ExprKind::Unary(..)
|
||||
| hir::ExprKind::Ret(..)
|
||||
|
|
|
@ -201,6 +201,7 @@ impl<'tcx> CheckInlineAssembly<'tcx> {
|
|||
| ExprKind::Type(..)
|
||||
| ExprKind::Loop(..)
|
||||
| ExprKind::Match(..)
|
||||
| ExprKind::If(..)
|
||||
| ExprKind::Closure(..)
|
||||
| ExprKind::Assign(..)
|
||||
| ExprKind::AssignOp(..)
|
||||
|
|
|
@ -241,6 +241,17 @@ fn resolve_expr<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx h
|
|||
terminating(r.hir_id.local_id);
|
||||
}
|
||||
|
||||
hir::ExprKind::If(ref expr, ref then, Some(ref otherwise)) => {
|
||||
terminating(expr.hir_id.local_id);
|
||||
terminating(then.hir_id.local_id);
|
||||
terminating(otherwise.hir_id.local_id);
|
||||
}
|
||||
|
||||
hir::ExprKind::If(ref expr, ref then, None) => {
|
||||
terminating(expr.hir_id.local_id);
|
||||
terminating(then.hir_id.local_id);
|
||||
}
|
||||
|
||||
hir::ExprKind::Loop(ref body, _, _) => {
|
||||
terminating(body.hir_id.local_id);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue