aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorOwen Avery <powerboat9.gamer@gmail.com>2024-10-15 15:34:28 -0400
committerP-E-P <32375388+P-E-P@users.noreply.github.com>2024-10-17 13:43:32 +0000
commit20ef2821922d1db2f5455f8dbf455f2f6764739c (patch)
treef74647a590b534497784fc4472b0ccfba3870773 /gcc
parent2b74b5cb755661f5232d5b98613f1295cf73de03 (diff)
downloadgcc-20ef2821922d1db2f5455f8dbf455f2f6764739c.zip
gcc-20ef2821922d1db2f5455f8dbf455f2f6764739c.tar.gz
gcc-20ef2821922d1db2f5455f8dbf455f2f6764739c.tar.bz2
Use name resolver 2.0 in MarkLive
gcc/rust/ChangeLog: * checks/lints/rust-lint-marklive.cc (MarkLive::visit_path_segment): Use name resolver 2.0 when enabled. (MarkLive::visit): Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/checks/lints/rust-lint-marklive.cc31
1 files changed, 27 insertions, 4 deletions
diff --git a/gcc/rust/checks/lints/rust-lint-marklive.cc b/gcc/rust/checks/lints/rust-lint-marklive.cc
index 47f5540..00fefbb 100644
--- a/gcc/rust/checks/lints/rust-lint-marklive.cc
+++ b/gcc/rust/checks/lints/rust-lint-marklive.cc
@@ -155,7 +155,17 @@ MarkLive::visit_path_segment (HIR::PathExprSegment seg)
//
// We should mark them alive all and ignoring other kind of segments.
// If the segment we dont care then just return false is fine
- if (!resolver->lookup_resolved_name (ast_node_id, &ref_node_id))
+ if (flag_name_resolution_2_0)
+ {
+ auto &nr_ctx
+ = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
+
+ if (auto id = nr_ctx.lookup (ast_node_id))
+ ref_node_id = *id;
+ else
+ return false;
+ }
+ else if (!resolver->lookup_resolved_name (ast_node_id, &ref_node_id))
{
if (!resolver->lookup_resolved_type (ast_node_id, &ref_node_id))
return false;
@@ -232,9 +242,22 @@ MarkLive::visit (HIR::TupleIndexExpr &expr)
void
MarkLive::visit (HIR::TypeAlias &alias)
{
- NodeId ast_node_id;
- resolver->lookup_resolved_type (
- alias.get_type_aliased ()->get_mappings ().get_nodeid (), &ast_node_id);
+ NodeId ast_node_id = UNKNOWN_NODEID;
+ if (flag_name_resolution_2_0)
+ {
+ auto &nr_ctx
+ = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
+
+ if (auto id = nr_ctx.lookup (
+ alias.get_type_aliased ()->get_mappings ().get_nodeid ()))
+ ast_node_id = *id;
+ }
+ else
+ {
+ resolver->lookup_resolved_type (
+ alias.get_type_aliased ()->get_mappings ().get_nodeid (), &ast_node_id);
+ }
+
if (auto hid = mappings.lookup_node_to_hir (ast_node_id))
mark_hir_id (*hid);
else