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