os-rust/tests/ui/async-await/async-closures
bors 730d5d4095 Auto merge of #128572 - compiler-errors:fix-elaborate-box-derefs-on-debug, r=saethlin
Fix `ElaborateBoxDerefs` on debug varinfo

Slightly simplifies the `ElaborateBoxDerefs` pass to fix cases where it was applying the wrong projections to debug var infos containing places that deref boxes.

From what I can tell[^1], we don't actually have any tests (or code anywhere, really) that exercise `debug x => *(...: Box<T>)`, and it's very difficult to trigger this in surface Rust, so I wrote a custom MIR test.

What happens is that the pass was turning `*(SOME_PLACE: Box<T>)` into `*(*((((SOME_PLACE).0: Unique<T>).0: NonNull<T>).0: *const T))` in debug var infos. In particular, notice the *double deref*, which was wrong.

This is the root cause of #128554, so this PR fixes #128554 as well. The reason that async closures was affected is because of the way that we compute the [`ByMove` body](https://github.com/rust-lang/rust/blob/master/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs), which resulted in `*(...: Box<T>)` in debug var info. But this really has nothing to do with async closures.

[^1]: Validated by literally replacing the `if elem == PlaceElem::Deref && base_ty.is_box() { ... }` innards with a `panic!()`, which compiled all of stage2 without panicking.
2024-08-10 21:24:25 +00:00
..
auxiliary [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
ambiguous-arg.rs Propagate errors rather than using return_if_err 2024-05-12 12:50:18 -04:00
ambiguous-arg.stderr Propagate errors rather than using return_if_err 2024-05-12 12:50:18 -04:00
arg-mismatch.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
arg-mismatch.stderr Add some tests 2024-02-06 02:22:58 +00:00
async-fn-mut-for-async-fn.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
async-fn-once-for-async-fn.rs Flesh out a few more tests 2024-02-27 17:39:20 +00:00
await-inference-guidance.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
box-deref-in-debuginfo.rs Stop doing weird index stuff in ElaborateBoxDerefs 2024-08-02 17:45:55 -04:00
brand.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
captures.rs Force move async-closures that are FnOnce to make their inner coroutines also move 2024-04-04 19:44:51 -04:00
captures.run.stdout Force move async-closures that are FnOnce to make their inner coroutines also move 2024-04-04 19:44:51 -04:00
clone-closure.rs Make coroutine-closures possible to be cloned 2024-07-26 12:53:53 -04:00
clone-closure.run.stdout Make coroutine-closures possible to be cloned 2024-07-26 12:53:53 -04:00
constrained-but-no-upvars-yet.rs Make all tests in async dir build-pass, adjust implements-fnmut test to begin ICEing during codegen 2024-06-29 17:38:02 -04:00
def-path.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
def-path.stderr Only split by-ref/by-move futures for async closures 2024-03-19 16:59:23 -04:00
different-projection-lengths-for-different-upvars.rs Only assert for child/parent projection compatibility AFTER checking that theyre coming from the same place 2024-04-10 10:13:24 -04:00
dont-ice-when-body-tainted-by-errors.rs Don't do coroutine-closure-specific upvar analysis if tainted by errors 2024-04-12 12:14:29 -04:00
dont-ice-when-body-tainted-by-errors.stderr Don't do coroutine-closure-specific upvar analysis if tainted by errors 2024-04-12 12:14:29 -04:00
drop.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
drop.run.stdout Fix drop shim for AsyncFnOnce closure, AsyncFnMut shim for AsyncFn closure 2024-02-06 02:22:58 +00:00
fn-exception-target-features.rs Don't implement AsyncFn for FnDef/FnPtr that wouldnt implement Fn 2024-08-08 14:07:31 -04:00
fn-exception-target-features.stderr Don't implement AsyncFn for FnDef/FnPtr that wouldnt implement Fn 2024-08-08 14:07:31 -04:00
fn-exception.rs Don't implement AsyncFn for FnDef/FnPtr that wouldnt implement Fn 2024-08-08 14:07:31 -04:00
fn-exception.stderr Don't implement AsyncFn for FnDef/FnPtr that wouldnt implement Fn 2024-08-08 14:07:31 -04:00
force-move-due-to-actually-fnonce.rs Make all tests in async dir build-pass, adjust implements-fnmut test to begin ICEing during codegen 2024-06-29 17:38:02 -04:00
force-move-due-to-inferred-kind.rs Make all tests in async dir build-pass, adjust implements-fnmut test to begin ICEing during codegen 2024-06-29 17:38:02 -04:00
foreign.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
higher-ranked-return.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
higher-ranked-return.stderr Add some tests 2024-02-06 02:22:58 +00:00
higher-ranked.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
implements-fnmut.rs Make all tests in async dir build-pass, adjust implements-fnmut test to begin ICEing during codegen 2024-06-29 17:38:02 -04:00
is-fn.rs Ignore tests w/ current/next revisions from compare-mode=next-solver 2024-03-10 21:18:41 -04:00
is-not-fn.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
is-not-fn.stderr Print kind of coroutine closure 2024-02-10 23:18:01 +00:00
lint-closure-returning-async-block.rs Make it into a structured suggestion, maybe-incorrect 2024-06-28 20:16:35 -04:00
lint-closure-returning-async-block.stderr Make it into a structured suggestion, maybe-incorrect 2024-06-28 20:16:35 -04:00
mangle.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
moro-example.rs Make the computation of coroutine_captures_by_ref_ty more sophisticated 2024-04-10 13:39:53 -04:00
move-consuming-capture.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
move-consuming-capture.stderr Make coroutine-closures possible to be cloned 2024-07-26 12:53:53 -04:00
move-is-async-fn.rs Flesh out a few more tests 2024-02-27 17:39:20 +00:00
mut-ref-reborrow.rs Account for an additional reborrow inserted by UniqueImmBorrow and MutBorrow 2024-04-05 17:35:03 -04:00
mutate.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
no-borrow-from-env.rs Make the computation of coroutine_captures_by_ref_ty more sophisticated 2024-04-10 13:39:53 -04:00
non-copy-arg-does-not-force-inner-move.rs Skip over args when determining if coroutine-closure's inner coroutine consumes its upvars 2024-08-01 18:46:26 -04:00
not-clone-closure.rs Make coroutine-closures possible to be cloned 2024-07-26 12:53:53 -04:00
not-clone-closure.stderr Make coroutine-closures possible to be cloned 2024-07-26 12:53:53 -04:00
not-fn.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
not-fn.stderr make better async fn kind errors 2024-02-15 15:59:35 +00:00
not-lending.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
not-lending.stderr Add some tests 2024-02-06 02:22:58 +00:00
once.rs Ignore tests w/ current/next revisions from compare-mode=next-solver 2024-03-10 21:18:41 -04:00
overlapping-projs.rs Check the base of the place too! 2024-04-05 16:48:45 -04:00
overlapping-projs.run.stdout Check the base of the place too! 2024-04-05 16:48:45 -04:00
precise-captures.call.run.stdout Rework the ByMoveBody shim to actually work correctly 2024-04-05 15:28:13 -04:00
precise-captures.call_once.run.stdout Rework the ByMoveBody shim to actually work correctly 2024-04-05 15:28:13 -04:00
precise-captures.force_once.run.stdout Rework the ByMoveBody shim to actually work correctly 2024-04-05 15:28:13 -04:00
precise-captures.rs Rework the ByMoveBody shim to actually work correctly 2024-04-05 15:28:13 -04:00
refd.rs Flesh out a few more tests 2024-02-27 17:39:20 +00:00
return-type-mismatch.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
return-type-mismatch.stderr Add some tests 2024-02-06 02:22:58 +00:00
signature-deduction.rs Make all tests in async dir build-pass, adjust implements-fnmut test to begin ICEing during codegen 2024-06-29 17:38:02 -04:00
signature-inference-from-two-part-bound.rs Infer async closure signature from old-style two-part Fn + Future bounds 2024-07-08 12:56:54 -04:00
tainted-body.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
tainted-body.stderr Don't ICE in ByMoveBody when coroutine is tainted 2024-02-09 00:36:30 +00:00
truncated-fields-when-imm.rs Actually, stop making any assumption about the projections applied to the upvar 2024-04-08 19:47:52 -04:00
without-precise-captures-we-are-powerless.rs Make coroutine-closures possible to be cloned 2024-07-26 12:53:53 -04:00
without-precise-captures-we-are-powerless.stderr Suppress useless clone suggestion 2024-07-26 12:53:55 -04:00
wrong-fn-kind.rs Actually use the inferred ClosureKind from signature inference in coroutine-closures 2024-04-04 19:44:35 -04:00
wrong-fn-kind.stderr Tighten spans for async blocks 2024-06-27 15:19:08 -04:00