Skip to content

Commit 7c0ea5e

Browse files
committed
stash
1 parent 96ed310 commit 7c0ea5e

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

gcc/rust/rust-session-manager.cc

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,9 @@ Session::expansion (AST::Crate &crate, Resolver2_0::NameResolutionContext &ctx)
936936
MacroExpander expander (crate, cfg, *this);
937937
std::vector<Error> macro_errors;
938938

939-
while (!fixed_point_reached && iterations < cfg.recursion_limit)
939+
bool did_desugar = false;
940+
941+
while (!fixed_point_reached)
940942
{
941943
CfgStrip ().go (crate);
942944
// Errors might happen during cfg strip pass
@@ -958,8 +960,22 @@ Session::expansion (AST::Crate &crate, Resolver2_0::NameResolutionContext &ctx)
958960
ExpandVisitor (expander).go (crate);
959961

960962
fixed_point_reached = !expander.has_changed () && !visitor_dirty;
963+
964+
if (fixed_point_reached && macro_errors.is_empty () && !did_desugar)
965+
{
966+
AST::DesugarForLoops ().go (crate);
967+
AST::DesugarQuestionMark ().go (crate);
968+
AST::DesugarApit ().go (crate);
969+
970+
fixed_point_reached = false;
971+
did_desugar = true;
972+
}
973+
else
974+
{
975+
fixed_point_reached |= (++iterations == cfg.recursion_limit);
976+
}
977+
961978
expander.reset_changed_state ();
962-
iterations++;
963979

964980
if (saw_errors ())
965981
break;
@@ -982,20 +998,6 @@ Session::expansion (AST::Crate &crate, Resolver2_0::NameResolutionContext &ctx)
982998
rust_error_at (range, "reached recursion limit");
983999
}
9841000

985-
// handle AST desugaring
986-
if (!saw_errors ())
987-
{
988-
AST::DesugarForLoops ().go (crate);
989-
AST::DesugarQuestionMark ().go (crate);
990-
AST::DesugarApit ().go (crate);
991-
992-
// HACK: we may need a final TopLevel pass
993-
// however, this should not count towards the recursion limit
994-
// and we don't need a full Early pass
995-
if (flag_name_resolution_2_0)
996-
Resolver2_0::TopLevel (ctx).go (crate);
997-
}
998-
9991001
// error reporting - check unused macros, get missing fragment specifiers
10001002

10011003
// build test harness

0 commit comments

Comments
 (0)