]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: nr1.0: Remove rust/typecheck support
authorOwen Avery <powerboat9.gamer@gmail.com>
Thu, 3 Jul 2025 21:48:22 +0000 (17:48 -0400)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 5 Aug 2025 14:36:59 +0000 (16:36 +0200)
gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-base.cc
(TypeCheckBase::TypeCheckBase): Remove initialization of
resolver field.
* typecheck/rust-hir-type-check-base.h
(TypeCheckBase::resolver): Remove field.
* typecheck/rust-hir-trait-resolve.cc: Remove "options.h"
include.
(TraitResolver::resolve_path_to_trait): Assume name resolution
2.0 is always enabled.
* typecheck/rust-hir-type-check-enumitem.cc: Remove "options.h"
include.
(TypeCheckEnumItem::visit): Assume name resolution 2.0 is always
enabled.
* typecheck/rust-hir-type-check-expr.cc: Remove "options.h"
include.
(TypeCheckExpr::visit): Assume name resolution 2.0 is always
enabled.
(TypeCheckExpr::resolve_operator_overload): Likewise.
(TypeCheckExpr::resolve_fn_trait_call): Likewise.
* typecheck/rust-hir-type-check-implitem.cc: Remove "options.h"
include.
(TypeCheckImplItem::visit): Assume name resolution 2.0 is always
enabled.
* typecheck/rust-hir-type-check-item.cc: Remove "options.h"
include.
(TypeCheckItem::visit): Assume name resolution 2.0 is always
enabled.
* typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::visit):
Likewise.
(TypeCheckExpr::resolve_root_path): Likewise.
(TypeCheckExpr::resolve_segments): Likewise.
* typecheck/rust-hir-type-check-pattern.cc: Remove "options.h"
include.
(TypeCheckPattern::visit): Assume name resolution 2.0 is always
enabled.
* typecheck/rust-hir-type-check-type.cc
(TypeCheckType::resolve_root_path): Likewise.
(ResolveWhereClauseItem::visit): Likewise.
* typecheck/rust-hir-type-check.cc: Remove "options.h" include.
(TraitItemReference::get_type_from_fn): Assume name resolution
2.0 is always enabled.
* typecheck/rust-type-util.cc (query_type): Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
12 files changed:
gcc/rust/typecheck/rust-hir-trait-resolve.cc
gcc/rust/typecheck/rust-hir-type-check-base.cc
gcc/rust/typecheck/rust-hir-type-check-base.h
gcc/rust/typecheck/rust-hir-type-check-enumitem.cc
gcc/rust/typecheck/rust-hir-type-check-expr.cc
gcc/rust/typecheck/rust-hir-type-check-implitem.cc
gcc/rust/typecheck/rust-hir-type-check-item.cc
gcc/rust/typecheck/rust-hir-type-check-path.cc
gcc/rust/typecheck/rust-hir-type-check-pattern.cc
gcc/rust/typecheck/rust-hir-type-check-type.cc
gcc/rust/typecheck/rust-hir-type-check.cc
gcc/rust/typecheck/rust-type-util.cc

index 7f224076cd7421e4ab0b6fa490cf3ad4291151d8..e2e9dbf83b030e511cea791402aa2a4553600fd7 100644 (file)
@@ -22,9 +22,6 @@
 #include "rust-type-util.h"
 #include "rust-immutable-name-resolution-context.h"
 
