Skip to content

Commit

Permalink
Add regression test for #73137
Browse files Browse the repository at this point in the history
Co-authored-by: Aaron1011 <[email protected]>
  • Loading branch information
ecstatic-morse and Aaron1011 committed Jun 8, 2020
1 parent c3b0b7b commit b6121a5
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/test/ui/async-await/issue-73137.rs
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit b6121a5

Please sign in to comment.