Skip to content

nr2.0: Separate out canonical path handling #3776

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

powerboat9
Copy link
Collaborator

@powerboat9 powerboat9 commented May 5, 2025

Depends on a few other PRs

@powerboat9 powerboat9 force-pushed the fix-can branch 4 times, most recently from 326ac5d to 1156370 Compare May 7, 2025 22:26
@powerboat9
Copy link
Collaborator Author

powerboat9 commented May 7, 2025

Now only depends on #3768

@powerboat9 powerboat9 requested review from P-E-P, CohenArthur and philberty and removed request for P-E-P May 7, 2025 22:42
This should improve our canonical path handling, without requiring
further tweaks to ForeverStack. This may also help if, in the future, we
have to move canonical path calculation to later compilation phases for
proper handling of generics.

gcc/rust/ChangeLog:

	* backend/rust-compile-base.cc
	(HIRCompileBase::compile_function): Since canonical paths
	returned from nr2.0 now include the crate name, avoid prepending
	the crate name again.

	* backend/rust-compile-implitem.cc
	(CompileTraitItem::visit): Use
	NameResolutionContext::to_canonical_path instead of
	ForeverStack::to_canonical_path.
	* backend/rust-compile-item.cc
	(CompileItem::visit): Likewise.
	* typecheck/rust-hir-type-check-enumitem.cc
	(TypeCheckEnumItem::visit): Likewise.
	* typecheck/rust-hir-type-check-implitem.cc
	(TypeCheckImplItem::visit): Likewise.
	* typecheck/rust-hir-type-check-item.cc
	(TypeCheckItem::visit): Likewise.
	* typecheck/rust-hir-type-check.cc
	(TraitItemReference::get_type_from_fn): Likewise.

	* resolve/rust-default-resolver.cc
	(DefaultResolver::visit): Add Crate and EnumItem instance
	visitors, handle canonical path context scoping.
	* resolve/rust-default-resolver.h
	(DefaultResolver::visit): Add Crate and EnumItem instance
	visitors.
	* resolve/rust-early-name-resolver-2.0.cc
	(Early::go): Visit instances of Crate using the virtual member
	function visit.
	* resolve/rust-forever-stack.h
	(ForeverStack::to_canonical_path): Remove function declaration.
	* resolve/rust-forever-stack.hxx
	(ForeverStack::to_canonical_path): Remove function definition.
	* resolve/rust-late-name-resolver-2.0.cc
	(Late::go): Visit instances of Crate using the virtual member
	function visit.
	* resolve/rust-name-resolution-context.cc
	(CanonicalPathRecordRoot::as_path): New function definition.
	(CanonicalPathRecordNormal::as_path): Likewise.
	(CanonicalPathRecordLookup::as_path): Likewise.
	(CanonicalPathRecordImpl::as_path): Likewise.
	(CanonicalPathRecordTraitImpl::as_path): Likewise.
	(NameResolutionContext::NameResolutionContext): Initialize
	member variable canonical_ctx.
	* resolve/rust-name-resolution-context.h: Include "rust-item.h".
	(class NameResolutionContext): Forward declare class.
	(class CanonicalPathRecord): New class.
	(class CanonicalPathRecordWithParent): Likewise.
	(class CanonicalPathRecordRoot): Likewise.
	(class CanonicalPathRecordNormal): Likewise.
	(class CanonicalPathRecordLookup): Likewise.
	(class CanonicalPathRecordImpl): Likewise.
	(class CanonicalPathRecordTraitImpl): Likewise.
	(class CanonicalPathCtx): Likewise.
	(NameResolutionContext::canonical_ctx): New member variable.
	(NameResolutionContext::to_canonical_path): New member function.
	* resolve/rust-toplevel-name-resolver-2.0.cc
	(TopLevel::go): Visit instances of Crate with the virtual member
	function visit.
	(TopLevel::visit): Handle canonical path context scoping for
	external crates, use DefaultResolver::visit when visiting
	instances of StructStruct.
	* util/rust-canonical-path.h
	(CanonicalPath::new_seg): Take path parameter by-value, as a
	duplicate instance will be constructed regardless.

gcc/testsuite/ChangeLog:

	* rust/compile/nr2/exclude: Remove canonical_paths1.rs.
@powerboat9 powerboat9 marked this pull request as ready for review May 8, 2025 17:52
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.

1 participant