You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A slightly modified version of Example 2 from here fails:
fnmain(){let foo:&muti32 = &mut22;letmut r_a:&&muti32 = & foo;let r_b:&mut&&muti32 = &mut r_a;let r_c:&&muti32 = &**r_b;// What is considered borrowed here?*r_b = &&mut0;println!("{}", r_c);}
with the following error:
error[E0716]: temporary value dropped while borrowed
--> src/main.rs:8:13
|
8 | *r_b = &&mut 0;
| ^^^^^^- temporary value is freed at the end of this statement
| |
| creates a temporary which is freed while still in use
9 |
10 | println!("{}", r_c);
| --- borrow later used here
|
= note: consider using a `let` binding to create a longer lived value
However, clearly r_c does not reborrow from r_a nor from r_b. Therefore, using it at the end should not affect either of these, but as we can see this is not the case. If one comments out the println! on line 10, then compilation succeeds as expected. Playground link here
The text was updated successfully, but these errors were encountered:
A slightly modified version of Example 2 from here fails:
with the following error:
However, clearly
r_c
does not reborrow fromr_a
nor fromr_b
. Therefore, using it at the end should not affect either of these, but as we can see this is not the case. If one comments out theprintln!
on line 10, then compilation succeeds as expected. Playground link hereThe text was updated successfully, but these errors were encountered: