]> git.proxmox.com Git - rustc.git/blob - src/test/ui/async-await/issue-70935-complex-spans.rs
New upstream version 1.63.0+dfsg1
[rustc.git] / src / test / ui / async-await / issue-70935-complex-spans.rs
1 // edition:2018
2 // revisions: normal drop_tracking
3 // [drop_tracking]compile-flags:-Zdrop-tracking
4 // #70935: Check if we do not emit snippet
5 // with newlines which lead complex diagnostics.
6
7 use std::future::Future;
8
9 async fn baz<T>(_c: impl FnMut() -> T) where T: Future<Output=()> {
10 //[drop_tracking]~^ within this `async fn` body
11 }
12
13 fn foo(tx: std::sync::mpsc::Sender<i32>) -> impl Future + Send {
14 //[normal]~^ ERROR: future cannot be sent between threads safely
15 //[drop_tracking]~^^ ERROR: `Sender<i32>` cannot be shared
16 //[drop_tracking]~| NOTE: cannot be shared
17 //[drop_tracking]~| NOTE: requirements on the impl of `Send`
18 //[drop_tracking]~| NOTE: captures the following types
19 //[drop_tracking]~| NOTE: in this expansion
20 //[drop_tracking]~| NOTE: in this expansion
21 //[drop_tracking]~| NOTE: in this expansion
22 //[drop_tracking]~| NOTE: in this expansion
23 async move {
24 //[drop_tracking]~^ within this `async` block
25 baz(|| async{ //[drop_tracking]~ NOTE: used within this closure
26 foo(tx.clone());
27 }).await;
28 }
29 }
30
31 fn bar(_s: impl Future + Send) {
32 }
33
34 fn main() {
35 let (tx, _rx) = std::sync::mpsc::channel();
36 bar(foo(tx));
37 }