未验证 提交 1fdf7d18 编写于 作者: D Dylan DPC 提交者: GitHub

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`
......@@ -79,7 +79,9 @@ fn visit_terminator(&mut self, terminator: &mir::Terminator<'tcx>, location: Loc
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 @@ fn visit_terminator(&mut self, terminator: &mir::Terminator<'tcx>, location: Loc
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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册