diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-05 15:34:25 +0000 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-31 21:07:15 +0200 |
commit | 02afa004778d49b86fb8c7320efaee4cff4e3a9d (patch) | |
tree | 42c111ed2e49a5715d57812d443b51de56447180 | |
parent | d68ebd1abff36196608e3411a8b1cddd6be80e0f (diff) | |
download | gcc-02afa004778d49b86fb8c7320efaee4cff4e3a9d.zip gcc-02afa004778d49b86fb8c7320efaee4cff4e3a9d.tar.gz gcc-02afa004778d49b86fb8c7320efaee4cff4e3a9d.tar.bz2 |
gccrs: name-resolution: Handle let-else properly
gcc/rust/ChangeLog:
* resolve/rust-ast-resolve-stmt.h: Add handling for diverging else.
* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Likewise.
-rw-r--r-- | gcc/rust/resolve/rust-ast-resolve-stmt.h | 7 | ||||
-rw-r--r-- | gcc/rust/resolve/rust-late-name-resolver-2.0.cc | 3 |
2 files changed, 7 insertions, 3 deletions
diff --git a/gcc/rust/resolve/rust-ast-resolve-stmt.h b/gcc/rust/resolve/rust-ast-resolve-stmt.h index d3ff14f..6c99d6a 100644 --- a/gcc/rust/resolve/rust-ast-resolve-stmt.h +++ b/gcc/rust/resolve/rust-ast-resolve-stmt.h @@ -73,9 +73,10 @@ public: void visit (AST::LetStmt &stmt) override { if (stmt.has_init_expr ()) - { - ResolveExpr::go (stmt.get_init_expr (), prefix, canonical_prefix); - } + ResolveExpr::go (stmt.get_init_expr (), prefix, canonical_prefix); + + if (stmt.has_else_expr ()) + ResolveExpr::go (stmt.get_else_expr (), prefix, canonical_prefix); PatternDeclaration::go (stmt.get_pattern (), Rib::ItemType::Var); if (stmt.has_type ()) diff --git a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc index cf7b7dc..95df727 100644 --- a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc +++ b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc @@ -140,6 +140,9 @@ Late::visit (AST::LetStmt &let) visit (let.get_init_expr ()); visit (let.get_pattern ()); + if (let.has_else_expr ()) + visit (let.get_init_expr ()); + // how do we deal with the fact that `let a = blipbloup` should look for a // label and cannot go through function ribs, but `let a = blipbloup()` can? |