diff --git a/.github/workflows/loom.yml b/.github/workflows/loom.yml
index d9bc4d161e7..bd92a1e45a4 100644
--- a/.github/workflows/loom.yml
+++ b/.github/workflows/loom.yml
@@ -45,4 +45,5 @@ jobs:
env:
RUSTFLAGS: --cfg loom --cfg tokio_unstable -Dwarnings
LOOM_MAX_PREEMPTIONS: 2
+ LOOM_MAX_BRANCHES: 10000
SCOPE: ${{ matrix.scope }}
diff --git a/tokio/src/runtime/context.rs b/tokio/src/runtime/context.rs
index 0e7b636af05..4f30d3374a9 100644
--- a/tokio/src/runtime/context.rs
+++ b/tokio/src/runtime/context.rs
@@ -7,8 +7,7 @@ use std::cell::Cell;
use crate::util::rand::{FastRand, RngSeed};
cfg_rt! {
- use crate::runtime::scheduler;
- use crate::runtime::task::Id;
+ use crate::runtime::{scheduler, task::Id, Defer};
use std::cell::RefCell;
use std::marker::PhantomData;
@@ -19,6 +18,7 @@ struct Context {
/// Handle to the runtime scheduler running on the current thread.
#[cfg(feature = "rt")]
handle: RefCell