-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
macros: don't take ownership of futures in macros #5087
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
ccf30c5
4a4c137
12fd8ce
f734620
d9eea3e
da99e6d
0bae230
8cf8a03
624dff4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
use std::sync::Arc; | ||
|
||
#[cfg(tokio_wasm_not_wasi)] | ||
#[cfg(target_pointer_width = "64")] | ||
use wasm_bindgen_test::wasm_bindgen_test as test; | ||
#[cfg(tokio_wasm_not_wasi)] | ||
use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; | ||
|
@@ -64,6 +65,7 @@ async fn two_await() { | |
} | ||
|
||
#[test] | ||
#[cfg(target_pointer_width = "64")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we be making similar assertions about the size of the futures on 32-bit platforms as well? or, calculate the expected size by adding either 8 or 4 bytes based on the value of |
||
fn join_size() { | ||
use futures::future; | ||
use std::mem; | ||
|
@@ -72,14 +74,14 @@ fn join_size() { | |
let ready = future::ready(0i32); | ||
tokio::join!(ready) | ||
}; | ||
assert_eq!(mem::size_of_val(&fut), 20); | ||
assert_eq!(mem::size_of_val(&fut), 32); | ||
|
||
let fut = async { | ||
let ready1 = future::ready(0i32); | ||
let ready2 = future::ready(0i32); | ||
tokio::join!(ready1, ready2) | ||
}; | ||
assert_eq!(mem::size_of_val(&fut), 32); | ||
assert_eq!(mem::size_of_val(&fut), 48); | ||
} | ||
|
||
async fn non_cooperative_task(permits: Arc<Semaphore>) -> usize { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -207,6 +207,7 @@ async fn nested() { | |
} | ||
|
||
#[maybe_tokio_test] | ||
#[cfg(target_pointer_width = "64")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as with join, could we make a separate set of assertions about the future size on 32-bit platforms? |
||
async fn struct_size() { | ||
use futures::future; | ||
use std::mem; | ||
|
@@ -219,7 +220,7 @@ async fn struct_size() { | |
} | ||
}; | ||
|
||
assert!(mem::size_of_val(&fut) <= 32); | ||
assert_eq!(mem::size_of_val(&fut), 40); | ||
|
||
let fut = async { | ||
let ready1 = future::ready(0i32); | ||
|
@@ -231,7 +232,7 @@ async fn struct_size() { | |
} | ||
}; | ||
|
||
assert!(mem::size_of_val(&fut) <= 40); | ||
assert_eq!(mem::size_of_val(&fut), 48); | ||
|
||
let fut = async { | ||
let ready1 = future::ready(0i32); | ||
|
@@ -245,7 +246,7 @@ async fn struct_size() { | |
} | ||
}; | ||
|
||
assert!(mem::size_of_val(&fut) <= 48); | ||
assert_eq!(mem::size_of_val(&fut), 56); | ||
} | ||
|
||
#[maybe_tokio_test] | ||
|
Uh oh!
There was an error while loading. Please reload this page.