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)
8 // needs-unwind Size of Futures change on panic=abort
13 #![allow(unused_variables, unused_assignments)]
15 use std::future::Future;
17 use std::task::{Context, Poll};
19 const BIG_FUT_SIZE: usize = 1024;
20 struct Big(#[allow(unused_tuple_struct_fields)] [u8; BIG_FUT_SIZE]);
24 Big([0; BIG_FUT_SIZE])
39 impl Future for Joiner {
42 fn poll(self: Pin<&mut Self>, _ctx: &mut Context<'_>) -> Poll<Self::Output> {
56 async fn single_with_noop() {
71 joiner = Joiner { a: Some(a), b: Some(b), c: Some(c) };
74 async fn joined_with_noop() {
82 joiner = Joiner { a: Some(a), b: Some(b), c: Some(c) };
86 async fn join_retval() -> Joiner {
93 Joiner { a: Some(a), b: Some(b), c: Some(c) }
97 assert_eq!(2, std::mem::size_of_val(&single()));
98 assert_eq!(3, std::mem::size_of_val(&single_with_noop()));
99 assert_eq!(3074, std::mem::size_of_val(&joined()));
100 assert_eq!(3078, std::mem::size_of_val(&joined_with_noop()));
101 assert_eq!(3074, std::mem::size_of_val(&join_retval()));