Skip to content

Commit 4c1e581

Browse files
authored
add track_caller atrtibute to spawn calls (#454)
* add track_caller attribute to spawn calls * fix ci
1 parent dc67ba7 commit 4c1e581

File tree

6 files changed

+20
-4
lines changed

6 files changed

+20
-4
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ jobs:
7373
command: install
7474
args: cargo-hack
7575

76+
- name: Generate Cargo.lock
77+
uses: actions-rs/cargo@v1
78+
with: { command: generate-lockfile }
79+
80+
- name: Tweak lockfile
81+
run: |
82+
cargo update -p=native-tls --precise=0.2.8
83+
7684
- name: check lib
7785
if: >
7886
matrix.target.os != 'ubuntu-latest'
@@ -142,10 +150,9 @@ jobs:
142150
with: { command: generate-lockfile }
143151

144152
- name: Tweak lockfile
145-
uses: actions-rs/cargo@v1
146-
with:
147-
command: update
148-
args: -p=rustls --precise=0.20.2
153+
run: |
154+
cargo update -p=rustls --precise=0.20.2
155+
cargo update -p=native-tls --precise=0.2.8
149156
150157
- name: tests
151158
run: |

actix-rt/CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Changes
22

33
## Unreleased - 2022-xx-xx
4+
- Add `#[track_caller]` attribute to `spawn` functions and methods. [#454]
5+
6+
[#454]: https://github.com/actix/actix-net/pull/454
47

58

69
## 2.7.0 - 2022-03-08

actix-rt/src/arbiter.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ impl Arbiter {
260260
/// If you require a result, include a response channel in the future.
261261
///
262262
/// Returns true if future was sent successfully and false if the Arbiter has died.
263+
#[track_caller]
263264
pub fn spawn<Fut>(&self, future: Fut) -> bool
264265
where
265266
Fut: Future<Output = ()> + Send + 'static,
@@ -275,6 +276,7 @@ impl Arbiter {
275276
/// channel in the function.
276277
///
277278
/// Returns true if function was sent successfully and false if the Arbiter has died.
279+
#[track_caller]
278280
pub fn spawn_fn<F>(&self, f: F) -> bool
279281
where
280282
F: FnOnce() + Send + 'static,

actix-rt/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ pub mod task {
195195
/// assert!(handle.await.unwrap_err().is_cancelled());
196196
/// # });
197197
/// ```
198+
#[track_caller]
198199
#[inline]
199200
pub fn spawn<Fut>(f: Fut) -> JoinHandle<Fut::Output>
200201
where

actix-rt/src/runtime.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ impl Runtime {
5353
/// # Panics
5454
/// This function panics if the spawn fails. Failure occurs if the executor is currently at
5555
/// capacity and is unable to spawn a new future.
56+
#[track_caller]
5657
pub fn spawn<F>(&self, future: F) -> JoinHandle<F::Output>
5758
where
5859
F: Future + 'static,
@@ -73,6 +74,7 @@ impl Runtime {
7374
///
7475
/// The caller is responsible for ensuring that other spawned futures complete execution by
7576
/// calling `block_on` or `run`.
77+
#[track_caller]
7678
pub fn block_on<F>(&self, f: F) -> F::Output
7779
where
7880
F: Future,

actix-rt/src/system.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ impl SystemRunner {
204204
}
205205

206206
/// Runs the provided future, blocking the current thread until the future completes.
207+
#[track_caller]
207208
#[inline]
208209
pub fn block_on<F: Future>(&self, fut: F) -> F::Output {
209210
self.rt.block_on(fut)

0 commit comments

Comments
 (0)