Skip to content

Commit 96d0f43

Browse files
Don't ICE when encountering asm sym with regions
1 parent 959b2c7 commit 96d0f43

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

compiler/rustc_borrowck/src/universal_regions.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use rustc_data_structures::fx::FxHashMap;
1616
use rustc_errors::Diagnostic;
1717
use rustc_hir as hir;
18+
use rustc_hir::def::DefKind;
1819
use rustc_hir::def_id::{DefId, LocalDefId};
1920
use rustc_hir::lang_items::LangItem;
2021
use rustc_hir::BodyOwnerKind;
@@ -711,7 +712,13 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
711712
// For a constant body, there are no inputs, and one
712713
// "output" (the type of the constant).
713714
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+
if tcx.def_kind(tcx.parent(def_id)) == DefKind::GlobalAsm {
717+
ty = tcx.fold_regions(ty, |re, _| {
718+
assert_eq!(re, tcx.lifetimes.re_erased);
719+
tcx.lifetimes.re_static
720+
});
721+
}
715722
let ty = indices.fold_to_region_vids(tcx, ty);
716723
ty::Binder::dummy(tcx.mk_type_list(&[ty]))
717724
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// build-pass
2+
3+
core::arch::global_asm!("/* {} */", sym <&'static ()>::clone);
4+
5+
fn main() {}

0 commit comments

Comments
 (0)