Don't extend lifetime of temp in Repeat
expressions
This commit is contained in:
parent
d6431f69ad
commit
420457e5ca
1 changed files with 11 additions and 18 deletions
|
@ -1065,30 +1065,23 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
|
||||||
} else {
|
} else {
|
||||||
self.valid_promotion_candidates()
|
self.valid_promotion_candidates()
|
||||||
};
|
};
|
||||||
|
|
||||||
debug!("qualify_const: promotion_candidates={:?}", promotion_candidates);
|
debug!("qualify_const: promotion_candidates={:?}", promotion_candidates);
|
||||||
for candidate in promotion_candidates {
|
for candidate in promotion_candidates {
|
||||||
let promoted_place = match candidate {
|
match candidate {
|
||||||
Candidate::Repeat(Location { block: bb, statement_index: stmt_idx }) => {
|
|
||||||
match &self.body[bb].statements[stmt_idx].kind {
|
|
||||||
StatementKind::Assign(box(_, Rvalue::Repeat(Operand::Move(place), _)))
|
|
||||||
=> place,
|
|
||||||
_ => continue,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Candidate::Ref(Location { block: bb, statement_index: stmt_idx }) => {
|
Candidate::Ref(Location { block: bb, statement_index: stmt_idx }) => {
|
||||||
match &self.body[bb].statements[stmt_idx].kind {
|
if let StatementKind::Assign(box( _, Rvalue::Ref(_, _, place)))
|
||||||
StatementKind::Assign(box( _, Rvalue::Ref(_, _, place))) => place,
|
= &self.body[bb].statements[stmt_idx].kind
|
||||||
_ => continue,
|
{
|
||||||
|
if let PlaceBase::Local(local) = place.base {
|
||||||
|
promoted_temps.insert(local);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Candidate::Argument { .. } => continue,
|
|
||||||
};
|
|
||||||
|
|
||||||
match promoted_place.base {
|
// Only rvalue-static promotion requires extending the lifetime of the promoted
|
||||||
PlaceBase::Local(local) if !promoted_place.is_indirect() => {
|
// local.
|
||||||
promoted_temps.insert(local);
|
Candidate::Argument { .. } | Candidate::Repeat(_) => {}
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue