Skip to content

Commit 207cec0

Browse files
committed
Clean up with_task.
Currently it creates an `Option` and then does `map`/`unwrap_or` and `map_or_else` on it, which is hard to read. This commit simplifies things by moving more code into the two arms of the if/else.
1 parent 458d4da commit 207cec0

File tree

1 file changed

+6
-10
lines changed
  • compiler/rustc_query_system/src/dep_graph

1 file changed

+6
-10
lines changed

compiler/rustc_query_system/src/dep_graph/graph.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -354,24 +354,20 @@ impl<K: DepKind> DepGraphData<K> {
354354
- dep-node: {key:?}"
355355
);
356356

357-
let task_deps = if cx.dep_context().is_eval_always(key.kind) {
358-
None
357+
let with_deps = |task_deps| K::with_deps(task_deps, || task(cx, arg));
358+
let (result, edges) = if cx.dep_context().is_eval_always(key.kind) {
359+
(with_deps(TaskDepsRef::EvalAlways), smallvec![])
359360
} else {
360-
Some(Lock::new(TaskDeps {
361+
let task_deps = Lock::new(TaskDeps {
361362
#[cfg(debug_assertions)]
362363
node: Some(key),
363364
reads: SmallVec::new(),
364365
read_set: Default::default(),
365366
phantom_data: PhantomData,
366-
}))
367+
});
368+
(with_deps(TaskDepsRef::Allow(&task_deps)), task_deps.into_inner().reads)
367369
};
368370

369-
let task_deps_ref =
370-
task_deps.as_ref().map(TaskDepsRef::Allow).unwrap_or(TaskDepsRef::EvalAlways);
371-
372-
let result = K::with_deps(task_deps_ref, || task(cx, arg));
373-
let edges = task_deps.map_or_else(|| smallvec![], |lock| lock.into_inner().reads);
374-
375371
let dcx = cx.dep_context();
376372
let hashing_timer = dcx.profiler().incr_result_hashing();
377373
let current_fingerprint =

0 commit comments

Comments
 (0)