diff options
| author | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2020-10-04 10:39:12 -0700 |
|---|---|---|
| committer | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2020-10-04 10:41:08 -0700 |
| commit | 25fdbaff444580bb07783861579653bf81657f5b (patch) | |
| tree | 05c8dbc273808c6ff092fc681fc808f405e616a4 | |
| parent | 14c3705c6cfc5f88ba64e00129c99cc1f8a41490 (diff) | |
| download | rust-25fdbaff444580bb07783861579653bf81657f5b.tar.gz rust-25fdbaff444580bb07783861579653bf81657f5b.zip | |
Discuss cleanup blocks and `span_bug` on `Abort`
| -rw-r--r-- | compiler/rustc_mir/src/transform/check_consts/validation.rs | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/compiler/rustc_mir/src/transform/check_consts/validation.rs b/compiler/rustc_mir/src/transform/check_consts/validation.rs index ab78e3d541c..cb9feba260f 100644 --- a/compiler/rustc_mir/src/transform/check_consts/validation.rs +++ b/compiler/rustc_mir/src/transform/check_consts/validation.rs @@ -434,11 +434,13 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> { fn visit_basic_block_data(&mut self, bb: BasicBlock, block: &BasicBlockData<'tcx>) { trace!("visit_basic_block_data: bb={:?} is_cleanup={:?}", bb, block.is_cleanup); - // Just as the old checker did, we skip const-checking basic blocks on the unwind path. - // These blocks often drop locals that would otherwise be returned from the function. + // We don't const-check basic blocks on the cleanup path since we never unwind during + // const-eval: a panic causes an immediate compile error. In other words, cleanup blocks + // are unreachable during const-eval. // - // FIXME: This shouldn't be unsound since a panic at compile time will cause a compiler - // error anyway, but maybe we should do more here? + // We can't be more conservative (e.g., by const-checking cleanup blocks anyways) because + // locals that would never be dropped during normal execution are sometimes dropped during + // unwinding, which means backwards-incompatible live-drop errors. if block.is_cleanup { return; } @@ -879,8 +881,11 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> { self.check_op(ops::Generator(hir::GeneratorKind::Gen)) } - TerminatorKind::Abort - | TerminatorKind::Assert { .. } + TerminatorKind::Abort => { + span_bug!(self.span, "`Abort` terminator outside of cleanup block") + } + + TerminatorKind::Assert { .. } | TerminatorKind::FalseEdge { .. } | TerminatorKind::FalseUnwind { .. } | TerminatorKind::Goto { .. } |
