ensure there are no stmts for expr check

This commit is contained in:
Centri3 2023-06-09 11:43:58 -05:00
parent 0c545c7bcc
commit c1c134a288
2 changed files with 3 additions and 15 deletions

View File

@ -139,13 +139,13 @@ impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> {
match e.kind {
// fix #10776
ExprKind::Block(block, ..) => {
if let Some(e) = block.expr {
if let Some(e) = block.expr && block.stmts.is_empty() {
self.visit_expr(e);
return;
}
if let [stmt] = block.stmts && block.stmts.len() == 1 {
if let [stmt, rest @ ..] = block.stmts && rest.is_empty() {
match stmt.kind {
StmtKind::Expr(e) | StmtKind::Semi(e) => self.visit_expr(e),
_ => {},

View File

@ -62,23 +62,11 @@ error: sub-expression diverges
LL | 18 => false || { return },
| ^^^^^^
error: sub-expression diverges
--> $DIR/diverging_sub_expression.rs:47:36
|
LL | 19 => true || { _ = 1; return },
| ^^^^^^
error: sub-expression diverges
--> $DIR/diverging_sub_expression.rs:48:37
|
LL | 20 => false || { _ = 1; return },
| ^^^^^^
error: sub-expression diverges
--> $DIR/diverging_sub_expression.rs:52:26
|
LL | _ => true || break,
| ^^^^^
error: aborting due to 13 previous errors
error: aborting due to 11 previous errors