don't drop types with no drop glue when tailcalling
this is required as otherwise drops of `&mut` refs count as a usage of a 'two-phase temporary' causing an ICE.
This commit is contained in:
parent
99768c80a1
commit
af2ce8b702
10 changed files with 12 additions and 12 deletions
|
@ -785,6 +785,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
let local =
|
||||
place.as_local().unwrap_or_else(|| bug!("projection in tail call args"));
|
||||
|
||||
if !self.local_decls[local].ty.needs_drop(self.tcx, self.typing_env()) {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(DropData { source_info, local, kind: DropKind::Value })
|
||||
}
|
||||
Operand::Constant(_) => None,
|
||||
|
@ -795,6 +799,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
self.scopes.scopes.iter().rev().nth(1).unwrap().region_scope,
|
||||
DUMMY_SP,
|
||||
);
|
||||
let typing_env = self.typing_env();
|
||||
let unwind_drops = &mut self.scopes.unwind_drops;
|
||||
|
||||
// the innermost scope contains only the destructors for the tail call arguments
|
||||
|
@ -805,6 +810,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
let source_info = drop_data.source_info;
|
||||
let local = drop_data.local;
|
||||
|
||||
if !self.local_decls[local].ty.needs_drop(self.tcx, typing_env) {
|
||||
continue;
|
||||
}
|
||||
|
||||
match drop_data.kind {
|
||||
DropKind::Value => {
|
||||
// `unwind_to` should drop the value that we're about to
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue