From 4c1e581a542b0ca14f543932792c5866cc7a7161 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Mon, 25 Apr 2022 21:05:48 +0100 Subject: [PATCH] add track_caller atrtibute to spawn calls (#454) * add track_caller attribute to spawn calls * fix ci --- .github/workflows/ci.yml | 15 +++++++++++---- actix-rt/CHANGES.md | 3 +++ actix-rt/src/arbiter.rs | 2 ++ actix-rt/src/lib.rs | 1 + actix-rt/src/runtime.rs | 2 ++ actix-rt/src/system.rs | 1 + 6 files changed, 20 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fc82ab18..e87c4205 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -73,6 +73,14 @@ jobs: command: install args: cargo-hack + - name: Generate Cargo.lock + uses: actions-rs/cargo@v1 + with: { command: generate-lockfile } + + - name: Tweak lockfile + run: | + cargo update -p=native-tls --precise=0.2.8 + - name: check lib if: > matrix.target.os != 'ubuntu-latest' @@ -142,10 +150,9 @@ jobs: with: { command: generate-lockfile } - name: Tweak lockfile - uses: actions-rs/cargo@v1 - with: - command: update - args: -p=rustls --precise=0.20.2 + run: | + cargo update -p=rustls --precise=0.20.2 + cargo update -p=native-tls --precise=0.2.8 - name: tests run: | diff --git a/actix-rt/CHANGES.md b/actix-rt/CHANGES.md index 671b623a..4715a4b5 100644 --- a/actix-rt/CHANGES.md +++ b/actix-rt/CHANGES.md @@ -1,6 +1,9 @@ # Changes ## Unreleased - 2022-xx-xx +- Add `#[track_caller]` attribute to `spawn` functions and methods. [#454] + +[#454]: https://github.com/actix/actix-net/pull/454 ## 2.7.0 - 2022-03-08 diff --git a/actix-rt/src/arbiter.rs b/actix-rt/src/arbiter.rs index 95256360..4c9a588e 100644 --- a/actix-rt/src/arbiter.rs +++ b/actix-rt/src/arbiter.rs @@ -260,6 +260,7 @@ impl Arbiter { /// If you require a result, include a response channel in the future. /// /// Returns true if future was sent successfully and false if the Arbiter has died. + #[track_caller] pub fn spawn(&self, future: Fut) -> bool where Fut: Future + Send + 'static, @@ -275,6 +276,7 @@ impl Arbiter { /// channel in the function. /// /// Returns true if function was sent successfully and false if the Arbiter has died. + #[track_caller] pub fn spawn_fn(&self, f: F) -> bool where F: FnOnce() + Send + 'static, diff --git a/actix-rt/src/lib.rs b/actix-rt/src/lib.rs index b2d5f893..23dd01e8 100644 --- a/actix-rt/src/lib.rs +++ b/actix-rt/src/lib.rs @@ -195,6 +195,7 @@ pub mod task { /// assert!(handle.await.unwrap_err().is_cancelled()); /// # }); /// ``` +#[track_caller] #[inline] pub fn spawn(f: Fut) -> JoinHandle where diff --git a/actix-rt/src/runtime.rs b/actix-rt/src/runtime.rs index 25937003..557dfcfe 100644 --- a/actix-rt/src/runtime.rs +++ b/actix-rt/src/runtime.rs @@ -53,6 +53,7 @@ impl Runtime { /// # Panics /// This function panics if the spawn fails. Failure occurs if the executor is currently at /// capacity and is unable to spawn a new future. + #[track_caller] pub fn spawn(&self, future: F) -> JoinHandle where F: Future + 'static, @@ -73,6 +74,7 @@ impl Runtime { /// /// The caller is responsible for ensuring that other spawned futures complete execution by /// calling `block_on` or `run`. + #[track_caller] pub fn block_on(&self, f: F) -> F::Output where F: Future, diff --git a/actix-rt/src/system.rs b/actix-rt/src/system.rs index 0ea3547d..f3a5a4d8 100644 --- a/actix-rt/src/system.rs +++ b/actix-rt/src/system.rs @@ -204,6 +204,7 @@ impl SystemRunner { } /// Runs the provided future, blocking the current thread until the future completes. + #[track_caller] #[inline] pub fn block_on(&self, fut: F) -> F::Output { self.rt.block_on(fut)