]> git.proxmox.com Git - rustc.git/blob - tests/ui/async-await/drop-track-field-assign-nonsend.rs
New upstream version 1.69.0+dfsg1
[rustc.git] / tests / ui / async-await / drop-track-field-assign-nonsend.rs
1 // revisions: no_drop_tracking drop_tracking drop_tracking_mir
2 // [drop_tracking] compile-flags: -Zdrop-tracking
3 // [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir
4 // Derived from an ICE found in tokio-xmpp during a crater run.
5 // edition:2021
6
7 #![allow(dead_code)]
8
9 #[derive(Clone)]
10 struct InfoResult {
11 node: Option<std::rc::Rc<String>>
12 }
13
14 struct Agent {
15 info_result: InfoResult
16 }
17
18 impl Agent {
19 async fn handle(&mut self) {
20 let mut info = self.info_result.clone();
21 info.node = None;
22 let element = parse_info(info);
23 let _ = send_element(element).await;
24 }
25 }
26
27 struct Element {
28 }
29
30 async fn send_element(_: Element) {}
31
32 fn parse(_: &[u8]) -> Result<(), ()> {
33 Ok(())
34 }
35
36 fn parse_info(_: InfoResult) -> Element {
37 Element { }
38 }
39
40 fn assert_send<T: Send>(_: T) {}
41
42 fn main() {
43 let agent = Agent { info_result: InfoResult { node: None } };
44 // FIXME: It would be nice for this to work. See #94067.
45 assert_send(agent.handle());
46 //~^ cannot be sent between threads safely
47 }