|
15 | 15 | use rustc_data_structures::fx::FxHashMap; |
16 | 16 | use rustc_errors::Diagnostic; |
17 | 17 | use rustc_hir as hir; |
| 18 | +use rustc_hir::def::DefKind; |
18 | 19 | use rustc_hir::def_id::{DefId, LocalDefId}; |
19 | 20 | use rustc_hir::lang_items::LangItem; |
20 | 21 | use rustc_hir::BodyOwnerKind; |
@@ -711,7 +712,17 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> { |
711 | 712 | // For a constant body, there are no inputs, and one |
712 | 713 | // "output" (the type of the constant). |
713 | 714 | assert_eq!(self.mir_def.to_def_id(), def_id); |
714 | | - let ty = tcx.type_of(self.mir_def).instantiate_identity(); |
| 715 | + let mut ty = tcx.type_of(self.mir_def).instantiate_identity(); |
| 716 | + // `SymFn` in global asm may only reference `'static`, but those |
| 717 | + // regions are erased as part of computing the type of the anon |
| 718 | + // const. Put them back, since the `UniversalRegionsBuilder` is |
| 719 | + // not setup to handle erased regions. |
| 720 | + if tcx.def_kind(tcx.parent(def_id)) == DefKind::GlobalAsm { |
| 721 | + ty = tcx.fold_regions(ty, |re, _| { |
| 722 | + assert_eq!(re, tcx.lifetimes.re_erased); |
| 723 | + tcx.lifetimes.re_static |
| 724 | + }); |
| 725 | + } |
715 | 726 | let ty = indices.fold_to_region_vids(tcx, ty); |
716 | 727 | ty::Binder::dummy(tcx.mk_type_list(&[ty])) |
717 | 728 | } |
|
0 commit comments