Skip to content

Commit

Permalink
Don't ICE when encountering asm sym with regions
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Sep 23, 2023
1 parent 959b2c7 commit 96d0f43
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 8 additions & 1 deletion compiler/rustc_borrowck/src/universal_regions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::Diagnostic;
use rustc_hir as hir;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::lang_items::LangItem;
use rustc_hir::BodyOwnerKind;
Expand Down Expand Up @@ -711,7 +712,13 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
// For a constant body, there are no inputs, and one
// "output" (the type of the constant).
assert_eq!(self.mir_def.to_def_id(), def_id);
let ty = tcx.type_of(self.mir_def).instantiate_identity();
let mut ty = tcx.type_of(self.mir_def).instantiate_identity();
if tcx.def_kind(tcx.parent(def_id)) == DefKind::GlobalAsm {
ty = tcx.fold_regions(ty, |re, _| {
assert_eq!(re, tcx.lifetimes.re_erased);
tcx.lifetimes.re_static
});
}
let ty = indices.fold_to_region_vids(tcx, ty);
ty::Binder::dummy(tcx.mk_type_list(&[ty]))
}
Expand Down
5 changes: 5 additions & 0 deletions tests/ui/asm/global-asm-with-regions-in-sym.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// build-pass

core::arch::global_asm!("/* {} */", sym <&'static ()>::clone);

fn main() {}

0 comments on commit 96d0f43

Please sign in to comment.