aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/resolve/rust-late-name-resolver-2.0.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/rust/resolve/rust-late-name-resolver-2.0.cc')
-rw-r--r--gcc/rust/resolve/rust-late-name-resolver-2.0.cc31
1 files changed, 11 insertions, 20 deletions
diff --git a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc
index 0b591730..c134ca0 100644
--- a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc
@@ -294,29 +294,20 @@ Late::visit (AST::TypePath &type)
// maybe we can overload `resolve_path<Namespace::Types>` to only do
// typepath-like path resolution? that sounds good
- if (type.get_segments ().size () != 1)
- {
- rust_sorry_at (
- type.get_locus (),
- "name resolution 2.0 cannot resolve multi-segment type paths");
- return;
- }
+ // take care of only simple cases
+ // TODO: remove this?
+ rust_assert (!type.has_opening_scope_resolution_op ());
- auto str = type.get_segments ().back ()->get_ident_segment ().as_string ();
- auto values = ctx.types.peek ().get_values ();
+ // this *should* mostly work
+ // TODO: make sure typepath-like path resolution (?) is working
+ auto resolved = ctx.resolve_path (type.get_segments (), Namespace::Types);
- if (auto resolved = ctx.types.get (str))
- {
- ctx.map_usage (Usage (type.get_node_id ()),
- Definition (resolved->get_node_id ()));
- ctx.map_usage (Usage (type.get_segments ().back ()->get_node_id ()),
- Definition (resolved->get_node_id ()));
- }
+ if (resolved.has_value ())
+ ctx.map_usage (Usage (type.get_node_id ()),
+ Definition (resolved->get_node_id ()));
else
- {
- rust_error_at (type.get_locus (), "could not resolve type path %qs",
- str.c_str ());
- }
+ rust_error_at (type.get_locus (), "could not resolve type path %qs",
+ type.as_string ().c_str ());
DefaultResolver::visit (type);
}