Skip to content

Commit

Permalink
Rollup merge of #126077 - oli-obk:revert_is_mir_available, r=BoxyUwU
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
matthiaskrgr authored Jun 7, 2024
2 parents 4aceaaa + 9461852 commit 2e82d7f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ fn remap_mir_for_const_eval_select<'tcx>(
}

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
Expand Down
11 changes: 8 additions & 3 deletions tests/ui-fulldeps/stable-mir/check_instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn test_stable_mir() -> ControlFlow<()> {
// Get all items and split generic vs monomorphic items.
let (generic, mono): (Vec<_>, Vec<_>) =
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");

// For all monomorphic items, get the correspondent instances.
Expand All @@ -57,8 +57,9 @@ fn test_body(body: mir::Body) {
for term in body.blocks.iter().map(|bb| &bb.terminator) {
match &term.kind {
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 instance = Instance::resolve(def, &args).unwrap();
let mangled_name = instance.mangled_name();
Expand Down Expand Up @@ -102,6 +103,9 @@ fn generate_input(path: &str) -> std::io::Result<()> {
write!(
file,
r#"
struct Foo(());
pub fn ty_param<T>(t: &T) -> T where T: Clone {{
t.clone()
}}
Expand All @@ -116,6 +120,7 @@ fn generate_input(path: &str) -> std::io::Result<()> {
}}
pub fn monomorphic() {{
Foo(());
let v = vec![10];
let dup = ty_param(&v);
assert_eq!(v, dup);
Expand Down

0 comments on commit 2e82d7f

Please sign in to comment.