Use closures more consistently in dep_graph.rs.#153997
Use closures more consistently in dep_graph.rs.#153997nnethercote wants to merge 1 commit intorust-lang:mainfrom
dep_graph.rs.#153997Conversation
This file has several methods that take a `FnOnce() -> R` closure: - `DepGraph::with_ignore` - `DepGraph::with_query_deserialization` - `DepGraph::with_anon_task` - `DepGraphData::with_anon_task_inner` It also has two methods that take a faux closure via an `A` argument and a `fn(TyCtxt<'tcx>, A) -> R` argument: - DepGraph::with_task - DepGraphData::with_task It's not clear why these two are different. They are more awkward to use, e.g. requiring multiple arguments to be gathered into a tuple. This commit changes the latter cases to closures. The commit also changes the types and names of the closures from the awkward `op: OP` to the more standard `f: F`.
|
Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 Some changes occurred in compiler/rustc_codegen_gcc |
|
|
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Use closures more consistently in `dep_graph.rs`.
| } | ||
|
|
||
| pub fn with_ignore<OP, R>(&self, op: OP) -> R | ||
| pub fn with_ignore<F, R>(&self, f: F) -> R |
There was a problem hiding this comment.
| pub fn with_ignore<F, R>(&self, f: F) -> R | |
| pub fn with_ignore<R>(&self, f: impl FnOnce() -> R) -> R |
I prefer using APITs because then you don't have to think whether to name it F or OP.
There was a problem hiding this comment.
Yeah, I generally prefer impl Fn* if there isn't a specific need to name the function type.
|
Based on comments, I think there was historically a desire to make sure that dep-graph tasks didn't accidentally pull in other untracked state via closure capture. But given the existing inconsistency, and the fact that passing |
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (283c322): comparison URL. Overall result: ❌ regressions - no action neededBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (secondary -1.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeResults (secondary -0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 481.409s -> 481.18s (-0.05%) |
This file has several methods that take a
FnOnce() -> Rclosure:DepGraph::with_ignoreDepGraph::with_query_deserializationDepGraph::with_anon_taskDepGraphData::with_anon_task_innerIt also has two methods that take a faux closure via an
Aargument and afn(TyCtxt<'tcx>, A) -> Rargument:It's not clear why these two are different. They are more awkward to use, e.g. requiring multiple arguments to be gathered into a tuple. This commit changes the latter cases to closures.
The commit also changes the types and names of the closures from the awkward
op: OPto the more standardf: F.r? @Zalathar