aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorOwen Avery <powerboat9.gamer@gmail.com>2024-10-08 23:29:27 -0400
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-19 15:32:16 +0100
commite71b4d671a71588c0fd7d6833bbec539e82562e3 (patch)
treee1a0da6b781cd77e890cc8c0c3810d731039b5c8 /gcc
parent84f5e7b12e750e48051a9cc0bd969b2e2f73117b (diff)
downloadgcc-e71b4d671a71588c0fd7d6833bbec539e82562e3.zip
gcc-e71b4d671a71588c0fd7d6833bbec539e82562e3.tar.gz
gcc-e71b4d671a71588c0fd7d6833bbec539e82562e3.tar.bz2
gccrs: Fix some issues with canonical path fetching in name resolution 2.0
gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-enumitem.cc: Add includes. (TypeCheckEnumItem::visit): Fetch canonical paths properly when name resolution 2.0 is enabled. * typecheck/rust-hir-type-check-implitem.cc: Add includes. (TypeCheckImplItem::visit): Fetch canonical paths properly when name resolution 2.0 is enabled. * typecheck/rust-hir-type-check-item.cc: Add include. (TypeCheckItem::visit): Fetch canonical paths properly when name resolution 2.0 is enabled. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-enumitem.cc80
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-implitem.cc23
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-item.cc43
-rw-r--r--gcc/testsuite/rust/compile/nr2/exclude8
4 files changed, 132 insertions, 22 deletions
diff --git a/gcc/rust/typecheck/rust-hir-type-check-enumitem.cc b/gcc/rust/typecheck/rust-hir-type-check-enumitem.cc
index 72d8791..a9154c6 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-enumitem.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-enumitem.cc
@@ -20,6 +20,10 @@
#include "rust-hir-type-check-expr.h"
#include "rust-hir-type-check-enumitem.h"
#include "rust-type-util.h"
+#include "rust-immutable-name-resolution-context.h"
+
+// for flag_name_resolution_2_0
+#include "options.h"
namespace Rust {
namespace Resolver {
@@ -75,8 +79,23 @@ TypeCheckEnumItem::visit (HIR::EnumItem &item)
rust_assert (ok);
context->insert_type (mapping, isize);
- auto canonical_path
- = mappings.lookup_canonical_path (item.get_mappings ().get_nodeid ());
+ tl::optional<CanonicalPath> canonical_path;
+
+ if (flag_name_resolution_2_0)
+ {
+ auto nr_ctx
+ = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
+
+ canonical_path
+ = nr_ctx.types.to_canonical_path (item.get_mappings ().get_nodeid ());
+ }
+ else
+ {
+ canonical_path
+ = mappings.lookup_canonical_path (item.get_mappings ().get_nodeid ());
+ }
+
+ rust_assert (canonical_path.has_value ());
RustIdent ident{*canonical_path, item.get_locus ()};
variant = new TyTy::VariantDef (item.get_mappings ().get_hirid (),
@@ -104,8 +123,23 @@ TypeCheckEnumItem::visit (HIR::EnumItemDiscriminant &item)
TyTy::TyWithLocation (expected_ty),
TyTy::TyWithLocation (capacity_type), item.get_locus ());
- auto canonical_path
- = mappings.lookup_canonical_path (item.get_mappings ().get_nodeid ());
+ tl::optional<CanonicalPath> canonical_path;
+
+ if (flag_name_resolution_2_0)
+ {
+ auto nr_ctx
+ = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
+
+ canonical_path
+ = nr_ctx.types.to_canonical_path (item.get_mappings ().get_nodeid ());
+ }
+ else
+ {
+ canonical_path
+ = mappings.lookup_canonical_path (item.get_mappings ().get_nodeid ());
+ }
+
+ rust_assert (canonical_path.has_value ());
RustIdent ident{*canonical_path, item.get_locus ()};
variant = new TyTy::VariantDef (item.get_mappings ().get_hirid (),
@@ -151,8 +185,23 @@ TypeCheckEnumItem::visit (HIR::EnumItemTuple &item)
rust_assert (ok);
context->insert_type (mapping, isize);
- auto canonical_path
- = mappings.lookup_canonical_path (item.get_mappings ().get_nodeid ());
+ tl::optional<CanonicalPath> canonical_path;
+
+ if (flag_name_resolution_2_0)
+ {
+ auto nr_ctx
+ = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
+
+ canonical_path
+ = nr_ctx.types.to_canonical_path (item.get_mappings ().get_nodeid ());
+ }
+ else
+ {
+ canonical_path
+ = mappings.lookup_canonical_path (item.get_mappings ().get_nodeid ());
+ }
+
+ rust_assert (canonical_path.has_value ());
RustIdent ident{*canonical_path, item.get_locus ()};
variant = new TyTy::VariantDef (item.get_mappings ().get_hirid (),
@@ -197,8 +246,23 @@ TypeCheckEnumItem::visit (HIR::EnumItemStruct &item)
rust_assert (ok);
context->insert_type (mapping, isize);
- auto canonical_path
- = mappings.lookup_canonical_path (item.get_mappings ().get_nodeid ());
+ tl::optional<CanonicalPath> canonical_path;
+
+ if (flag_name_resolution_2_0)
+ {
+ auto nr_ctx
+ = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
+
+ canonical_path
+ = nr_ctx.types.to_canonical_path (item.get_mappings ().get_nodeid ());
+ }
+ else
+ {
+ canonical_path
+ = mappings.lookup_canonical_path (item.get_mappings ().get_nodeid ());
+ }
+
+ rust_assert (canonical_path.has_value ());
RustIdent ident{*canonical_path, item.get_locus ()};
variant = new TyTy::VariantDef (item.get_mappings ().get_hirid (),
diff --git a/gcc/rust/typecheck/rust-hir-type-check-implitem.cc b/gcc/rust/typecheck/rust-hir-type-check-implitem.cc
index 58d59d9..0036e9a 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-implitem.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-implitem.cc
@@ -24,6 +24,10 @@
#include "rust-hir-type-check-pattern.h"
#include "rust-type-util.h"
#include "rust-tyty.h"
+#include "rust-immutable-name-resolution-context.h"
+
+// for flag_name_resolution_2_0
+#include "options.h"
namespace Rust {
namespace Resolver {
@@ -461,8 +465,23 @@ TypeCheckImplItem::visit (HIR::Function &function)
TypeCheckPattern::Resolve (param.get_param_name ().get (), param_tyty);
}
- auto canonical_path
- = mappings.lookup_canonical_path (function.get_mappings ().get_nodeid ());
+ tl::optional<CanonicalPath> canonical_path;
+
+ if (flag_name_resolution_2_0)
+ {
+ auto nr_ctx
+ = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
+
+ canonical_path = nr_ctx.values.to_canonical_path (
+ function.get_mappings ().get_nodeid ());
+ }
+ else
+ {
+ canonical_path = mappings.lookup_canonical_path (
+ function.get_mappings ().get_nodeid ());
+ }
+
+ rust_assert (canonical_path.has_value ());
RustIdent ident{*canonical_path, function.get_locus ()};
auto fnType = new TyTy::FnType (
diff --git a/gcc/rust/typecheck/rust-hir-type-check-item.cc b/gcc/rust/typecheck/rust-hir-type-check-item.cc
index 3858d51..4ea6852 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-item.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-item.cc
@@ -32,6 +32,9 @@
#include "rust-type-util.h"
#include "rust-tyty-variance-analysis.h"
+// for flag_name_resolution_2_0
+#include "options.h"
+
namespace Rust {
namespace Resolver {
@@ -343,8 +346,24 @@ TypeCheckItem::visit (HIR::Enum &enum_decl)
}
// get the path
- auto canonical_path
- = mappings.lookup_canonical_path (enum_decl.get_mappings ().get_nodeid ());
+ tl::optional<CanonicalPath> canonical_path;
+
+ if (flag_name_resolution_2_0)
+ {
+ auto nr_ctx
+ = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
+
+ canonical_path = nr_ctx.types.to_canonical_path (
+ enum_decl.get_mappings ().get_nodeid ());
+ }
+ else
+ {
+ canonical_path = mappings.lookup_canonical_path (
+ enum_decl.get_mappings ().get_nodeid ());
+ }
+
+ rust_assert (canonical_path.has_value ());
+
RustIdent ident{*canonical_path, enum_decl.get_locus ()};
// multi variant ADT
@@ -390,8 +409,24 @@ TypeCheckItem::visit (HIR::Union &union_decl)
}
// get the path
- auto canonical_path
- = mappings.lookup_canonical_path (union_decl.get_mappings ().get_nodeid ());
+ tl::optional<CanonicalPath> canonical_path;
+
+ if (flag_name_resolution_2_0)
+ {
+ auto nr_ctx
+ = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
+
+ canonical_path = nr_ctx.types.to_canonical_path (
+ union_decl.get_mappings ().get_nodeid ());
+ }
+ else
+ {
+ canonical_path = mappings.lookup_canonical_path (
+ union_decl.get_mappings ().get_nodeid ());
+ }
+
+ rust_assert (canonical_path.has_value ());
+
RustIdent ident{*canonical_path, union_decl.get_locus ()};
// there is only a single variant
diff --git a/gcc/testsuite/rust/compile/nr2/exclude b/gcc/testsuite/rust/compile/nr2/exclude
index f254c56..e0aa155 100644
--- a/gcc/testsuite/rust/compile/nr2/exclude
+++ b/gcc/testsuite/rust/compile/nr2/exclude
@@ -33,7 +33,6 @@ const_generics_3.rs
const_generics_4.rs
const_generics_5.rs
const_generics_7.rs
-const_generics_8.rs
derive_empty.rs
derive_macro1.rs
derive_macro3.rs
@@ -61,8 +60,6 @@ generics8.rs
generics9.rs
if_let_expr.rs
infer-crate-name.rs
-issue-1005.rs
-issue-1006.rs
issue-1019.rs
issue-1031.rs
issue-1034.rs
@@ -92,7 +89,6 @@ issue-2019-2.rs
issue-2019-3.rs
issue-2036.rs
issue-2037.rs
-issue-2039.rs
issue-2043.rs
issue-2070.rs
issue-2105.rs
@@ -141,7 +137,6 @@ macros/mbe/macro43.rs
macros/mbe/macro44.rs
macros/mbe/macro50.rs
macros/mbe/macro54.rs
-macros/mbe/macro55.rs
macros/mbe/macro6.rs
macros/mbe/macro_rules_macro_rules.rs
macros/mbe/macro_use1.rs
@@ -154,7 +149,6 @@ match4.rs
match5.rs
match8.rs
match9.rs
-method1.rs
method2.rs
missing_constructor_fields.rs
multi_reference_type.rs
@@ -222,8 +216,6 @@ unsafe2.rs
unsafe3.rs
unsafe6.rs
unsafe7.rs
-unsafe8.rs
-unsafe9.rs
use_1.rs
use_2.rs
v0-mangle1.rs