Skip to content

Use enums to clarify DepNodeColorMap color marking #154201

Merged
rust-bors[bot] merged 2 commits intorust-lang:mainfrom
Zalathar:try-set-color
Mar 23, 2026
Merged

Use enums to clarify DepNodeColorMap color marking #154201
rust-bors[bot] merged 2 commits intorust-lang:mainfrom
Zalathar:try-set-color

Conversation

@Zalathar
Copy link
Member

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: atomicalyatomically.

r? nnethercote (or compiler)

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.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 22, 2026
}
}

/// The color that [`DepNodeColorMap::try_set_color`] should try to apply to a node.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@nnethercote
Copy link
Contributor

@bors r+ rollup

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 22, 2026

📌 Commit 1fec51c has been approved by nnethercote

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 22, 2026
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)
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)
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)
rust-bors bot pushed a commit that referenced this pull request Mar 23, 2026
…uwer

Rollup of 22 pull requests

Successful merges:

 - #122668 (Add APIs for dealing with titlecase)
 - #152543 (privacy: Fix type privacy holes in RPITITs)
 - #153107 (Optimize BTreeMap::append() using CursorMut)
 - #153312 (Packages as namespaces part 1)
 - #153534 (Remove a flaky `got_timeout` assert from two channel tests)
 - #153718 (Fix environ on FreeBSD with cdylib targets that use -Wl,--no-undefined .)
 - #153857 (Rename `target.abi` to `target.cfg_abi` and enum-ify llvm_abiname)
 - #153880 (Lifted intersperse and intersperse_with Fused transformation and updated documentation + tests)
 - #153931 (remove usages of to-be-deprecated numeric constants)
 - #150630 (Unknown -> Unsupported compression algorithm)
 - #153491 (Move `freeze_*` methods to `OpenOptionsExt2`)
 - #153582 (Simplify find_attr! for HirId usage)
 - #153623 (std: move `sys::pal::os` to `sys::paths`)
 - #153647 (docs(fs): Clarify That File::lock Coordinates Across Processes)
 - #153936 (Skip stack_start_aligned for immediate-abort)
 - #154011 (implement `BinaryHeap::as_mut_slice`)
 - #154167 (ui/lto: move and rename two tests from issues/)
 - #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 )
rust-bors bot pushed a commit that referenced this pull request Mar 23, 2026
…uwer

Rollup of 22 pull requests

Successful merges:

 - #122668 (Add APIs for dealing with titlecase)
 - #152543 (privacy: Fix type privacy holes in RPITITs)
 - #153107 (Optimize BTreeMap::append() using CursorMut)
 - #153312 (Packages as namespaces part 1)
 - #153534 (Remove a flaky `got_timeout` assert from two channel tests)
 - #153718 (Fix environ on FreeBSD with cdylib targets that use -Wl,--no-undefined .)
 - #153857 (Rename `target.abi` to `target.cfg_abi` and enum-ify llvm_abiname)
 - #153880 (Lifted intersperse and intersperse_with Fused transformation and updated documentation + tests)
 - #153931 (remove usages of to-be-deprecated numeric constants)
 - #150630 (Unknown -> Unsupported compression algorithm)
 - #153491 (Move `freeze_*` methods to `OpenOptionsExt2`)
 - #153582 (Simplify find_attr! for HirId usage)
 - #153623 (std: move `sys::pal::os` to `sys::paths`)
 - #153647 (docs(fs): Clarify That File::lock Coordinates Across Processes)
 - #153936 (Skip stack_start_aligned for immediate-abort)
 - #154011 (implement `BinaryHeap::as_mut_slice`)
 - #154167 (ui/lto: move and rename two tests from issues/)
 - #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 )
rust-bors bot pushed a commit that referenced this pull request Mar 23, 2026
…uwer

Rollup of 21 pull requests

Successful merges:

 - #152543 (privacy: Fix type privacy holes in RPITITs)
 - #153107 (Optimize BTreeMap::append() using CursorMut)
 - #153312 (Packages as namespaces part 1)
 - #153534 (Remove a flaky `got_timeout` assert from two channel tests)
 - #153718 (Fix environ on FreeBSD with cdylib targets that use -Wl,--no-undefined .)
 - #153857 (Rename `target.abi` to `target.cfg_abi` and enum-ify llvm_abiname)
 - #153880 (Lifted intersperse and intersperse_with Fused transformation and updated documentation + tests)
 - #153931 (remove usages of to-be-deprecated numeric constants)
 - #150630 (Unknown -> Unsupported compression algorithm)
 - #153491 (Move `freeze_*` methods to `OpenOptionsExt2`)
 - #153582 (Simplify find_attr! for HirId usage)
 - #153623 (std: move `sys::pal::os` to `sys::paths`)
 - #153647 (docs(fs): Clarify That File::lock Coordinates Across Processes)
 - #153936 (Skip stack_start_aligned for immediate-abort)
 - #154011 (implement `BinaryHeap::as_mut_slice`)
 - #154167 (ui/lto: move and rename two tests from issues/)
 - #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 )
@rust-bors rust-bors bot merged commit baffc5e into rust-lang:main Mar 23, 2026
11 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Mar 23, 2026
@Zalathar Zalathar deleted the try-set-color branch March 23, 2026 23:08
github-actions bot pushed a commit to rust-lang/stdarch that referenced this pull request Mar 26, 2026
…uwer

Rollup of 21 pull requests

Successful merges:

 - rust-lang/rust#152543 (privacy: Fix type privacy holes in RPITITs)
 - rust-lang/rust#153107 (Optimize BTreeMap::append() using CursorMut)
 - rust-lang/rust#153312 (Packages as namespaces part 1)
 - rust-lang/rust#153534 (Remove a flaky `got_timeout` assert from two channel tests)
 - rust-lang/rust#153718 (Fix environ on FreeBSD with cdylib targets that use -Wl,--no-undefined .)
 - rust-lang/rust#153857 (Rename `target.abi` to `target.cfg_abi` and enum-ify llvm_abiname)
 - rust-lang/rust#153880 (Lifted intersperse and intersperse_with Fused transformation and updated documentation + tests)
 - rust-lang/rust#153931 (remove usages of to-be-deprecated numeric constants)
 - rust-lang/rust#150630 (Unknown -> Unsupported compression algorithm)
 - rust-lang/rust#153491 (Move `freeze_*` methods to `OpenOptionsExt2`)
 - rust-lang/rust#153582 (Simplify find_attr! for HirId usage)
 - rust-lang/rust#153623 (std: move `sys::pal::os` to `sys::paths`)
 - rust-lang/rust#153647 (docs(fs): Clarify That File::lock Coordinates Across Processes)
 - rust-lang/rust#153936 (Skip stack_start_aligned for immediate-abort)
 - rust-lang/rust#154011 (implement `BinaryHeap::as_mut_slice`)
 - rust-lang/rust#154167 (ui/lto: move and rename two tests from issues/)
 - rust-lang/rust#154174 (allow `incomplete_features` in most UI tests)
 - rust-lang/rust#154175 (Add new alias for Guillaume Gomez email address)
 - rust-lang/rust#154182 (diagnostics: avoid ICE for undeclared generic parameter in impl)
 - rust-lang/rust#154188 (Update the tracking issue for #[diagnostic::on_move])
 - rust-lang/rust#154201 (Use enums to clarify `DepNodeColorMap` color marking )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants