Skip to content

nr2.0: Run a final TopLevel pass after desugaring #3801

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

No description provided.

@@ -622,6 +622,14 @@ Session::compile_crate (const char *filename)
AST::DesugarQuestionMark ().go (parsed_crate);
AST::DesugarApit ().go (parsed_crate);

// HACK: run a final toplevel pass
// since desugaring may have added definitions
if (!saw_errors () && flag_name_resolution_2_0)
Copy link
Member

@P-E-P P-E-P May 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we also run early nr again since some of those definitions could technically be matched to some invocations ?

If we could make macro fixed point more generic that would allow us to avoid this weird top level nr call.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking we'd be done with early resolution before the desugaring and would only need to run TopLevel for the benefit of Late resolution.

@CohenArthur
Copy link
Member

I don't know if this is the best way to go about this, it's definitely hacky. maybe we could do all the desugars as part of the fixed point and mark the visitor as dirty when we find something to desugar

This fixes some issues with name resolution 2.0.

gcc/rust/ChangeLog:

	* rust-session-manager.cc (Session::compile_crate): Move
	AST desugaring to...
	(Session::expansion): ...here and add a final TopLevel pass
	afterwards.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
@powerboat9
Copy link
Collaborator Author

I don't know if this is the best way to go about this, it's definitely hacky. maybe we could do all the desugars as part of the fixed point and mark the visitor as dirty when we find something to desugar

It looks like doing exactly that would screw up recursion_limit tracking -- I've reworked the patch to put desugaring + the final TopLevel pass in the fixed point loop though, which seems a bit less hacky.

@powerboat9 powerboat9 requested review from P-E-P and CohenArthur May 24, 2025 19:01
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.

3 participants