Closed
Description
Hey Folks,
So, I've been fuzz testing rustc
nightly using a range of generated programs and am digesting the findings. This one stood out to me:
fn main() {
let mut x = 1;
{
let mut y = &mut x;
y = y;
y;
}
x;
}
This currently reports an E0505 on the playground and Rust nightly. However, removing the nop y=y;
and its fine. This feels like a bug to me ... thoughts?
Activity
ExpHP commentedon Aug 19, 2019
I think this is technically a reborrow (
y = &mut *y
) rather than a no-op, because the lhs and rhs are both known to be&mut _
. Though this might be the first time I've ever seen a reborrow cause fewer programs to compile versus a move!(amusingly, though, the MIR is simply
_2 = _2
)Edit: nope, there's more to it than that. If you explicitly write
y = &mut *y
, it compiles!DavePearce commentedon Aug 21, 2019
Ok, have found some more related cases:
Above gives
E0502
andE0505
.Above gives
E0499
andE0505
.nikomatsakis commentedon Aug 29, 2019
Discussed in lang team pre-triage meeting. Maybe @matthewjasper you'd be game to investigate and take a look at what's happening here?