use std::intrinsics::TypeId;
fn print_type_name<T:'static>(_val: T) {
println!("{}", TypeId::of::<T>());
}
fn main() {
print_type_name(|_name: &str| { // allows non 'static &str here
5i
});
}
// error: internal compiler error: non-static region found when hashing a type
Activity
Nercury commentedon Dec 13, 2014
Backtrace:
bkoropoff commentedon Dec 13, 2014
Well, this is interesting. It's broken all the way back to 0.10. I think it's been a bug in the type id implementation since it first landed. Here's a smaller test case:
bkoropoff commentedon Dec 13, 2014
@alexcrichton, is there a particular reason
hash_crate_independentexplicitly checks that all regions it encounters are'static? Trans doesn't seem to go out of its way to erase late-bound regions in fn type signatures, which results in this ICE. I could add a call tonormalize_tyin trans to fix this, but it would be cheaper to just ignore regions during hashing.[-]ICE: when non-static &str argument is allowed for closure used as static generic type[/-][+]ICE: when non-static &str argument is encountered by TypeId[/+]alexcrichton commentedon Dec 13, 2014
Ended up catching me on IRC
bkoropoff commentedon Dec 13, 2014
It seems we actually want to take late-bound regions into account when hashing. For example, the following should hold: