diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-04-08 18:44:15 +0200 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-19 15:32:13 +0100 |
commit | 3118129c0c96a87f187b319c65b819b71e633f2f (patch) | |
tree | b08e9d67742704d158de5ea07b28e93ae8c8eafe /gcc/rust/resolve/rust-finalize-imports-2.0.cc | |
parent | 924446743f6e21efa745ec1b051e9f37887e32f9 (diff) | |
download | gcc-3118129c0c96a87f187b319c65b819b71e633f2f.zip gcc-3118129c0c96a87f187b319c65b819b71e633f2f.tar.gz gcc-3118129c0c96a87f187b319c65b819b71e633f2f.tar.bz2 |
gccrs: Insert imports in all namespaces they were resolved in
gcc/rust/ChangeLog:
* resolve/rust-early-name-resolver-2.0.cc (Early::resolve_simple_import):
Insert import in all namespaces where they were resolved.
(Early::resolve_rebind_import): Likewise.
* resolve/rust-early-name-resolver-2.0.h: Improve APIs, make them
accept multiple resolutions.
* resolve/rust-finalize-imports-2.0.cc: Handle multiple resolutions.
* resolve/rust-name-resolution-context.h (resolve_path): Remove function.
Diffstat (limited to 'gcc/rust/resolve/rust-finalize-imports-2.0.cc')
-rw-r--r-- | gcc/rust/resolve/rust-finalize-imports-2.0.cc | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/gcc/rust/resolve/rust-finalize-imports-2.0.cc b/gcc/rust/resolve/rust-finalize-imports-2.0.cc index ac288e3..52bbcaa 100644 --- a/gcc/rust/resolve/rust-finalize-imports-2.0.cc +++ b/gcc/rust/resolve/rust-finalize-imports-2.0.cc @@ -137,10 +137,10 @@ finalize_simple_import ( auto identifier = mapping.first.to_resolve.get_final_segment ().get_segment_name (); - // FIXME: Fix the namespace in which we insert the new definition - toplevel.insert_or_error_out (identifier, locus, - data.definition.get_node_id (), - data.ns.value ()); + for (auto &&definition : data.definitions ()) + toplevel + .insert_or_error_out ( + identifier, locus, definition.first.get_node_id (), definition.second /* TODO: This isn't clear - it would be better if it was called .ns or something */); } void @@ -149,7 +149,7 @@ finalize_glob_import ( const std::pair<TopLevel::ImportKind, Early::ImportData> &mapping) { auto module = Analysis::Mappings::get ().lookup_ast_module ( - mapping.second.definition.get_node_id ()); + mapping.second.module ().get_node_id ()); rust_assert (module); GlobbingVisitor glob_visitor (ctx); @@ -186,10 +186,9 @@ finalize_rebind_import ( break; } - // FIXME: Fix the namespace in which we insert the new definition - toplevel.insert_or_error_out (declared_name, locus, - data.definition.get_node_id (), - data.ns.value ()); + for (auto &&definition : data.definitions ()) + toplevel.insert_or_error_out ( + declared_name, locus, definition.first.get_node_id (), definition.second /* TODO: This isn't clear - it would be better if it was called .ns or something */); } FinalizeImports::FinalizeImports ( |