diff options
| author | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2020-06-08 15:01:02 -0700 |
|---|---|---|
| committer | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2020-06-08 16:51:26 -0700 |
| commit | b6121a5419853e7715d6e8671ac51be5fa92b9bf (patch) | |
| tree | 5523c602a04074a05601cd230d2057098d9ef7ed /src | |
| parent | c3b0b7b68f08d5d8266a072f2a3b96e7cbaabe9e (diff) | |
Add regression test for #73137
Co-authored-by: Aaron1011 <aa1ronham@gmail.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/async-await/issue-73137.rs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/test/ui/async-await/issue-73137.rs b/src/test/ui/async-await/issue-73137.rs new file mode 100644 index 00000000000..18374460df7 --- /dev/null +++ b/src/test/ui/async-await/issue-73137.rs @@ -0,0 +1,42 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/73137> + +// run-pass +// edition:2018 + +#![allow(dead_code)] +#![feature(wake_trait)] +use std::future::Future; +use std::task::{Waker, Wake, Context}; +use std::sync::Arc; + +struct DummyWaker; +impl Wake for DummyWaker { + fn wake(self: Arc<Self>) {} +} + +struct Foo { + a: usize, + b: &'static u32, +} + +#[inline(never)] +fn nop<T>(_: T) {} + +fn main() { + let mut fut = Box::pin(async { + let action = Foo { + b: &42, + a: async { 0 }.await, + }; + + // An error in the generator transform caused `b` to be overwritten with `a` when `b` was + // borrowed. + nop(&action.b); + assert_ne!(0usize, unsafe { std::mem::transmute(action.b) }); + + async {}.await; + }); + let waker = Waker::from(Arc::new(DummyWaker)); + let mut cx = Context::from_waker(&waker); + let _ = fut.as_mut().poll(&mut cx); +} |
