Skip to content

Resolve non-final path segments in type namespace#4525

Open
powerboat9 wants to merge 1 commit intoRust-GCC:masterfrom
powerboat9:use-path-type-ns
Open

Resolve non-final path segments in type namespace#4525
powerboat9 wants to merge 1 commit intoRust-GCC:masterfrom
powerboat9:use-path-type-ns

Conversation

@powerboat9
Copy link
Copy Markdown
Collaborator

This is very hack-y, and the ForeverStack/NameResolutionContext boundary is due for some major refactoring, but should be correct. Credit to @CohenArthur for mentioning the idea in DMs

so I did a quick and dirty implementation where ForeverStack::resolve_path now takes an extra parameter, a ForeverStackNamespace::Types &types_stack, and does resolve_segments within the types NS before resolving the last segment.

This is very hack-y, and the ForeverStack/NameResolutionContext boundary
is due for some major refactoring, but should be correct.

gcc/rust/ChangeLog:

	* resolve/rust-forever-stack.h (class ForeverStack): Friend
	other ForeverStack specializations.
	(ForeverStack::resolve_path): Add parameter for type namespace
	ForeverStack instance.
	(ForeverStack::resolve_segments): Likewise.
	* resolve/rust-forever-stack.hxx
	(ForeverStack::resolve_segments): Specialize for different
	namespaces.
	(ForeverStack::resolve_path): Pass a type namespace ForeverStack
	instance to resolve_segments.
	* resolve/rust-name-resolution-context.h
	(NameResolutionContext::resolve_path): Pass a type namespace
	ForeverStack instance to ForeverStack::resolve_path.

gcc/testsuite/ChangeLog:

	* rust/compile/name_resolution27.rs: New test.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
@powerboat9 powerboat9 requested a review from CohenArthur April 15, 2026 03:55
@CohenArthur
Copy link
Copy Markdown
Member

Hey @powerboat9 sorry for the confusion, I actually have a branch with these changes which I think is less hacky. We ended up working on the same thing in parallel. I didn't think you would work on this as well, my apologies.

I'll submit my branch this weekend and we can see which approach we like best. Apologies :(

@powerboat9
Copy link
Copy Markdown
Collaborator Author

No worries, I figured you had probably been working on something similar, though I wasn't sure how far along you had gotten with it, or if you had abandoned it for being too hack-y.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants