File: task-context-arg.rs

package info (click to toggle)
rustc 1.86.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid
  • size: 913,560 kB
  • sloc: xml: 158,127; python: 35,921; javascript: 19,689; sh: 19,600; cpp: 18,906; ansic: 13,124; asm: 4,376; makefile: 708; perl: 29; lisp: 29; ruby: 19; sql: 11
file content (25 lines) | stat: -rw-r--r-- 1,003 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Checks that we don't get conflicting arguments in our debug info with a particular async function
// structure.

//@ edition:2021
//@ compile-flags: -Cdebuginfo=2
//@ build-pass

#![crate_type = "lib"]

use std::future::Future;

// The compiler produces a closure as part of this function. That closure initially takes an
// argument _task_context. Later, when the MIR for that closure is transformed into a coroutine
// state machine, _task_context is demoted to not be an argument, but just part of an unnamed
// argument. If we emit debug info saying that both _task_context and the unnamed argument are both
// argument number 2, then LLVM will fail with "conflicting debug info for argument". See
// https://github.com/rust-lang/rust/pull/109466#issuecomment-1500879195 for details.
async fn recv_unit() {
    std::future::ready(()).await;
}

pub fn poll_recv() {
    // This box is necessary in order to reproduce the problem.
    let _: Box<dyn Future<Output = ()>> = Box::new(recv_unit());
}