| 101 | } |
| 102 | |
| 103 | fn after_analysis<'tcx>(&mut self, compiler: &Compiler, tcx: TyCtxt<'tcx>) -> Compilation { |
| 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 |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | pub struct BackendWrapper<C> { |