]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: toplevel: Add note for resolving use declarations
authorArthur Cohen <arthur.cohen@embecosm.com>
Wed, 3 Apr 2024 15:41:47 +0000 (17:41 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Wed, 19 Mar 2025 14:32:12 +0000 (15:32 +0100)
gcc/rust/ChangeLog:

* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::handle_use_dec):
Add notes on the problem.
* resolve/rust-toplevel-name-resolver-2.0.h: Likewise.

gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
gcc/rust/resolve/rust-toplevel-name-resolver-2.0.h

index 746b2240d4b7a84331b730b2ffcc8f3270eba981..b18b86ca8218a22fe46bf546eaff7cba8d59013a 100644 (file)
@@ -452,6 +452,13 @@ TopLevel::handle_use_dec (AST::SimplePath &path)
   auto locus = path.get_final_segment ().get_locus ();
   auto declared_name = path.get_final_segment ().as_string ();
 
+  // In that function, we only need to declare a new definition - the use path.
+  // the resolution needs to happpen in the EarlyNameResolver. So the
+  // definitions we'll add will be the path's NodeId - that makes sense, as we
+  // need one definition per path declared in a Use tree. so all good.
+  // alright, now in what namespace do we declare them? all of them? do we only
+  // declare them in the EarlyNameResolver? this is dodgy
+
   // in what namespace do we perform path resolution? All of them? see which one
   // matches? Error out on ambiguities?
   // so, apparently, for each one that matches, add it to the proper namespace
@@ -464,6 +471,10 @@ TopLevel::handle_use_dec (AST::SimplePath &path)
                                             const AST::SimplePath &path) {
        tl::optional<Rib::Definition> resolved = tl::nullopt;
 
+       insert_or_error_out (declared_name, locus, path.get_node_id (), ns);
+       // what do we do here with the full simplepath? do we add it to an extra
+       // map?
+
        // FIXME: resolve_path needs to return an `expected<NodeId, Error>` so
        // that we can improve it with hints or location or w/ever. and maybe
        // only emit it the first time.
index 095037042658b52732a8bdaef4eedc6d7f0b838f..affddb97d50c1f3debba9dab50c993d40872e7eb 100644 (file)
@@ -84,7 +84,7 @@ private:
   std::unordered_map<NodeId, location_t> node_locations;
 
   // Store node forwarding for use declaration, the link between a
-  // "new" local name and its definition.
+  // definition and its new local name.
   std::unordered_map<NodeId, NodeId> node_forwarding;
 
   void visit (AST::Module &module) override;