]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/issue-103250.rs
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / borrowck / issue-103250.rs
1 // edition:2021
2
3 type TranslateFn = Box<dyn Fn(String, String) -> String>;
4
5 pub struct DeviceCluster {
6     devices: Vec<Device>,
7 }
8
9 impl DeviceCluster {
10     pub async fn do_something(&mut self) -> Result<String, Box<dyn std::error::Error>> {
11         let mut last_error: Box<dyn std::error::Error>;
12
13         for device in &mut self.devices {
14             match device.do_something().await {
15                 Ok(info) => {
16                     return Ok(info);
17                 }
18                 Err(e) => {}
19             }
20         }
21
22         Err(last_error)
23         //~^ ERROR used binding `last_error` isn't initialized
24     }
25 }
26
27 pub struct Device {
28     translate_fn: Option<TranslateFn>,
29 }
30
31 impl Device {
32     pub async fn do_something(&mut self) -> Result<String, Box<dyn std::error::Error>> {
33         Ok(String::from(""))
34     }
35 }
36
37 fn main() {}