Description
First, sorry that I can't pinpoint which change caused this ICE to pop up - but the best guess I can give is somewhere in the last 2 weeks - I just updated to a recent nightly over the weekend. This is still reproducible on master.
The following code produces an ICE:
use std::collections::HashMap;
use std::collections::hash_map::Entry::Vacant;
pub fn foo() {
type F = Box<Fn(&()) + 'static>;
let mut map: HashMap<(), F> = HashMap::new();
let x: &mut F = match map.entry(()) {
Vacant(_) => unimplemented!(),
_ => unimplemented!()
};
}
The error message is:
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'assertion failed: !ty::type_needs_infer(ty)', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/librustc_typeck/lib.rs:149
Obviously the unimplemented!()
code is just a placeholder, and the same issue occurs when the match statement is used as might be expected to get a mutable reference from an entry.
This is the smallest test case I have come up with. It seems to depend on the match statement existing with at least two arms and its result being used in some way, as well as the higher-ranked lifetime bound in the closure type F
.
This bug is really hindering a project I am working on.