From 75049a3bfee8c3f888994bce3b741a805c631c2a Mon Sep 17 00:00:00 2001 From: Owen Avery Date: Wed, 28 Feb 2024 20:19:04 -0500 Subject: [PATCH] Improve handling of ConstantItem during name resolution 2.0 gcc/rust/ChangeLog: * resolve/rust-default-resolver.cc (DefaultResolver::visit): Scope with Rib::Kind::ConstantItem instead of Rib::Kind::Item. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Remove redundancy in override of ConstantItem visitor. Signed-off-by: Owen Avery --- gcc/rust/resolve/rust-default-resolver.cc | 2 +- gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/gcc/rust/resolve/rust-default-resolver.cc b/gcc/rust/resolve/rust-default-resolver.cc index d9fe9eef36be..8138a8949004 100644 --- a/gcc/rust/resolve/rust-default-resolver.cc +++ b/gcc/rust/resolve/rust-default-resolver.cc @@ -487,7 +487,7 @@ DefaultResolver::visit (AST::ConstantItem &item) }; // FIXME: Why do we need a Rib here? - ctx.scoped (Rib::Kind::Item, item.get_node_id (), expr_vis); + ctx.scoped (Rib::Kind::ConstantItem, item.get_node_id (), expr_vis); } } diff --git a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc index b991145c4d4a..6524a303061b 100644 --- a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc +++ b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc @@ -424,10 +424,7 @@ TopLevel::visit (AST::ConstantItem &const_item) insert_or_error_out (const_item.get_identifier (), const_item, Namespace::Values); - auto expr_vis - = [this, &const_item] () { const_item.get_expr ().accept_vis (*this); }; - - ctx.scoped (Rib::Kind::ConstantItem, const_item.get_node_id (), expr_vis); + DefaultResolver::visit (const_item); } bool