File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -101,7 +101,19 @@ impl<C: CallbacksExt> Callbacks for CallbackWrapper<C> {
101101 }
102102
103103 fn after_analysis < ' tcx > ( & mut self , compiler : & Compiler , tcx : TyCtxt < ' tcx > ) -> Compilation {
104- self . callback . lock ( ) . unwrap ( ) . after_analysis ( compiler, tcx)
104+ let ret = self . callback . lock ( ) . unwrap ( ) . after_analysis ( compiler, tcx) ;
105+
106+ if tcx. sess . opts . unstable_opts . no_codegen || !tcx. sess . opts . output_types . should_codegen ( ) {
107+ // Normally we destory `cx` in `codegen_crate`. However when codegen is not happening,
108+ // that will not be invoked, and this is our last change to do cleanups.
109+ let tcx_addr = * tcx as * const _ as usize ;
110+ let cx = TCX_EXT_MAP . lock ( ) . unwrap ( ) . remove ( & tcx_addr) . unwrap ( ) ;
111+ assert ! ( cx. is:: <C :: ExtCtxt <' static >>( ) ) ;
112+ // SAFETY: we just check the (type-erased) type matches.
113+ drop ( unsafe { Box :: from_raw ( Box :: into_raw ( cx) as * mut C :: ExtCtxt < ' tcx > ) } ) ;
114+ }
115+
116+ ret
105117 }
106118}
107119
You can’t perform that action at this time.
0 commit comments