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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions gcc/rust/rust-session-manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -619,10 +619,6 @@ Session::compile_crate (const char *filename)

expansion (parsed_crate, name_resolution_ctx);

AST::DesugarForLoops ().go (parsed_crate);
AST::DesugarQuestionMark ().go (parsed_crate);
AST::DesugarApit ().go (parsed_crate);

rust_debug ("\033[0;31mSUCCESSFULLY FINISHED EXPANSION \033[0m");
if (options.dump_option_enabled (CompileOptions::EXPANSION_DUMP))
{
Expand Down Expand Up @@ -986,6 +982,20 @@ Session::expansion (AST::Crate &crate, Resolver2_0::NameResolutionContext &ctx)
rust_error_at (range, "reached recursion limit");
}

// handle AST desugaring
if (!saw_errors ())
{
AST::DesugarForLoops ().go (crate);
AST::DesugarQuestionMark ().go (crate);
AST::DesugarApit ().go (crate);

// HACK: we may need a final TopLevel pass
// however, this should not count towards the recursion limit
// and we don't need a full Early pass
if (flag_name_resolution_2_0)
Resolver2_0::TopLevel (ctx).go (crate);
}

// error reporting - check unused macros, get missing fragment specifiers

// build test harness
Expand Down
4 changes: 0 additions & 4 deletions gcc/testsuite/rust/compile/nr2/exclude
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
issue-3315-2.rs
torture/alt_patterns1.rs
issue-1487.rs
issue-2015.rs
issue-3454.rs
impl_trait_generic_arg.rs
# please don't delete the trailing newline