Skip to content

Commit eaac7a1

Browse files
committed
Auto merge of #120991 - matthiaskrgr:rollup-f8kw2st, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #118983 (Warn on references casting to bigger memory layout) - #119451 (Gate PR CI on clippy correctness lints) - #120273 (compiletest: few naive improvements) - #120950 (Fix async closures in CTFE) - #120958 (Dejargonize `subst`) - #120965 (Add lahfsahf and prfchw target feature) - #120970 (add another test for promoteds-in-static) - #120979 (Update books) r? `@ghost` `@rustbot` modify labels: rollup
2 parents b320c0a + cc5b1f4 commit eaac7a1

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

tests/fail/unaligned_pointers/unaligned_ref_addr_of.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// This should fail even without Stacked Borrows.
22
//@compile-flags: -Zmiri-disable-stacked-borrows -Cdebug-assertions=no
33

4+
#![allow(invalid_reference_casting)] // for u16 -> u32
5+
46
fn main() {
57
// Try many times as this might work by chance.
68
for _ in 0..20 {

tests/pass/async-closure.rs

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#![feature(async_closure, noop_waker, async_fn_traits)]
2+
3+
use std::future::Future;
4+
use std::pin::pin;
5+
use std::task::*;
6+
7+
pub fn block_on<T>(fut: impl Future<Output = T>) -> T {
8+
let mut fut = pin!(fut);
9+
let ctx = &mut Context::from_waker(Waker::noop());
10+
11+
loop {
12+
match fut.as_mut().poll(ctx) {
13+
Poll::Pending => {}
14+
Poll::Ready(t) => break t,
15+
}
16+
}
17+
}
18+
19+
async fn call_once(f: impl async FnOnce(DropMe)) {
20+
f(DropMe("world")).await;
21+
}
22+
23+
#[derive(Debug)]
24+
struct DropMe(&'static str);
25+
26+
impl Drop for DropMe {
27+
fn drop(&mut self) {
28+
println!("{}", self.0);
29+
}
30+
}
31+
32+
pub fn main() {
33+
block_on(async {
34+
let b = DropMe("hello");
35+
let async_closure = async move |a: DropMe| {
36+
println!("{a:?} {b:?}");
37+
};
38+
call_once(async_closure).await;
39+
});
40+
}

tests/pass/async-closure.stdout

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
DropMe("world") DropMe("hello")
2+
world
3+
hello

0 commit comments

Comments
 (0)