File tree Expand file tree Collapse file tree
compiler/rustc_infer/src/infer Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -321,9 +321,11 @@ pub struct InferCtxt<'tcx> {
321321
322322impl < ' tcx > Drop for InferCtxt < ' tcx > {
323323 fn drop ( & mut self ) {
324- // Defuse the drop bomb in the OpaqueTypeStorage when we're in TypingMode::Borrowck,
325- // and the InferCtxt doesn't consider regions. This is okay since in `Borrowck`,
326- // the only reason we care about opaques is in relation to regions.
324+ let mut inner = self . inner . borrow_mut ( ) ;
325+ let opaque_type_storage = & mut inner. opaque_type_storage ;
326+
327+ // No need for the drop bomb when we're in TypingMode::Borrowck, and the InferCtxt doesn't consider regions.
328+ // This is okay since in `Borrowck`, the only reason we care about opaques is in relation to regions.
327329 // In some places *after* typeck, like in lints we use `TypingMode::Borrowck`
328330 // to prevent defining opaque types and we simply don't care about regions.
329331 match self . typing_mode ( ) {
@@ -333,10 +335,14 @@ impl<'tcx> Drop for InferCtxt<'tcx> {
333335 | TypingMode :: PostAnalysis => { }
334336 TypingMode :: Borrowck { .. } => {
335337 if !self . considering_regions {
336- let _ = self . inner . borrow_mut ( ) . opaque_type_storage . take_opaque_types ( ) ;
338+ return ;
337339 }
338340 }
339341 }
342+
343+ if !opaque_type_storage. is_empty ( ) {
344+ ty:: tls:: with ( |tcx| tcx. dcx ( ) . delayed_bug ( format ! ( "{opaque_type_storage:?}" ) ) ) ;
345+ }
340346 }
341347}
342348
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ use std::ops::Deref;
33use rustc_data_structures:: fx:: FxIndexMap ;
44use rustc_data_structures:: undo_log:: UndoLogs ;
55use rustc_middle:: bug;
6- use rustc_middle:: ty:: { self , OpaqueTypeKey , ProvisionalHiddenType , Ty } ;
6+ use rustc_middle:: ty:: { OpaqueTypeKey , ProvisionalHiddenType , Ty } ;
77use tracing:: instrument;
88
99use crate :: infer:: snapshot:: undo_log:: { InferCtxtUndoLogs , UndoLog } ;
@@ -121,14 +121,6 @@ impl<'tcx> OpaqueTypeStorage<'tcx> {
121121 }
122122}
123123
124- impl < ' tcx > Drop for OpaqueTypeStorage < ' tcx > {
125- fn drop ( & mut self ) {
126- if !self . is_empty ( ) {
127- ty:: tls:: with ( |tcx| tcx. dcx ( ) . delayed_bug ( format ! ( "{:?}" , self . opaque_types) ) ) ;
128- }
129- }
130- }
131-
132124pub struct OpaqueTypeTable < ' a , ' tcx > {
133125 storage : & ' a mut OpaqueTypeStorage < ' tcx > ,
134126
You can’t perform that action at this time.
0 commit comments