-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
fixed-by-NLLBugs fixed, but only when NLL is enabled.Bugs fixed, but only when NLL is enabled.
Description
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 arg
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 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.
Metadata
Metadata
Assignees
Labels
fixed-by-NLLBugs fixed, but only when NLL is enabled.Bugs fixed, but only when NLL is enabled.