Skip to content

Commit

Permalink
Fix variable shadowing in late resolution 2.0
Browse files Browse the repository at this point in the history
gcc/rust/ChangeLog:

	* resolve/rust-late-name-resolver-2.0.cc
	(Late::visit): Visit the initialization expressions of let
	statements before visiting their patterns.

gcc/testsuite/ChangeLog:

	* rust/compile/nr2/exclude: Remove entries.

Signed-off-by: Owen Avery <[email protected]>
  • Loading branch information
powerboat9 authored and P-E-P committed Oct 27, 2024
1 parent daa5fd3 commit e52fa08
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 8 additions & 2 deletions gcc/rust/resolve/rust-late-name-resolver-2.0.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,14 @@ Late::new_label (Identifier name, NodeId id)
void
Late::visit (AST::LetStmt &let)
{
// so we don't need that method
DefaultResolver::visit (let);
DefaultASTVisitor::visit_outer_attrs (let);
if (let.has_type ())
visit (let.get_type ());
// visit expression before pattern
// this makes variable shadowing work properly
if (let.has_init_expr ())
visit (let.get_init_expr ());
visit (let.get_pattern ());

// 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?
Expand Down
3 changes: 0 additions & 3 deletions gcc/testsuite/rust/compile/nr2/exclude
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,8 @@ issue-1589.rs
issue-1725-1.rs
issue-1725-2.rs
issue-1786.rs
issue-1813.rs
issue-1893.rs
issue-1901.rs
issue-1930.rs
issue-1981.rs
issue-2019-1.rs
issue-2019-2.rs
Expand Down Expand Up @@ -142,7 +140,6 @@ match4.rs
match5.rs
match9.rs
method2.rs
multi_reference_type.rs
multiple_bindings1.rs
multiple_bindings2.rs
name_resolution2.rs
Expand Down

0 comments on commit e52fa08

Please sign in to comment.