[gccrs COMMIT] gccrs: Only the last segment should resolve to an expr item

gerris.rs@gmail.com gerris.rs@gmail.com
Fri Sep 11 08:47:34 GMT 2026


From: Philip Herron <herron.philip@googlemail.com>

This doesnt fix that linked issue but its part of the fix thats needed.

Addresses Rust-GCC/gccrs#4865

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::resolve_segments):
	use probe expr on last seg

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
---
This change was merged into the gccrs repository and is posted here for
upstream visibility and potential drive-by review, as requested by GCC
release managers.
Each commit email contains a link to its details on github from where you can
find the Pull-Request and associated discussions.


Commit on github: https://github.com/Rust-GCC/gccrs/commit/c50c70727027e2c88b74caf54b260690ea515b34

The commit has been mentioned in the following issue(s):
 - Rust-GCC/gccrs#4865: https://github.com/Rust-GCC/gccrs/issues/4865

The commit has been mentioned in the following pull-request(s):
 - https://github.com/Rust-GCC/gccrs/pull/4882

 gcc/rust/typecheck/rust-hir-type-check-path.cc | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/gcc/rust/typecheck/rust-hir-type-check-path.cc b/gcc/rust/typecheck/rust-hir-type-check-path.cc
index 2e1731ac1..27d7d55e5 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-path.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-path.cc
@@ -26,10 +26,10 @@
 #include "rust-rib.h"
 #include "rust-substitution-mapper.h"
 #include "rust-hir-path-probe-expr.h"
+#include "rust-hir-path-probe-type.h"
 #include "rust-type-util.h"
 #include "rust-hir-type-bounds.h"
 #include "rust-hir-item.h"
-#include "rust-session-manager.h"
 #include "rust-finalized-name-resolution-context.h"
 
 namespace Rust {
@@ -417,8 +417,19 @@ TypeCheckExpr::resolve_segments (NodeId root_resolved_node_id,
 
   for (size_t i = offset; i < segments.size (); i++)
     {
+      bool last_seg = i == segments.size () - 1;
       HIR::PathExprSegment &seg = segments.at (i);
-      auto candidates = PathProbeExpr::Probe (prev_segment, seg.get_segment ());
+
+      std::set<PathProbeCandidate> candidates;
+      if (last_seg)
+	candidates = PathProbeExpr::Probe (tyseg, seg.get_segment ());
+      else
+	{
+	  auto type_candidates
+	    = TypePathProbe::Probe (tyseg, seg.get_segment ());
+	  candidates = type_candidates.type_candidates;
+	}
+
       if (candidates.size () == 0)
 	{
 	  rust_error_at (seg.get_locus (),

base-commit: add37b32daa982f65dc56852ce0a562c54e27950
-- 
2.55.0



More information about the Gcc-rust mailing list