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
I think the code below should not be allowed by the compiler, but it is. Here, even though arg is mutably borrowed, we are allowed to make a copy (reborrow) of it. Why is this the case? As the comment shows, a read of argis invalid, so why isn't a reborrow? I had a discussion about this on the IRC, but I would like a second opinion, as I'm still not convinced the behavior is consistent. The only difference I see between a reborrow let b = &*arg and a copy let c = arg is the lifetimes of the resulting borrows. But I don't see why that would make the first valid but not the second..
fn f(mut arg: & bool) {
let a = & mut arg;
let b = &*arg; // allowed
// this would not be allowed: let c = arg;
}
Tested on 1.29.2.
The text was updated successfully, but these errors were encountered:
I think the code below should not be allowed by the compiler, but it is. Here, even though
arg
is mutably borrowed, we are allowed to make a copy (reborrow) of it. Why is this the case? As the comment shows, a read ofarg
is invalid, so why isn't a reborrow? I had a discussion about this on the IRC, but I would like a second opinion, as I'm still not convinced the behavior is consistent. The only difference I see between a reborrowlet b = &*arg
and a copylet c = arg
is the lifetimes of the resulting borrows. But I don't see why that would make the first valid but not the second..Tested on 1.29.2.
The text was updated successfully, but these errors were encountered: