diff options
| author | Eric Holk <ericholk@microsoft.com> | 2022-01-05 14:11:37 -0800 | 
|---|---|---|
| committer | Eric Holk <ericholk@microsoft.com> | 2022-01-18 14:25:30 -0800 | 
| commit | 32930d9ea7cc79239daa19a040cbae9867053af8 (patch) | |
| tree | 1fac2ecc51a35832b9c8f968ee19c53d6892be98 /src/test/ui/async-await/partial-drop-partial-reinit.rs | |
| parent | 78c5644de5ffea9d64200bd28eac7e49ca2c8f33 (diff) | |
| download | rust-32930d9ea7cc79239daa19a040cbae9867053af8.tar.gz rust-32930d9ea7cc79239daa19a040cbae9867053af8.zip  | |
Safely handle partial drops
We previously weren't tracking partial re-inits while being too aggressive around partial drops. With this change, we simply ignore partial drops, which is the safer, more conservative choice.
Diffstat (limited to 'src/test/ui/async-await/partial-drop-partial-reinit.rs')
| -rw-r--r-- | src/test/ui/async-await/partial-drop-partial-reinit.rs | 29 | 
1 files changed, 29 insertions, 0 deletions
diff --git a/src/test/ui/async-await/partial-drop-partial-reinit.rs b/src/test/ui/async-await/partial-drop-partial-reinit.rs new file mode 100644 index 00000000000..73f0ca8153c --- /dev/null +++ b/src/test/ui/async-await/partial-drop-partial-reinit.rs @@ -0,0 +1,29 @@ +// edition:2021 +#![feature(negative_impls)] +#![allow(unused)] + +fn main() { + gimme_send(foo()); + //~^ ERROR cannot be sent between threads safely +} + +fn gimme_send<T: Send>(t: T) { + drop(t); +} + +struct NotSend {} + +impl Drop for NotSend { + fn drop(&mut self) {} +} + +impl !Send for NotSend {} + +async fn foo() { + let mut x = (NotSend {},); + drop(x.0); + x.0 = NotSend {}; + bar().await; +} + +async fn bar() {}  | 
