diff options
| author | Santiago Pastorino <spastorino@gmail.com> | 2019-05-27 22:00:44 +0200 |
|---|---|---|
| committer | Santiago Pastorino <spastorino@gmail.com> | 2019-05-27 22:16:39 +0200 |
| commit | b922e8a97d12e2b10d918ee54ecd0bc99df050f2 (patch) | |
| tree | 70a2e32aa24b9e08493dd59b93994281728a54eb /src | |
| parent | 4dbc7f96d6438b93c9274675b276cfe934164704 (diff) | |
| download | rust-b922e8a97d12e2b10d918ee54ecd0bc99df050f2.tar.gz rust-b922e8a97d12e2b10d918ee54ecd0bc99df050f2.zip | |
Make dest_needs_borrow iterate instead of recurse
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_mir/transform/inline.rs | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/librustc_mir/transform/inline.rs b/src/librustc_mir/transform/inline.rs index 24ec3219a2e..782af3024ad 100644 --- a/src/librustc_mir/transform/inline.rs +++ b/src/librustc_mir/transform/inline.rs @@ -440,19 +440,22 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> { // writes to `i`. To prevent this we need to create a temporary // borrow of the place and pass the destination as `*temp` instead. fn dest_needs_borrow(place: &Place<'_>) -> bool { - match *place { - Place::Projection(ref p) => { - match p.elem { + place.iterate(|place_base, place_projection| { + for proj in place_projection { + match proj.elem { ProjectionElem::Deref | - ProjectionElem::Index(_) => true, - _ => dest_needs_borrow(&p.base) + ProjectionElem::Index(_) => return true, + _ => {} } } - // Static variables need a borrow because the callee - // might modify the same static. - Place::Base(PlaceBase::Static(_)) => true, - _ => false - } + + match place_base { + // Static variables need a borrow because the callee + // might modify the same static. + PlaceBase::Static(_) => true, + _ => false + } + }) } let dest = if dest_needs_borrow(&destination.0) { |
