Rollup merge of #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 e5cba17b84.

turns out SMIR still needs it (https://github.com/model-checking/kani/issues/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.
This commit is contained in:
Matthias Krüger 2024-06-07 20:14:31 +02:00 committed by GitHub
commit 2e82d7f569
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 4 deletions

View File

@ -211,7 +211,7 @@ fn remap_mir_for_const_eval_select<'tcx>(
} }
fn is_mir_available(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool { fn is_mir_available(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
tcx.hir().maybe_body_owned_by(def_id).is_some() tcx.mir_keys(()).contains(&def_id)
} }
/// Finds the full set of `DefId`s within the current crate that have /// Finds the full set of `DefId`s within the current crate that have

View File

@ -33,7 +33,7 @@ fn test_stable_mir() -> ControlFlow<()> {
// Get all items and split generic vs monomorphic items. // Get all items and split generic vs monomorphic items.
let (generic, mono): (Vec<_>, Vec<_>) = let (generic, mono): (Vec<_>, Vec<_>) =
items.into_iter().partition(|item| item.requires_monomorphization()); items.into_iter().partition(|item| item.requires_monomorphization());
assert_eq!(mono.len(), 3, "Expected 2 mono functions and one constant"); assert_eq!(mono.len(), 4, "Expected 2 mono functions and one constant");
assert_eq!(generic.len(), 2, "Expected 2 generic functions"); assert_eq!(generic.len(), 2, "Expected 2 generic functions");
// For all monomorphic items, get the correspondent instances. // For all monomorphic items, get the correspondent instances.
@ -57,8 +57,9 @@ fn test_body(body: mir::Body) {
for term in body.blocks.iter().map(|bb| &bb.terminator) { for term in body.blocks.iter().map(|bb| &bb.terminator) {
match &term.kind { match &term.kind {
Call { func, .. } => { Call { func, .. } => {
let TyKind::RigidTy(ty) = func.ty(body.locals()).unwrap().kind() else { unreachable! let TyKind::RigidTy(ty) = func.ty(body.locals()).unwrap().kind() else {
() }; unreachable!()
};
let RigidTy::FnDef(def, args) = ty else { unreachable!() }; let RigidTy::FnDef(def, args) = ty else { unreachable!() };
let instance = Instance::resolve(def, &args).unwrap(); let instance = Instance::resolve(def, &args).unwrap();
let mangled_name = instance.mangled_name(); let mangled_name = instance.mangled_name();
@ -102,6 +103,9 @@ fn generate_input(path: &str) -> std::io::Result<()> {
write!( write!(
file, file,
r#" r#"
struct Foo(());
pub fn ty_param<T>(t: &T) -> T where T: Clone {{ pub fn ty_param<T>(t: &T) -> T where T: Clone {{
t.clone() t.clone()
}} }}
@ -116,6 +120,7 @@ pub fn ty_param<T>(t: &T) -> T where T: Clone {{
}} }}
pub fn monomorphic() {{ pub fn monomorphic() {{
Foo(());
let v = vec![10]; let v = vec![10];
let dup = ty_param(&v); let dup = ty_param(&v);
assert_eq!(v, dup); assert_eq!(v, dup);