diff options
| author | bors <bors@rust-lang.org> | 2022-10-21 10:21:17 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-10-21 10:21:17 +0000 |
| commit | befc94e691ae36c2fad134e1cdf483b7bdeeb74f (patch) | |
| tree | 295eb20dddee89560f4e67c9fc14937611688207 /compiler/rustc_mir_transform/src/inline.rs | |
| parent | 53e357748675b387b6d25fe563b960cb7a7a0aea (diff) | |
| parent | bb911ce32aeef2d691af993d0a1696d8402998a9 (diff) | |
| download | rust-befc94e691ae36c2fad134e1cdf483b7bdeeb74f.tar.gz rust-befc94e691ae36c2fad134e1cdf483b7bdeeb74f.zip | |
Auto merge of #2607 - RalfJung:rustup, r=RalfJung
Rustup
Diffstat (limited to 'compiler/rustc_mir_transform/src/inline.rs')
| -rw-r--r-- | compiler/rustc_mir_transform/src/inline.rs | 46 |
1 files changed, 20 insertions, 26 deletions
diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs index b60bd3cea23..780b91d9215 100644 --- a/compiler/rustc_mir_transform/src/inline.rs +++ b/compiler/rustc_mir_transform/src/inline.rs @@ -605,7 +605,7 @@ impl<'tcx> Inliner<'tcx> { caller_body.required_consts.extend( callee_body.required_consts.iter().copied().filter(|&ct| match ct.literal { ConstantKind::Ty(_) => { - bug!("should never encounter ty::Unevaluated in `required_consts`") + bug!("should never encounter ty::UnevaluatedConst in `required_consts`") } ConstantKind::Val(..) | ConstantKind::Unevaluated(..) => true, }), @@ -977,6 +977,21 @@ impl Integrator<'_, '_> { trace!("mapping block `{:?}` to `{:?}`", block, new); new } + + fn map_unwind(&self, unwind: Option<BasicBlock>) -> Option<BasicBlock> { + if self.in_cleanup_block { + if unwind.is_some() { + bug!("cleanup on cleanup block"); + } + return unwind; + } + + match unwind { + Some(target) => Some(self.map_block(target)), + // Add an unwind edge to the original call's cleanup block + None => self.cleanup_block, + } + } } impl<'tcx> MutVisitor<'tcx> for Integrator<'_, 'tcx> { @@ -1085,35 +1100,17 @@ impl<'tcx> MutVisitor<'tcx> for Integrator<'_, 'tcx> { TerminatorKind::Drop { ref mut target, ref mut unwind, .. } | TerminatorKind::DropAndReplace { ref mut target, ref mut unwind, .. } => { *target = self.map_block(*target); - if let Some(tgt) = *unwind { - *unwind = Some(self.map_block(tgt)); - } else if !self.in_cleanup_block { - // Unless this drop is in a cleanup block, add an unwind edge to - // the original call's cleanup block - *unwind = self.cleanup_block; - } + *unwind = self.map_unwind(*unwind); } TerminatorKind::Call { ref mut target, ref mut cleanup, .. } => { if let Some(ref mut tgt) = *target { *tgt = self.map_block(*tgt); } - if let Some(tgt) = *cleanup { - *cleanup = Some(self.map_block(tgt)); - } else if !self.in_cleanup_block { - // Unless this call is in a cleanup block, add an unwind edge to - // the original call's cleanup block - *cleanup = self.cleanup_block; - } + *cleanup = self.map_unwind(*cleanup); } TerminatorKind::Assert { ref mut target, ref mut cleanup, .. } => { *target = self.map_block(*target); - if let Some(tgt) = *cleanup { - *cleanup = Some(self.map_block(tgt)); - } else if !self.in_cleanup_block { - // Unless this assert is in a cleanup block, add an unwind edge to - // the original call's cleanup block - *cleanup = self.cleanup_block; - } + *cleanup = self.map_unwind(*cleanup); } TerminatorKind::Return => { terminator.kind = if let Some(tgt) = self.callsite.target { @@ -1141,11 +1138,8 @@ impl<'tcx> MutVisitor<'tcx> for Integrator<'_, 'tcx> { TerminatorKind::InlineAsm { ref mut destination, ref mut cleanup, .. } => { if let Some(ref mut tgt) = *destination { *tgt = self.map_block(*tgt); - } else if !self.in_cleanup_block { - // Unless this inline asm is in a cleanup block, add an unwind edge to - // the original call's cleanup block - *cleanup = self.cleanup_block; } + *cleanup = self.map_unwind(*cleanup); } } } |
