Skip to content
/ rust Public
forked from rust-lang/rust

Commit 2e82d7f

Browse files
authored
Rollup merge of rust-lang#126077 - oli-obk:revert_is_mir_available, r=BoxyUwU
Revert "Use the HIR instead of mir_keys for determining whether something will have a MIR body." This reverts commit e5cba17. turns out SMIR still needs it (model-checking/kani#3218). I'll create a full plan and MCP for what I intended this to be a part of. Maybe my plan is nonsense anyway.
2 parents 4aceaaa + 9461852 commit 2e82d7f

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

compiler/rustc_mir_transform/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ fn remap_mir_for_const_eval_select<'tcx>(
211211
}
212212

213213
fn is_mir_available(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
214-
tcx.hir().maybe_body_owned_by(def_id).is_some()
214+
tcx.mir_keys(()).contains(&def_id)
215215
}
216216

217217
/// Finds the full set of `DefId`s within the current crate that have

tests/ui-fulldeps/stable-mir/check_instance.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ fn test_stable_mir() -> ControlFlow<()> {
3333
// Get all items and split generic vs monomorphic items.
3434
let (generic, mono): (Vec<_>, Vec<_>) =
3535
items.into_iter().partition(|item| item.requires_monomorphization());
36-
assert_eq!(mono.len(), 3, "Expected 2 mono functions and one constant");
36+
assert_eq!(mono.len(), 4, "Expected 2 mono functions and one constant");
3737
assert_eq!(generic.len(), 2, "Expected 2 generic functions");
3838

3939
// For all monomorphic items, get the correspondent instances.
@@ -57,8 +57,9 @@ fn test_body(body: mir::Body) {
5757
for term in body.blocks.iter().map(|bb| &bb.terminator) {
5858
match &term.kind {
5959
Call { func, .. } => {
60-
let TyKind::RigidTy(ty) = func.ty(body.locals()).unwrap().kind() else { unreachable!
61-
() };
60+
let TyKind::RigidTy(ty) = func.ty(body.locals()).unwrap().kind() else {
61+
unreachable!()
62+
};
6263
let RigidTy::FnDef(def, args) = ty else { unreachable!() };
6364
let instance = Instance::resolve(def, &args).unwrap();
6465
let mangled_name = instance.mangled_name();
@@ -102,6 +103,9 @@ fn generate_input(path: &str) -> std::io::Result<()> {
102103
write!(
103104
file,
104105
r#"
106+
107+
struct Foo(());
108+
105109
pub fn ty_param<T>(t: &T) -> T where T: Clone {{
106110
t.clone()
107111
}}
@@ -116,6 +120,7 @@ fn generate_input(path: &str) -> std::io::Result<()> {
116120
}}
117121
118122
pub fn monomorphic() {{
123+
Foo(());
119124
let v = vec![10];
120125
let dup = ty_param(&v);
121126
assert_eq!(v, dup);

0 commit comments

Comments
 (0)