[core] Documentation and cleanups for LifetimeTracker
#5674
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Use a
for
loop inLifetimeTracker
triage code.A
for
loop is less noisy here than adrain
, which requires:a
mut
qualifier for a variable whose modified value we neverconsult
a method name appearing mid-line instead of a control structure name
at the front of the line
a range which is always
..
, establishing no restriction at alla closure instead of a block
Structured control flow syntax has a fine pedigree, originating in,
among other places, Dijkstrsa's efforts at designing languages in a
way that made it easier to formally verify programs written in
them (see "A Discipline Of Programming"). There is nothing "more
mathematical" about a method call that takes a closure than a
for
loop. Since
for_each
is useless unless the closure has side effects,there's nothing "more functional" about
for_each
here, either.Obsessive use of
for_each
suggests that the author loves Haskellwithout understanding it.
In
LifetimeTracker
s triage code, use more specific names.Rename
LifetimeTracker::triage_resources
'sresources_map
argumentto
suspected_resources
, since this always points to a field ofLifetimeTracker::suspected_resources
.In the various
triage_suspected_foo
functions, name the mapsuspected_foos
.Refactor
LifetimeTracker::triage_resources
.Check whether the resource is abandoned first, since none of the rest
of the work is necessary otherwise.
Rename
non_referenced_resources
tolast_resources
. This functioncopes with various senses in which the resource might be referenced or
not. Instead,
last_resources
is the name of theActiveSubmission
member this may point to, which is more specific.
Move the use of
last_resources
immediately after its production.Doc fixes for lifetime management, minor typos.
Document
LifetimeTracker::triage_resources
.Fix various typos and bad grammar.