diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2021-03-22 15:21:29 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-22 15:21:29 +0100 |
| commit | 1fdf7d18ad2f74ecb3e4a113ae3251bef4521e2c (patch) | |
| tree | 5bdd15819a15dd6d40275859ba5febad3fdec9ef | |
| parent | b759044d3a035c77b1b57c652ea3707bb32386cf (diff) | |
| parent | 4e7f1fa14fe54c20eb583dbf40efe3284d48a3b0 (diff) | |
| download | rust-1fdf7d18ad2f74ecb3e4a113ae3251bef4521e2c.tar.gz rust-1fdf7d18ad2f74ecb3e4a113ae3251bef4521e2c.zip | |
Rollup merge of #83351 - RalfJung:precise-const-drop, r=oli-obk
post-drop-elab check-const: explain why we still check qualifs r? `@oli-obk`
| -rw-r--r-- | compiler/rustc_mir/src/transform/check_consts/post_drop_elaboration.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler/rustc_mir/src/transform/check_consts/post_drop_elaboration.rs b/compiler/rustc_mir/src/transform/check_consts/post_drop_elaboration.rs index 1a2d932ba19..057092b8ef5 100644 --- a/compiler/rustc_mir/src/transform/check_consts/post_drop_elaboration.rs +++ b/compiler/rustc_mir/src/transform/check_consts/post_drop_elaboration.rs @@ -79,7 +79,9 @@ impl Visitor<'tcx> for CheckLiveDrops<'mir, 'tcx> { mir::TerminatorKind::Drop { place: dropped_place, .. } => { let dropped_ty = dropped_place.ty(self.body, self.tcx).ty; if !NeedsDrop::in_any_value_of_ty(self.ccx, dropped_ty) { - return; + bug!( + "Drop elaboration left behind a Drop for a type that does not need dropping" + ); } if dropped_place.is_indirect() { @@ -87,6 +89,10 @@ impl Visitor<'tcx> for CheckLiveDrops<'mir, 'tcx> { return; } + // Drop elaboration is not precise enough to accept code like + // `src/test/ui/consts/control-flow/drop-pass.rs`; e.g., when an `Option<Vec<T>>` is + // initialized with `None` and never changed, it still emits drop glue. + // Hence we additionally check the qualifs here to allow more code to pass. if self.qualifs.needs_drop(self.ccx, dropped_place.local, location) { // Use the span where the dropped local was declared for the error. let span = self.body.local_decls[dropped_place.local].source_info.span; |
