Fix dest prop miscompilation around references
This commit is contained in:
parent
e0bc267512
commit
4b6a4821b7
@ -905,7 +905,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindAssignments<'a, 'tcx> {
|
||||
// FIXME: This can be smarter and take `StorageDead` into account (which
|
||||
// invalidates borrows).
|
||||
if self.ever_borrowed_locals.contains(dest.local)
|
||||
&& self.ever_borrowed_locals.contains(src.local)
|
||||
|| self.ever_borrowed_locals.contains(src.local)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
16
src/test/ui/issues/issue-77002.rs
Normal file
16
src/test/ui/issues/issue-77002.rs
Normal file
@ -0,0 +1,16 @@
|
||||
// compile-flags: -Zmir-opt-level=2 -Copt-level=0
|
||||
// run-pass
|
||||
|
||||
type M = [i64; 2];
|
||||
|
||||
fn f(a: &M) -> M {
|
||||
let mut b: M = M::default();
|
||||
b[0] = a[0] * a[0];
|
||||
b
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut a: M = [1, 1];
|
||||
a = f(&a);
|
||||
assert_eq!(a[0], 1);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user