]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Struct are types, not values
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Wed, 24 Jan 2024 16:10:42 +0000 (17:10 +0100)
committerP-E-P <32375388+P-E-P@users.noreply.github.com>
Tue, 26 Mar 2024 17:35:02 +0000 (17:35 +0000)
We shall search in the right namespace. The correct namespace for struct
is type namespace.

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): Change
search location for struct types.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/typecheck/rust-hir-type-check-item.cc

index 4ab946e1c2a1e2f7b164eb99352b6d3e3f0af434..3e504e5df3221742cfadc07a870d1e27e43c480f 100644 (file)
@@ -279,9 +279,11 @@ TypeCheckItem::visit (HIR::StructStruct &struct_decl)
     {
       auto nr_ctx
        = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
-      auto canonical_path = nr_ctx.values.to_canonical_path (
+      auto canonical_path = nr_ctx.types.to_canonical_path (
        struct_decl.get_mappings ().get_nodeid ());
 
+      if (!canonical_path.has_value ())
+       rust_unreachable ();
       path = canonical_path.value ();
     }
   else