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

RedundantBraces: keep around do-while within for #4356

Merged
merged 2 commits into from
Sep 28, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,15 @@ class RedundantBraces(implicit val ftoks: FormatTokens)
case p: Term.Match => p.expr eq b
case p: Type.Match => p.tpe eq b

case p: Term.ForClause if p.body eq b =>
@tailrec
def iter(t: Tree): Boolean = t match {
case _: Term.Do => true
case Term.Block(x :: Nil) => iter(x)
case _ => false
}
iter(stat)

case parent => SyntacticGroupOps.groupNeedsParenthesis(
TreeSyntacticGroup(parent),
TreeSyntacticGroup(stat),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2061,3 +2061,41 @@ hostLocalDirManager =
Utils.isPushBasedShuffleEnabled(conf, isDriver)
)
None
<<< #4133 do-while within for
rewrite.redundantBraces.maxLines = 100
===
for (taskSet <- sortedTaskSets; maxLocality <- taskSet.myLocalityLevels) {
do {
launchedTask = resourceOfferSingleTaskSet(
taskSet, maxLocality, shuffledOffers, availableCpus, tasks)
} while (launchedTask)
}
>>>
for (taskSet <- sortedTaskSets; maxLocality <- taskSet.myLocalityLevels) {
do launchedTask = resourceOfferSingleTaskSet(
taskSet,
maxLocality,
shuffledOffers,
availableCpus,
tasks
) while (launchedTask)
}
<<< #4133 do-while within for, extra block
rewrite.redundantBraces.maxLines = 100
===
for (taskSet <- sortedTaskSets; maxLocality <- taskSet.myLocalityLevels) {{
do {
launchedTask = resourceOfferSingleTaskSet(
taskSet, maxLocality, shuffledOffers, availableCpus, tasks)
} while (launchedTask)
}}
>>>
for (taskSet <- sortedTaskSets; maxLocality <- taskSet.myLocalityLevels) {
do launchedTask = resourceOfferSingleTaskSet(
taskSet,
maxLocality,
shuffledOffers,
availableCpus,
tasks
) while (launchedTask)
}
Loading