Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nr2.0: Resolve paths which start with Self #3416

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

powerboat9
Copy link
Collaborator

Overlaps with #3391 (apologies to @P-E-P, but this should be a more general resolution), depends on #3220

@P-E-P
Copy link
Member

P-E-P commented Feb 4, 2025

Overlaps with #3391 (apologies to @P-E-P, but this should be a more general resolution), depends on #3220

I'm kinda glad you came up with another solution because mine felt wrong and I was even thinking about starting it from scratch again.

gcc/rust/ChangeLog:

	* util/rust-unwrap-segment.cc: New file.
	* util/rust-unwrap-segment.h: New file.
	* Make-lang.in: Add rust-unwrap-segment.o to the object list.
	* resolve/rust-forever-stack.hxx: Include rust-unwrap-segment.h.
	(ForeverStack::find_starting_point): Use unwrap_type_segment.
	(ForeverStack::resolve_segments): Likewise.
	(ForeverStack::resolve_path): Likewise.
	* resolve/rust-late-name-resolver-2.0.cc
	(Late::visit): Resolve type paths using
	NameResolutionContext::resolve_path.
	* resolve/rust-name-resolution-context.h
	(NameResolutionContext::resolve_path): Use
	unwrap_segment_node_id.

gcc/testsuite/ChangeLog:

	* rust/compile/nr2/exclude: Remove entries.

Signed-off-by: Owen Avery <[email protected]>
gcc/rust/ChangeLog:

	* resolve/rust-forever-stack.hxx
	(ForeverStack::find_starting_point): Be more careful about
	applying ForeverStack::find_closest_module.
	(ForeverStack::resolve_segments): Allow traversal into parent
	nodes when not in a module node or root node, which
	ForeverStack::find_starting_point previously made moot through
	use of ForeverStack::find_closest_module. Also, when a child
	node lookup fails when resolving in the type namespace, attempt
	a rib lookup as a fallback.
	* resolve/rust-late-name-resolver-2.0.cc
	(Late::visit): Avoid throwing a resolution error for type paths
	when the typechecker may be able to finish the resolution. Also,
	throw an error when a resolution is ambiguous.

gcc/testsuite/ChangeLog:

	* rust/compile/nr2/exclude: Remove entries.

Signed-off-by: Owen Avery <[email protected]>
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