Allow loading the SMIR for constants and statics
This commit is contained in:
parent
e39976ff89
commit
c2e790044c
@ -84,7 +84,7 @@ fn trait_impl(&mut self, impl_def: &stable_mir::ty::ImplDef) -> stable_mir::ty::
|
||||
|
||||
fn mir_body(&mut self, item: stable_mir::DefId) -> stable_mir::mir::Body {
|
||||
let def_id = self[item];
|
||||
let mir = self.tcx.optimized_mir(def_id);
|
||||
let mir = self.tcx.instance_mir(ty::InstanceDef::Item(def_id));
|
||||
stable_mir::mir::Body {
|
||||
blocks: mir
|
||||
.basic_blocks
|
||||
|
@ -154,6 +154,10 @@ fn test_stable_mir(tcx: TyCtxt<'_>) -> ControlFlow<()> {
|
||||
}
|
||||
}
|
||||
|
||||
let foo_const = get_item(tcx, &items, (DefKind::Const, "FOO")).unwrap();
|
||||
// Ensure we don't panic trying to get the body of a constant.
|
||||
foo_const.body();
|
||||
|
||||
ControlFlow::Continue(())
|
||||
}
|
||||
|
||||
@ -191,6 +195,8 @@ fn generate_input(path: &str) -> std::io::Result<()> {
|
||||
write!(
|
||||
file,
|
||||
r#"
|
||||
pub const FOO: u32 = 1 + 2;
|
||||
|
||||
fn generic<T, const U: usize>(t: T) -> [(); U] {{
|
||||
_ = t;
|
||||
[(); U]
|
||||
|
Loading…
Reference in New Issue
Block a user