1
Fork 0

Auto merge of #125423 - fmease:rollup-ne4l9y4, r=fmease

Rollup of 7 pull requests

Successful merges:

 - #125043 (reference type safety invariant docs: clarification)
 - #125306 (Force the inner coroutine of an async closure to `move` if the outer closure is `move` and `FnOnce`)
 - #125355 (Use Backtrace::force_capture instead of Backtrace::capture in rustc_log)
 - #125382 (rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 7))
 - #125391 (Minor serialize/span tweaks)
 - #125395 (Remove unnecessary `.md` from the documentation sidebar)
 - #125399 (Stop using `to_hir_binop` in codegen)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2024-05-22 21:51:26 +00:00
commit 9cdfe285ca
41 changed files with 253 additions and 137 deletions

View file

@ -0,0 +1,27 @@
//@ aux-build:block-on.rs
//@ edition:2021
//@ check-pass
#![feature(async_closure)]
extern crate block_on;
fn consume(_: String) {}
fn main() {
block_on::block_on(async {
let x = 1i32;
let s = String::new();
// `consume(s)` pulls the closure's kind down to `FnOnce`,
// which means that we don't treat the borrow of `x` as a
// self-borrow (with `'env` lifetime). This leads to a lifetime
// error which is solved by forcing the inner coroutine to
// be `move` as well, so that it moves `x`.
let c = async move || {
println!("{x}");
// This makes the closure FnOnce...
consume(s);
};
c().await;
});
}

View file

@ -0,0 +1,24 @@
//@ aux-build:block-on.rs
//@ edition:2021
//@ check-pass
#![feature(async_closure)]
extern crate block_on;
fn force_fnonce<T: async FnOnce()>(t: T) -> T { t }
fn main() {
block_on::block_on(async {
let x = 1i32;
// `force_fnonce` pulls the closure's kind down to `FnOnce`,
// which means that we don't treat the borrow of `x` as a
// self-borrow (with `'env` lifetime). This leads to a lifetime
// error which is solved by forcing the inner coroutine to
// be `move` as well, so that it moves `x`.
let c = force_fnonce(async move || {
println!("{x}");
});
c().await;
});
}