Obtain an extended context from `TyCtxt`.
(tcx: TyCtxt<'tcx>)
| 223 | |
| 224 | /// Obtain an extended context from `TyCtxt`. |
| 225 | pub fn cx<'tcx, C: CallbacksExt>(tcx: TyCtxt<'tcx>) -> &'tcx C::ExtCtxt<'tcx> { |
| 226 | let tcx_addr = *tcx as *const _ as usize; |
| 227 | let guard = TCX_EXT_MAP.lock().unwrap(); |
| 228 | let cx = guard.get(&tcx_addr).unwrap(); |
| 229 | assert!(cx.is::<C::ExtCtxt<'static>>()); |
| 230 | // SAFETY: we have checked that the type actually matches. |
| 231 | unsafe { &*(&raw const **cx as *const C::ExtCtxt<'tcx>) } |
| 232 | } |
| 233 | |
| 234 | #[macro_export] |
| 235 | macro_rules! hook_query { |