-// used for flag_name_resolution_2_0
-#include "options.h"
-
 namespace Rust {
 namespace Resolver {
 
@@ -123,27 +120,15 @@ bool
 TraitResolver::resolve_path_to_trait (const HIR::TypePath &path,
                                      HIR::Trait **resolved) const
 {
+  auto &nr_ctx
+    = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
+
   NodeId ref;
-  bool ok;
-  if (flag_name_resolution_2_0)
+  if (auto ref_opt = nr_ctx.lookup (path.get_mappings ().get_nodeid ()))
     {
-      auto &nr_ctx
-       = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
-
-      auto ref_opt = nr_ctx.lookup (path.get_mappings ().get_nodeid ());
-
-      if ((ok = ref_opt.has_value ()))
-       ref = *ref_opt;
+      ref = *ref_opt;
     }
   else
-    {
-      auto path_nodeid = path.get_mappings ().get_nodeid ();
-      ok = resolver->lookup_resolved_type (path_nodeid, &ref)
-          || resolver->lookup_resolved_name (path_nodeid, &ref)
-          || resolver->lookup_resolved_macro (path_nodeid, &ref);
-    }
-
-  if (!ok)
     {
       rust_error_at (path.get_locus (), "Failed to resolve path to node-id");
       return false;
index 4bbd52a29f4580ad66831d717ecc6dcc448e3ed4..c1f15afae61e3c38ad9039e292510a466c7aaf4e 100644 (file)
@@ -28,8 +28,7 @@ namespace Rust {
 namespace Resolver {
 
 TypeCheckBase::TypeCheckBase ()
-  : mappings (Analysis::Mappings::get ()), resolver (Resolver::get ()),
-    context (TypeCheckContext::get ())
+  : mappings (Analysis::Mappings::get ()), context (TypeCheckContext::get ())
 {}
 
 void
index a8084f2bf5b8dc75685080e7f1f4c384be1f6fe7..fc55516fab10fc82b43ecfe44e8a43f027e2740e 100644 (file)
@@ -69,7 +69,6 @@ protected:
                                                 location_t locus);
 
   Analysis::Mappings &mappings;
-  Resolver *resolver;
   TypeCheckContext *context;
 };
 
index 2dbd84d254aeea383d860aeab7f39f0d738a7632..23a8cca3d1477a595ac7f757f5bf7b743fb72317 100644 (file)
@@ -23,9 +23,6 @@
 #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 {
 
@@ -79,25 +76,13 @@ TypeCheckEnumItem::visit (HIR::EnumItem &item)
   rust_assert (ok);
   context->insert_type (mapping, isize);
 
-  tl::optional<CanonicalPath> canonical_path;
-
-  if (flag_name_resolution_2_0)
-    {
-      auto &nr_ctx
-       = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
-
-      canonical_path
-       = nr_ctx.to_canonical_path (item.get_mappings ().get_nodeid ());
-    }
-  else
-    {
-      canonical_path
-       = mappings.lookup_canonical_path (item.get_mappings ().get_nodeid ());
-    }
+  auto &nr_ctx
+    = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
 
-  rust_assert (canonical_path.has_value ());
+  CanonicalPath canonical_path
+    = nr_ctx.to_canonical_path (item.get_mappings ().get_nodeid ());
 
-  RustIdent ident{*canonical_path, item.get_locus ()};
+  RustIdent ident{canonical_path, item.get_locus ()};
   variant = new TyTy::VariantDef (item.get_mappings ().get_hirid (),
                                  item.get_mappings ().get_defid (),
                                  item.get_identifier ().as_string (), ident,
@@ -123,25 +108,13 @@ TypeCheckEnumItem::visit (HIR::EnumItemDiscriminant &item)
              TyTy::TyWithLocation (expected_ty),
              TyTy::TyWithLocation (capacity_type), item.get_locus ());
 
-  tl::optional<CanonicalPath> canonical_path;
-
-  if (flag_name_resolution_2_0)
-    {
-      auto &nr_ctx
-       = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
-
-      canonical_path
-       = nr_ctx.to_canonical_path (item.get_mappings ().get_nodeid ());
-    }
-  else
-    {
-      canonical_path
-       = mappings.lookup_canonical_path (item.get_mappings ().get_nodeid ());
-    }
+  auto &nr_ctx
+    = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
 
-  rust_assert (canonical_path.has_value ());
+  CanonicalPath canonical_path
+    = nr_ctx.to_canonical_path (item.get_mappings ().get_nodeid ());
 
-  RustIdent ident{*canonical_path, item.get_locus ()};
+  RustIdent ident{canonical_path, item.get_locus ()};
   variant
     = new TyTy::VariantDef (item.get_mappings ().get_hirid (),
                            item.get_mappings ().get_defid (),
@@ -185,25 +158,13 @@ TypeCheckEnumItem::visit (HIR::EnumItemTuple &item)
   rust_assert (ok);
   context->insert_type (mapping, isize);
 
-  tl::optional<CanonicalPath> canonical_path;
+  auto &nr_ctx
+    = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
 
-  if (flag_name_resolution_2_0)
-    {
-      auto &nr_ctx
-       = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
-
-      canonical_path
-       = nr_ctx.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 ());
+  CanonicalPath canonical_path
+    = nr_ctx.to_canonical_path (item.get_mappings ().get_nodeid ());
 
-  RustIdent ident{*canonical_path, item.get_locus ()};
+  RustIdent ident{canonical_path, item.get_locus ()};
   variant = new TyTy::VariantDef (item.get_mappings ().get_hirid (),
                                  item.get_mappings ().get_defid (),
                                  item.get_identifier ().as_string (), ident,
@@ -245,25 +206,13 @@ TypeCheckEnumItem::visit (HIR::EnumItemStruct &item)
   rust_assert (ok);
   context->insert_type (mapping, isize);
 
-  tl::optional<CanonicalPath> canonical_path;
-
-  if (flag_name_resolution_2_0)
-    {
-      auto &nr_ctx
-       = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
-
-      canonical_path
-       = nr_ctx.to_canonical_path (item.get_mappings ().get_nodeid ());
-    }
-  else
-    {
-      canonical_path
-       = mappings.lookup_canonical_path (item.get_mappings ().get_nodeid ());
-    }
+  auto &nr_ctx
+    = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
 
-  rust_assert (canonical_path.has_value ());
+  CanonicalPath canonical_path
+    = nr_ctx.to_canonical_path (item.get_mappings ().get_nodeid ());
 
-  RustIdent ident{*canonical_path, item.get_locus ()};
+  RustIdent ident{canonical_path, item.get_locus ()};
   variant = new TyTy::VariantDef (item.get_mappings ().get_hirid (),
                                  item.get_mappings ().get_defid (),
                                  item.get_identifier ().as_string (), ident,
index 9f8d31109b15fef358006d111b06012b16017d9f..ead751a0a7d64693eff76a154231fea9f653aa2e 100644 (file)
@@ -34,9 +34,6 @@
 #include "rust-immutable-name-resolution-context.h"
 #include "rust-compile-base.h"
 
-// for flag_name_resolution_2_0
-#include "options.h"
-
 namespace Rust {
 namespace Resolver {
 
@@ -1460,26 +1457,11 @@ TypeCheckExpr::visit (HIR::MethodCallExpr &expr)
   // store the expected fntype
   context->insert_type (expr.get_method_name ().get_mappings (), lookup);
 
-  if (flag_name_resolution_2_0)
-    {
-      auto &nr_ctx = const_cast<Resolver2_0::NameResolutionContext &> (
-       Resolver2_0::ImmutableNameResolutionContext::get ().resolver ());
+  auto &nr_ctx = const_cast<Resolver2_0::NameResolutionContext &> (
+    Resolver2_0::ImmutableNameResolutionContext::get ().resolver ());
 
-      nr_ctx.map_usage (Resolver2_0::Usage (expr.get_mappings ().get_nodeid ()),
-                       Resolver2_0::Definition (resolved_node_id));
-    }
-  // set up the resolved name on the path
-  else if (resolver->get_name_scope ().decl_was_declared_here (
-            resolved_node_id))
-    {
-      resolver->insert_resolved_name (expr.get_mappings ().get_nodeid (),
-                                     resolved_node_id);
-    }
-  else
-    {
-      resolver->insert_resolved_misc (expr.get_mappings ().get_nodeid (),
-                                     resolved_node_id);
-    }
+  nr_ctx.map_usage (Resolver2_0::Usage (expr.get_mappings ().get_nodeid ()),
+                   Resolver2_0::Definition (resolved_node_id));
 
   // return the result of the function back
   infered = function_ret_tyty;
@@ -1821,19 +1803,12 @@ TypeCheckExpr::visit (HIR::ClosureExpr &expr)
   // Resolve closure captures
 
   std::set<NodeId> captures;
-  if (flag_name_resolution_2_0)
-    {
-      auto &nr_ctx = const_cast<Resolver2_0::NameResolutionContext &> (
-       Resolver2_0::ImmutableNameResolutionContext::get ().resolver ());
+  auto &nr_ctx = const_cast<Resolver2_0::NameResolutionContext &> (
+    Resolver2_0::ImmutableNameResolutionContext::get ().resolver ());
 
-      if (auto opt_cap = nr_ctx.mappings.lookup_captures (closure_node_id))
-       for (auto cap : opt_cap.value ())
-         captures.insert (cap);
-    }
-  else
-    {
-      captures = resolver->get_captures (closure_node_id);
-    }
+  if (auto opt_cap = nr_ctx.mappings.lookup_captures (closure_node_id))
+    for (auto cap : opt_cap.value ())
+      captures.insert (cap);
 
   infered = new TyTy::ClosureType (ref, id, ident, closure_args, result_type,
                                   subst_refs, captures);
@@ -2141,19 +2116,11 @@ TypeCheckExpr::resolve_operator_overload (
   context->insert_operator_overload (expr.get_mappings ().get_hirid (), type);
 
   // set up the resolved name on the path
-  if (flag_name_resolution_2_0)
-    {
-      auto &nr_ctx = const_cast<Resolver2_0::NameResolutionContext &> (
-       Resolver2_0::ImmutableNameResolutionContext::get ().resolver ());
+  auto &nr_ctx = const_cast<Resolver2_0::NameResolutionContext &> (
+    Resolver2_0::ImmutableNameResolutionContext::get ().resolver ());
 
-      nr_ctx.map_usage (Resolver2_0::Usage (expr.get_mappings ().get_nodeid ()),
-                       Resolver2_0::Definition (resolved_node_id));
-    }
-  else
-    {
-      resolver->insert_resolved_name (expr.get_mappings ().get_nodeid (),
-                                     resolved_node_id);
-    }
+  nr_ctx.map_usage (Resolver2_0::Usage (expr.get_mappings ().get_nodeid ()),
+                   Resolver2_0::Definition (resolved_node_id));
 
   // return the result of the function back
   infered = function_ret_tyty;
@@ -2346,32 +2313,15 @@ TypeCheckExpr::resolve_fn_trait_call (HIR::CallExpr &expr,
   context->insert_operator_overload (expr.get_mappings ().get_hirid (), fn);
 
   // set up the resolved name on the path
-  if (flag_name_resolution_2_0)
-    {
-      auto &nr_ctx = const_cast<Resolver2_0::NameResolutionContext &> (
-       Resolver2_0::ImmutableNameResolutionContext::get ().resolver ());
+  auto &nr_ctx = const_cast<Resolver2_0::NameResolutionContext &> (
+    Resolver2_0::ImmutableNameResolutionContext::get ().resolver ());
 
-      auto existing = nr_ctx.lookup (expr.get_mappings ().get_nodeid ());
-      if (existing)
-       rust_assert (*existing == resolved_node_id);
-      else
-       nr_ctx.map_usage (Resolver2_0::Usage (
-                           expr.get_mappings ().get_nodeid ()),
-                         Resolver2_0::Definition (resolved_node_id));
-    }
+  auto existing = nr_ctx.lookup (expr.get_mappings ().get_nodeid ());
+  if (existing)
+    rust_assert (*existing == resolved_node_id);
   else
-    {
-      NodeId existing = UNKNOWN_NODEID;
-      bool ok
-       = resolver->lookup_resolved_name (expr.get_mappings ().get_nodeid (),
-                                         &existing);
-
-      if (ok)
-       rust_assert (existing == resolved_node_id);
-      else
-       resolver->insert_resolved_name (expr.get_mappings ().get_nodeid (),
-                                       resolved_node_id);
-    }
+    nr_ctx.map_usage (Resolver2_0::Usage (expr.get_mappings ().get_nodeid ()),
+                     Resolver2_0::Definition (resolved_node_id));
 
   // return the result of the function back
   *result = function_ret_tyty;
index 00f0cc669747354a26b0b07532e61fcd5238a394..76ff6903077d8866ab8f9c5115dc1f2e3e5fa71f 100644 (file)
@@ -28,9 +28,6 @@
 #include "rust-tyty.h"
 #include "rust-immutable-name-resolution-context.h"
 
-// for flag_name_resolution_2_0
-#include "options.h"
-
 namespace Rust {
 namespace Resolver {
 
@@ -338,25 +335,13 @@ TypeCheckImplItem::visit (HIR::Function &function)
        TyTy::FnParam (param.get_param_name ().clone_pattern (), param_tyty));
     }
 
-  tl::optional<CanonicalPath> canonical_path;
-
-  if (flag_name_resolution_2_0)
-    {
-      auto &nr_ctx
-       = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
-
-      canonical_path
-       = nr_ctx.to_canonical_path (function.get_mappings ().get_nodeid ());
-    }
-  else
-    {
-      canonical_path = mappings.lookup_canonical_path (
-       function.get_mappings ().get_nodeid ());
-    }
+  auto &nr_ctx
+    = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
 
-  rust_assert (canonical_path.has_value ());
+  CanonicalPath canonical_path
+    = nr_ctx.to_canonical_path (function.get_mappings ().get_nodeid ());
 
-  RustIdent ident{*canonical_path, function.get_locus ()};
+  RustIdent ident{canonical_path, function.get_locus ()};
   auto fnType = new TyTy::FnType (
     function.get_mappings ().get_hirid (),
     function.get_mappings ().get_defid (),
index 70622778a1c00ccfd676e20f55b8735a302a1019..e86525a68e55d07659d73439e4f83027714e3147 100644 (file)
@@ -33,9 +33,6 @@
 #include "rust-type-util.h"
 #include "rust-tyty-variance-analysis.h"
 
-// for flag_name_resolution_2_0
-#include "options.h"
-
 namespace Rust {
 namespace Resolver {
 
@@ -195,24 +192,11 @@ TypeCheckItem::visit (HIR::TupleStruct &struct_decl)
 
   // get the path
 
-  auto path = CanonicalPath::create_empty ();
+  auto &nr_ctx
+    = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
 
-  // FIXME: HACK: ARTHUR: Disgusting
-  if (flag_name_resolution_2_0)
-    {
-      auto &nr_ctx
-       = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
-
-      path
-       = nr_ctx.to_canonical_path (struct_decl.get_mappings ().get_nodeid ());
-    }
-  else
-    {
-      path
-       = mappings
-           .lookup_canonical_path (struct_decl.get_mappings ().get_nodeid ())
-           .value ();
-    }
+  CanonicalPath path
+    = nr_ctx.to_canonical_path (struct_decl.get_mappings ().get_nodeid ());
 
   RustIdent ident{path, struct_decl.get_locus ()};
 
@@ -275,23 +259,11 @@ TypeCheckItem::visit (HIR::StructStruct &struct_decl)
       context->insert_type (field.get_mappings (), ty_field->get_field_type ());
     }
 
-  auto path = CanonicalPath::create_empty ();
+  auto &nr_ctx
+    = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
 
-  // FIXME: HACK: ARTHUR: Disgusting
-  if (flag_name_resolution_2_0)
-    {
-      auto &nr_ctx
-       = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
-      path
-       = nr_ctx.to_canonical_path (struct_decl.get_mappings ().get_nodeid ());
-    }
-  else
-    {
-      path
-       = mappings
-           .lookup_canonical_path (struct_decl.get_mappings ().get_nodeid ())
-           .value ();
-    }
+  CanonicalPath path
+    = nr_ctx.to_canonical_path (struct_decl.get_mappings ().get_nodeid ());
 
   RustIdent ident{path, struct_decl.get_locus ()};
 
@@ -362,26 +334,14 @@ TypeCheckItem::visit (HIR::Enum &enum_decl)
        }
     }
 
-  // get the path
-  tl::optional<CanonicalPath> canonical_path;
+  auto &nr_ctx
+    = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
 
-  if (flag_name_resolution_2_0)
-    {
-      auto &nr_ctx
-       = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
-
-      canonical_path
-       = nr_ctx.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 ());
+  // get the path
+  CanonicalPath canonical_path
+    = nr_ctx.to_canonical_path (enum_decl.get_mappings ().get_nodeid ());
 
-  RustIdent ident{*canonical_path, enum_decl.get_locus ()};
+  RustIdent ident{canonical_path, enum_decl.get_locus ()};
 
   // multi variant ADT
   auto *type
@@ -426,26 +386,14 @@ TypeCheckItem::visit (HIR::Union &union_decl)
                            ty_variant->get_field_type ());
     }
 
-  // get the path
-  tl::optional<CanonicalPath> canonical_path;
+  auto &nr_ctx
+    = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
 
-  if (flag_name_resolution_2_0)
-    {
-      auto &nr_ctx
-       = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
-
-      canonical_path
-       = nr_ctx.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 ());
+  // get the path
+  CanonicalPath canonical_path
+    = nr_ctx.to_canonical_path (union_decl.get_mappings ().get_nodeid ());
 
-  RustIdent ident{*canonical_path, union_decl.get_locus ()};
+  RustIdent ident{canonical_path, union_decl.get_locus ()};
 
   // there is only a single variant
   std::vector<TyTy::VariantDef *> variants;
@@ -602,21 +550,11 @@ TypeCheckItem::visit (HIR::Function &function)
        TyTy::FnParam (param.get_param_name ().clone_pattern (), param_tyty));
     }
 
-  auto path = CanonicalPath::create_empty ();
+  auto &nr_ctx
+    = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
 
-  // FIXME: HACK: ARTHUR: Disgusting
-  if (flag_name_resolution_2_0)
-    {
-      auto &nr_ctx
-       = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
-      path = nr_ctx.to_canonical_path (function.get_mappings ().get_nodeid ());
-    }
-  else
-    {
-      path = mappings
-              .lookup_canonical_path (function.get_mappings ().get_nodeid ())
-              .value ();
-    }
+  CanonicalPath path
+    = nr_ctx.to_canonical_path (function.get_mappings ().get_nodeid ());
 
   RustIdent ident{path, function.get_locus ()};
 
index 5662da5310e5efd0bdc5db887bac4f30739af688..cc5c412f9868a02e6fa258cd04a2e9f6effd621f 100644 (file)
@@ -157,20 +157,11 @@ TypeCheckExpr::visit (HIR::QualifiedPathInExpression &expr)
   bool fully_resolved = expr.get_segments ().size () <= 1;
   if (fully_resolved)
     {
-      if (flag_name_resolution_2_0)
-       {
-         auto &nr_ctx = const_cast<Resolver2_0::NameResolutionContext &> (
-           Resolver2_0::ImmutableNameResolutionContext::get ().resolver ());
+      auto &nr_ctx = const_cast<Resolver2_0::NameResolutionContext &> (
+       Resolver2_0::ImmutableNameResolutionContext::get ().resolver ());
 
-         nr_ctx.map_usage (Resolver2_0::Usage (
-                             expr.get_mappings ().get_nodeid ()),
-                           Resolver2_0::Definition (root_resolved_node_id));
-       }
-      else
-       {
-         resolver->insert_resolved_name (expr.get_mappings ().get_nodeid (),
-                                         root_resolved_node_id);
-       }
+      nr_ctx.map_usage (Resolver2_0::Usage (expr.get_mappings ().get_nodeid ()),
+                       Resolver2_0::Definition (root_resolved_node_id));
       return;
     }
 
@@ -264,24 +255,16 @@ TypeCheckExpr::resolve_root_path (HIR::PathInExpression &expr, size_t *offset,
       bool is_root = *offset == 0;
       NodeId ast_node_id = seg.get_mappings ().get_nodeid ();
 
-      // then lookup the reference_node_id
-      NodeId ref_node_id = UNKNOWN_NODEID;
+      auto &nr_ctx
+       = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
 
-      if (flag_name_resolution_2_0)
+      // lookup the reference_node_id
+      NodeId ref_node_id;
+      if (auto res = nr_ctx.lookup (ast_node_id))
        {
-         auto &nr_ctx
-           = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
-
-         // assign the ref_node_id if we've found something
-         nr_ctx.lookup (ast_node_id).map ([&ref_node_id] (NodeId resolved) {
-           ref_node_id = resolved;
-         });
+         ref_node_id = *res;
        }
-      else if (!resolver->lookup_resolved_name (ast_node_id, &ref_node_id))
-       resolver->lookup_resolved_type (ast_node_id, &ref_node_id);
-
-      // ref_node_id is the NodeId that the segments refers to.
-      if (ref_node_id == UNKNOWN_NODEID)
+      else
        {
          if (root_tyty != nullptr && *offset > 0)
            {
@@ -561,33 +544,12 @@ TypeCheckExpr::resolve_segments (NodeId root_resolved_node_id,
     }
 
   rust_assert (resolved_node_id != UNKNOWN_NODEID);
-  if (flag_name_resolution_2_0)
-    {
-      auto &nr_ctx = const_cast<Resolver2_0::NameResolutionContext &> (
-       Resolver2_0::ImmutableNameResolutionContext::get ().resolver ());
 
-      nr_ctx.map_usage (Resolver2_0::Usage (expr_mappings.get_nodeid ()),
-                       Resolver2_0::Definition (resolved_node_id));
-    }
-  // name scope first
-  else if (resolver->get_name_scope ().decl_was_declared_here (
-            resolved_node_id))
-    {
-      resolver->insert_resolved_name (expr_mappings.get_nodeid (),
-                                     resolved_node_id);
-    }
-  // check the type scope
-  else if (resolver->get_type_scope ().decl_was_declared_here (
-            resolved_node_id))
-    {
-      resolver->insert_resolved_type (expr_mappings.get_nodeid (),
-                                     resolved_node_id);
-    }
-  else
-    {
-      resolver->insert_resolved_misc (expr_mappings.get_nodeid (),
-                                     resolved_node_id);
-    }
+  auto &nr_ctx = const_cast<Resolver2_0::NameResolutionContext &> (
+    Resolver2_0::ImmutableNameResolutionContext::get ().resolver ());
+
+  nr_ctx.map_usage (Resolver2_0::Usage (expr_mappings.get_nodeid ()),
+                   Resolver2_0::Definition (resolved_node_id));
 
   infered = tyseg;
 }
index 13fc9c85cc863d947746526769b696b0e6c5c258..2190faec751881769162221801253360a5a19304 100644 (file)
@@ -22,9 +22,6 @@
 #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 {
 
@@ -54,23 +51,13 @@ TypeCheckPattern::visit (HIR::PathInExpression &pattern)
   NodeId ref_node_id = UNKNOWN_NODEID;
   bool maybe_item = false;
 
-  if (flag_name_resolution_2_0)
-    {
-      auto &nr_ctx
-       = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
+  auto &nr_ctx
+    = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
 
-      if (auto id = nr_ctx.lookup (pattern.get_mappings ().get_nodeid ()))
-       {
-         ref_node_id = *id;
-         maybe_item = true;
-       }
-    }
-  else
+  if (auto id = nr_ctx.lookup (pattern.get_mappings ().get_nodeid ()))
     {
-      maybe_item |= resolver->lookup_resolved_name (
-       pattern.get_mappings ().get_nodeid (), &ref_node_id);
-      maybe_item |= resolver->lookup_resolved_type (
-       pattern.get_mappings ().get_nodeid (), &ref_node_id);
+      ref_node_id = *id;
+      maybe_item = true;
     }
 
   bool path_is_const_item = false;
index 462b3d4876733e02e3b7109404312248118ea97d..21237f58868da19f3a48af69fa873819ccbf0c8f 100644 (file)
@@ -336,19 +336,13 @@ TypeCheckType::resolve_root_path (HIR::TypePath &path, size_t *offset,
          seg->get_lang_item ());
       else
        {
-         // FIXME: HACK: ARTHUR: Remove this
-         if (flag_name_resolution_2_0)
-           {
-             auto &nr_ctx = Resolver2_0::ImmutableNameResolutionContext::get ()
-                              .resolver ();
+         auto &nr_ctx
+           = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
 
-             // assign the ref_node_id if we've found something
-             nr_ctx.lookup (ast_node_id)
-               .map (
-                 [&ref_node_id] (NodeId resolved) { ref_node_id = resolved; });
-           }
-         else if (!resolver->lookup_resolved_name (ast_node_id, &ref_node_id))
-           resolver->lookup_resolved_type (ast_node_id, &ref_node_id);
+         // assign the ref_node_id if we've found something
+         nr_ctx.lookup (ast_node_id).map ([&ref_node_id] (NodeId resolved) {
+           ref_node_id = resolved;
+         });
        }
 
       // ref_node_id is the NodeId that the segments refers to.
@@ -1081,23 +1075,15 @@ ResolveWhereClauseItem::visit (HIR::TypeBoundWhereClauseItem &item)
 
   // then lookup the reference_node_id
   NodeId ref_node_id = UNKNOWN_NODEID;
-  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
-    {
-      NodeId id = UNKNOWN_NODEID;
+  auto &nr_ctx
+    = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
 
-      if (resolver->lookup_resolved_type (ast_node_id, &id))
-       ref_node_id = id;
+  if (auto id = nr_ctx.lookup (ast_node_id))
+    {
+      ref_node_id = *id;
     }
-
-  if (ref_node_id == UNKNOWN_NODEID)
+  else
     {
       // FIXME
       rust_error_at (UNDEF_LOCATION,
index 27879e3d4e9da940320cf3db4a1bcb37689c3d6f..6097c4e5be87a04db6edba95c30ccc03bd65588f 100644 (file)
@@ -26,9 +26,6 @@
 #include "rust-hir-type-check-struct-field.h"
 #include "rust-immutable-name-resolution-context.h"
 
-// for flag_name_resolution_2_0
-#include "options.h"
-
 extern bool saw_errors (void);
 
 namespace Rust {
@@ -275,26 +272,13 @@ TraitItemReference::get_type_from_fn (/*const*/ HIR::TraitItemFunc &fn) const
        TyTy::FnParam (param.get_param_name ().clone_pattern (), param_tyty));
     }
 
-  auto &mappings = Analysis::Mappings::get ();
-
-  tl::optional<CanonicalPath> canonical_path;
-  if (flag_name_resolution_2_0)
-    {
-      auto &nr_ctx
-       = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
-
-      canonical_path
-       = nr_ctx.to_canonical_path (fn.get_mappings ().get_nodeid ());
-    }
-  else
-    {
-      canonical_path
-       = mappings.lookup_canonical_path (fn.get_mappings ().get_nodeid ());
-    }
+  auto &nr_ctx
+    = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
 
-  rust_assert (canonical_path);
+  CanonicalPath canonical_path
+    = nr_ctx.to_canonical_path (fn.get_mappings ().get_nodeid ());
 
-  RustIdent ident{*canonical_path, fn.get_locus ()};
+  RustIdent ident{canonical_path, fn.get_locus ()};
   auto resolved = new TyTy::FnType (
     fn.get_mappings ().get_hirid (), fn.get_mappings ().get_defid (),
     function.get_function_name ().as_string (), ident,
index a549449dcef03c8d250d91c99fe1ac6cbdc6aa41..0f14e0a60082323bdf7b86866a20cea690e73992 100644 (file)
@@ -37,7 +37,6 @@ bool
 query_type (HirId reference, TyTy::BaseType **result)
 {
   auto &mappings = Analysis::Mappings::get ();
-  auto &resolver = *Resolver::get ();
   TypeCheckContext *context = TypeCheckContext::get ();
 
   if (context->lookup_type (reference, result))
@@ -103,18 +102,13 @@ query_type (HirId reference, TyTy::BaseType **result)
          NodeId ref_node_id = UNKNOWN_NODEID;
          NodeId ast_node_id = ty.get_mappings ().get_nodeid ();
 
-         if (flag_name_resolution_2_0)
-           {
-             auto &nr_ctx = Resolver2_0::ImmutableNameResolutionContext::get ()
-                              .resolver ();
+         auto &nr_ctx
+           = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
 
-             // assign the ref_node_id if we've found something
-             nr_ctx.lookup (ast_node_id)
-               .map (
-                 [&ref_node_id] (NodeId resolved) { ref_node_id = resolved; });
-           }
-         else if (!resolver.lookup_resolved_name (ast_node_id, &ref_node_id))
-           resolver.lookup_resolved_type (ast_node_id, &ref_node_id);
+         // assign the ref_node_id if we've found something
+         nr_ctx.lookup (ast_node_id).map ([&ref_node_id] (NodeId resolved) {
+           ref_node_id = resolved;
+         });
 
          if (ref_node_id != UNKNOWN_NODEID)
            {