Change:
While trying to build a test for , I renamed my test file and it stopped ICEing. I have no idea what's happening here. Create a file with this contents called Then This compiles fine: But this ICEs:
We skip calling by comparing def-path hashes. The def-path hash provides a total order on MIR bodies that respects incremental compilation, and avoids a potentially costly query. OTOH, it depends on the crate name, which is the file name in your example. If you add a somewhere, that should be reproducible.
Setting the crate name would stabilize this for now, but any change to the hash algorithm could cause this test to suddenly pass, even if the compiler regresses in its behavior. Is there a way around that problem?
As someone who has changed the hash algorithm before, a comment in the file that says you might have to fiddle with the crate name to find something where that check works (including a link to this issue) might be enough if there's no other option.
I'm not concerned about the test suddenly failing, I'm concerned about it suddenly passing when it shouldn't.
I can't reproduce the MCVE in your opening comment. However, if I rename the file to then it emits an ICE (which I suspect is the same you reported here, is it? <details</detailsTo summarize: :heavycheckmark: :heavycheckmark: :skull: I'm really puzzled. Any idea? :thinking: EDIT: worth mentioning I'm on the latest nightly:
For testing purposes? Repeat the test a number of times to ensure that it is unlikely that it will pass by an accident.
Yes, that is the ICE in question, and your difficulty in reproducing this underscores the problem here. Any ICE that relies on MIR inlining within a crate (as opposed to inlining a function from another crate) may stop reproducing basically at any time. I believe this is the same reason that bisects to unrelated commits.

Discussion:
let is_fn_like = tcx.def_kind(def).is_fn_like(); if is_fn_like { // Do not compute the mir call graph without said call graph actually being used. <del> if inline::Inline.is_enabled(&tcx.sess) { </del> <ins> if pm::should_run_pass(tcx, &inline::Inline) { </ins> tcx.ensure_with_value().mir_inliner_callees(ty::InstanceDef::Item(def.to_def_id())); } }

run_passes_inner(tcx, body, passes, phase_change, true); } <ins> pub fn should_run_pass<'tcx, P>(tcx: TyCtxt<'tcx>, pass: &P) -> bool where P: MirPass<'tcx> + ?Sized, { let name = pass.name(); let overridden_passes = &tcx.sess.opts.unstable_opts.mir_enable_passes; let overridden = overridden_passes.iter().rev().find(|(s, _)| s == &*name).map(|(_name, polarity)| { trace!( pass = %name, "{} as requested by flag", if *polarity { "Running" } else { "Not running" }, ); *polarity }); overridden.unwrap_or_else(|| pass.is_enabled(&tcx.sess)) } </ins> fn run_passes_inner<'tcx>( tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>,

for pass in passes { let name = pass.name(); <del> let overridden = overridden_passes.iter().rev().find(|(s, _)| s == &*name).map( |(_name, polarity)| { trace!( pass = %name, "{} as requested by flag", if *polarity { "Running" } else { "Not running" }, ); *polarity }, ); if !overridden.unwrap_or_else(|| pass.is_enabled(&tcx.sess)) { </del> <ins> if !should_run_pass(tcx, *pass) { </ins> continue; <del> } </del> <ins> }; </ins> let dump_enabled = pass.is_mir_dump_enabled();

<ins> // Check that `-Zmir-enable-passes=+Inline` does not ICE because of stolen MIR. // unit-test: Inline // skip-filecheck #![crate_type = "lib"] // Randomize `def_path_hash` by defining them under a module with different names macro_rules! emit { ($($m:ident)*) => {$( pub mod $m { pub fn main() { let func = || 123u8; func(); } } )*}; } // Increase the chance of triggering the bug emit!(m00 m01 m02 m03 m04 m05 m06 m07 m08 m09 m10 m11 m12 m13 m14 m15 m16 m17 m18 m19); </ins>