This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
compiler/rustc_mir/src/transform/check_consts Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -79,14 +79,20 @@ impl Visitor<'tcx> for CheckLiveDrops<'mir, 'tcx> {
7979 mir:: TerminatorKind :: Drop { place : dropped_place, .. } => {
8080 let dropped_ty = dropped_place. ty ( self . body , self . tcx ) . ty ;
8181 if !NeedsDrop :: in_any_value_of_ty ( self . ccx , dropped_ty) {
82- return ;
82+ bug ! (
83+ "Drop elaboration left behind a Drop for a type that does not need dropping"
84+ ) ;
8385 }
8486
8587 if dropped_place. is_indirect ( ) {
8688 self . check_live_drop ( terminator. source_info . span ) ;
8789 return ;
8890 }
8991
92+ // Drop elaboration is not precise enough to accept code like
93+ // `src/test/ui/consts/control-flow/drop-pass.rs`; e.g., when an `Option<Vec<T>>` is
94+ // initialized with `None` and never changed, it still emits drop glue.
95+ // Hence we additionally check the qualifs here to allow more code to pass.
9096 if self . qualifs . needs_drop ( self . ccx , dropped_place. local , location) {
9197 // Use the span where the dropped local was declared for the error.
9298 let span = self . body . local_decls [ dropped_place. local ] . source_info . span ;
You can’t perform that action at this time.
0 commit comments