-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace the "regular" AST->HIR lowering for IfLet* with a desugaring into a MatchExpr. Desugar a simple if let: if let Some(y) = some_value { bar(); } into: match some_value { Some(y) => {bar();}, _ => () } Same applies for IfLetExprConseqElse (if let with an else block). Desugar: if let Some(y) = some_value { bar(); } else { baz(); } into: match some_value { Some(y) => {bar();}, _ => {baz();} } Fixes #1177 gcc/rust/ChangeLog: * backend/rust-compile-block.h: * backend/rust-compile-expr.h: * checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit): * checks/errors/borrowck/rust-bir-builder-expr-stmt.h: * checks/errors/borrowck/rust-bir-builder-lazyboolexpr.h: * checks/errors/borrowck/rust-bir-builder-struct.h: * checks/errors/borrowck/rust-function-collector.h: * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): * checks/errors/privacy/rust-privacy-reporter.h: * checks/errors/rust-const-checker.cc (ConstChecker::visit): * checks/errors/rust-const-checker.h: * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): * checks/errors/rust-unsafe-checker.h: * hir/rust-ast-lower-block.h: * hir/rust-ast-lower.cc (do_if_let_desugaring): (ASTLoweringIfLetBlock::visit): * hir/rust-ast-lower.h (struct_field_name_exists): (translate_visibility): * hir/rust-hir-dump.cc (Dump::do_ifletexpr): (Dump::visit): * hir/rust-hir-dump.h: * hir/tree/rust-hir-expr.h (class IfLetExpr): (class IfLetExprConseqElse): * hir/tree/rust-hir-full-decls.h (class IfLetExpr): (class IfLetExprConseqElse): * hir/tree/rust-hir-visitor.h: * hir/tree/rust-hir.cc (IfLetExpr::as_string): (IfLetExprConseqElse::as_string): (IfLetExpr::accept_vis): (IfLetExprConseqElse::accept_vis): * hir/tree/rust-hir.h: * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): * typecheck/rust-hir-type-check-expr.h: gcc/testsuite/ChangeLog: * rust/compile/if_let_expr.rs: * rust/compile/if_let_expr_simple.rs: New test. * rust/compile/iflet.rs: New test. * rust/execute/torture/iflet.rs: New test. Signed-off-by: Marc Poulhiès <[email protected]>
- Loading branch information
Showing
29 changed files
with
243 additions
and
462 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.