]> git.lizzy.rs Git - rust.git/blob - tests/ui/let-else/let-else-temp-borrowck.rs
Don't resolve type var roots in point_at_expr_source_of_inferred_type
[rust.git] / tests / ui / let-else / let-else-temp-borrowck.rs
1 // run-pass
2 //
3 // from issue #93951, where borrowck complained the temporary that `foo(&x)` was stored in was to
4 // be dropped sometime after `x` was. It then suggested adding a semicolon that was already there.
5
6
7 use std::fmt::Debug;
8
9 fn foo<'a>(x: &'a str) -> Result<impl Debug + 'a, ()> {
10     Ok(x)
11 }
12
13 fn let_else() {
14     let x = String::from("Hey");
15     let Ok(_) = foo(&x) else { return };
16 }
17
18 fn if_let() {
19     let x = String::from("Hey");
20     let _ = if let Ok(s) = foo(&x) { s } else { return };
21 }
22
23 fn main() {
24     let_else();
25     if_let();
26 }