Make dest_needs_borrow iterate instead of recurse
This commit is contained in:
parent
4dbc7f96d6
commit
b922e8a97d
1 changed files with 13 additions and 10 deletions
|
@ -440,19 +440,22 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
|
||||||
// writes to `i`. To prevent this we need to create a temporary
|
// writes to `i`. To prevent this we need to create a temporary
|
||||||
// borrow of the place and pass the destination as `*temp` instead.
|
// borrow of the place and pass the destination as `*temp` instead.
|
||||||
fn dest_needs_borrow(place: &Place<'_>) -> bool {
|
fn dest_needs_borrow(place: &Place<'_>) -> bool {
|
||||||
match *place {
|
place.iterate(|place_base, place_projection| {
|
||||||
Place::Projection(ref p) => {
|
for proj in place_projection {
|
||||||
match p.elem {
|
match proj.elem {
|
||||||
ProjectionElem::Deref |
|
ProjectionElem::Deref |
|
||||||
ProjectionElem::Index(_) => true,
|
ProjectionElem::Index(_) => return true,
|
||||||
_ => dest_needs_borrow(&p.base)
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
match place_base {
|
||||||
// Static variables need a borrow because the callee
|
// Static variables need a borrow because the callee
|
||||||
// might modify the same static.
|
// might modify the same static.
|
||||||
Place::Base(PlaceBase::Static(_)) => true,
|
PlaceBase::Static(_) => true,
|
||||||
_ => false
|
_ => false
|
||||||
}
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let dest = if dest_needs_borrow(&destination.0) {
|
let dest = if dest_needs_borrow(&destination.0) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue