Rollup merge of #56319 - RalfJung:async-mutable-ref, r=cramertj

fix futures creating aliasing mutable and shared ref

Fixes the problem described in https://github.com/solson/miri/issues/532#issuecomment-442552764: `set_task_waker` takes a shared reference and puts a copy into the TLS (in a `NonNull`), but `get_task_waker` gets it back out as a mutable reference. That violates "mutable references must not alias anything"!
This commit is contained in:
Guillaume Gomez 2018-11-29 13:10:50 +01:00 committed by GitHub
commit 79f02e4b33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -95,10 +95,10 @@ where
});
let _reset_waker = SetOnDrop(waker_ptr);
let mut waker_ptr = waker_ptr.expect(
let waker_ptr = waker_ptr.expect(
"TLS LocalWaker not set. This is a rustc bug. \
Please file an issue on https://github.com/rust-lang/rust.");
unsafe { f(waker_ptr.as_mut()) }
unsafe { f(waker_ptr.as_ref()) }
}
#[unstable(feature = "gen_future", issue = "50547")]