diff options
| author | Joshua Nelson <jnelson@cloudflare.com> | 2022-07-01 00:05:00 -0500 |
|---|---|---|
| committer | Joshua Nelson <jnelson@cloudflare.com> | 2022-07-10 15:39:07 -0500 |
| commit | b30315d64f75b26fc20d3df975a48cd1e149f28f (patch) | |
| tree | 3fb11312783fddff926aa54326bc7fe8770362f4 /src/test/ui/async-await/default-struct-update.rs | |
| parent | 17355a3b9f30e16870a1890033bd13463c664f81 (diff) | |
| download | rust-b30315d64f75b26fc20d3df975a48cd1e149f28f.tar.gz rust-b30315d64f75b26fc20d3df975a48cd1e149f28f.zip | |
Fix drop-tracking ICE when a struct containing a field with a `Drop` impl is used across an await
Previously, drop-tracking would incorrectly assume the struct would be dropped immediately, which was not true: when the field had a type with a manual `Drop` impl, the drop becomes observable and has to be dropped after the await instead. For reasons I don't understand, this also fixes another error crater popped up related to type parameters. #98476
Diffstat (limited to 'src/test/ui/async-await/default-struct-update.rs')
| -rw-r--r-- | src/test/ui/async-await/default-struct-update.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/test/ui/async-await/default-struct-update.rs b/src/test/ui/async-await/default-struct-update.rs new file mode 100644 index 00000000000..64fb6280dd7 --- /dev/null +++ b/src/test/ui/async-await/default-struct-update.rs @@ -0,0 +1,22 @@ +// build-pass +// edition:2018 +// compile-flags: -Zdrop-tracking=y + +fn main() { + let _ = foo(); +} + +async fn from_config(_: Config) {} + +async fn foo() { + from_config(Config { + nickname: None, + ..Default::default() + }) + .await; +} + +#[derive(Default)] +struct Config { + nickname: Option<Box<u8>>, +} |
