Use enums to clarify DepNodeColorMap color marking #154201
Open
Zalathar wants to merge 2 commits intorust-lang:mainfrom
Open
Use enums to clarify DepNodeColorMap color marking #154201Zalathar wants to merge 2 commits intorust-lang:mainfrom
DepNodeColorMap color marking #154201Zalathar wants to merge 2 commits intorust-lang:mainfrom
Conversation
When a function's documentation has to explain the meaning of nested results and options, then it is often a good candidate for using a custom result enum instead. This commit also renames `DepNodeColorMap::try_mark` to `try_set_color`, to make it more distinct from the similarly-named `DepGraph::try_mark_green`. The difference is that `try_mark_green` is a higher-level operation that tries to determine whether a node _can_ be marked green, whereas `try_set_color` is a lower-level operation that actually records a color for the node.
This method is only used to initialize the always-red node, which can be done with `try_set_color` instead.
nnethercote
approved these changes
Mar 22, 2026
| } | ||
| } | ||
|
|
||
| /// The color that [`DepNodeColorMap::try_set_color`] should try to apply to a node. |
Contributor
There was a problem hiding this comment.
FWIW, I find these comments saying which functions use a type to be not that useful, and prone to getting out of date. The comments on the variants themselves are much more useful.
Contributor
|
@bors r+ rollup |
Contributor
Zalathar
added a commit
to Zalathar/rust
that referenced
this pull request
Mar 22, 2026
Use enums to clarify `DepNodeColorMap` color marking When a function's documentation has to explain the meaning of nested results and options, then it is often a good candidate for using a custom result enum instead. This PR also renames `DepNodeColorMap::try_mark` to `try_set_color`, to make it more distinct from the similarly-named `DepGraph::try_mark_green`. The difference is that `try_mark_green` is a higher-level operation that tries to determine whether a node _can_ be marked green, whereas `try_set_color` is a lower-level operation that actually records a colour for the node. The updated docs for `try_set_color` also fix a typo: *atomicaly* → *atomically*. r? nnethercote (or compiler)
rust-bors bot
pushed a commit
that referenced
this pull request
Mar 22, 2026
Rollup of 7 pull requests Successful merges: - #122668 (Add APIs for dealing with titlecase) - #153312 (Packages as namespaces part 1) - #153534 (Remove a flaky `got_timeout` assert from two channel tests) - #154175 (Add new alias for Guillaume Gomez email address) - #154182 (diagnostics: avoid ICE for undeclared generic parameter in impl) - #154188 (Update the tracking issue for #[diagnostic::on_move]) - #154201 (Use enums to clarify `DepNodeColorMap` color marking )
Zalathar
added a commit
to Zalathar/rust
that referenced
this pull request
Mar 22, 2026
Use enums to clarify `DepNodeColorMap` color marking When a function's documentation has to explain the meaning of nested results and options, then it is often a good candidate for using a custom result enum instead. This PR also renames `DepNodeColorMap::try_mark` to `try_set_color`, to make it more distinct from the similarly-named `DepGraph::try_mark_green`. The difference is that `try_mark_green` is a higher-level operation that tries to determine whether a node _can_ be marked green, whereas `try_set_color` is a lower-level operation that actually records a colour for the node. The updated docs for `try_set_color` also fix a typo: *atomicaly* → *atomically*. r? nnethercote (or compiler)
rust-bors bot
pushed a commit
that referenced
this pull request
Mar 22, 2026
Rollup of 9 pull requests Successful merges: - #122668 (Add APIs for dealing with titlecase) - #153312 (Packages as namespaces part 1) - #153534 (Remove a flaky `got_timeout` assert from two channel tests) - #153582 (Simplify find_attr! for HirId usage) - #154174 (allow `incomplete_features` in most UI tests) - #154175 (Add new alias for Guillaume Gomez email address) - #154182 (diagnostics: avoid ICE for undeclared generic parameter in impl) - #154188 (Update the tracking issue for #[diagnostic::on_move]) - #154201 (Use enums to clarify `DepNodeColorMap` color marking )
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Mar 22, 2026
Use enums to clarify `DepNodeColorMap` color marking When a function's documentation has to explain the meaning of nested results and options, then it is often a good candidate for using a custom result enum instead. This PR also renames `DepNodeColorMap::try_mark` to `try_set_color`, to make it more distinct from the similarly-named `DepGraph::try_mark_green`. The difference is that `try_mark_green` is a higher-level operation that tries to determine whether a node _can_ be marked green, whereas `try_set_color` is a lower-level operation that actually records a colour for the node. The updated docs for `try_set_color` also fix a typo: *atomicaly* → *atomically*. r? nnethercote (or compiler)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When a function's documentation has to explain the meaning of nested results and options, then it is often a good candidate for using a custom result enum instead.
This PR also renames
DepNodeColorMap::try_marktotry_set_color, to make it more distinct from the similarly-namedDepGraph::try_mark_green.The difference is that
try_mark_greenis a higher-level operation that tries to determine whether a node can be marked green, whereastry_set_coloris a lower-level operation that actually records a colour for the node.The updated docs for
try_set_coloralso fix a typo: atomicaly → atomically.r? nnethercote (or compiler)