We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c5c610a commit 638d9c3Copy full SHA for 638d9c3
src/test/ui/let-else/let-else-temp-borrowck.rs
@@ -0,0 +1,26 @@
1
+// check-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
+#![feature(let_else)]
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(s) = foo(&x) else { return };
16
17
18
+fn if_let() {
19
20
+ let s = if let Ok(s) = foo(&x) { s } else { return };
21
22
23
+fn main() {
24
+ let_else();
25
+ if_let();
26
0 commit comments