1 // Test that we don't store uninitialized locals in futures from `async fn`.
3 // The exact sizes can change by a few bytes (we'd like to know when they do).
4 // What we don't want to see is the wrong multiple of 1024 (the size of `Big`)
5 // being reflected in the size.
7 // ignore-emscripten (sizes don't match)
12 #![allow(unused_variables, unused_assignments)]
14 use std::future::Future;
16 use std::task::{Context, Poll};
18 const BIG_FUT_SIZE: usize = 1024;
19 struct Big([u8; BIG_FUT_SIZE]);
23 Big([0; BIG_FUT_SIZE])
38 impl Future for Joiner {
41 fn poll(self: Pin<&mut Self>, _ctx: &mut Context<'_>) -> Poll<Self::Output> {
55 async fn single_with_noop() {
71 joiner = Joiner { a: Some(a), b: Some(b), c: Some(c) };
75 async fn joined_with_noop() {
83 joiner = Joiner { a: Some(a), b: Some(b), c: Some(c) };
87 async fn join_retval() -> Joiner {
94 Joiner { a: Some(a), b: Some(b), c: Some(c) }
98 assert_eq!(2, std::mem::size_of_val(&single()));
99 assert_eq!(3, std::mem::size_of_val(&single_with_noop()));
100 assert_eq!(3078, std::mem::size_of_val(&joined()));
101 assert_eq!(3078, std::mem::size_of_val(&joined_with_noop()));
102 assert_eq!(3074, std::mem::size_of_val(&join_retval()));