Auto merge of #74717 - davidtwco:issue-74636-polymorphized-closures-inherited-params, r=oli-obk

mir: add `used_generic_parameters_needs_subst`

Fixes #74636.

This PR adds a `used_generic_parameters_needs_subst` helper function which checks whether a type needs substitution, but only for parameters that the `unused_generic_params` query considers used. This is used in the MIR interpreter to make the check for some pointer casts and for reflection intrinsics more precise.

I've opened this as a draft PR because this might not be the approach we want to fix this issue and we have to decide what to do about the reflection case.

r? @eddyb
cc @lcnr @wesleywiser
This commit is contained in:
bors 2020-08-01 02:48:34 +00:00
commit 22e6099330
7 changed files with 108 additions and 20 deletions

View file

@ -1,3 +1,4 @@
// compile-flags:-Zpolymorphize=on
// build-pass
fn test<T>() {

View file

@ -0,0 +1,16 @@
// compile-flags:-Zpolymorphize=on
// build-pass
use std::any::TypeId;
pub fn foo<T: 'static>(_: T) -> TypeId {
TypeId::of::<T>()
}
fn outer<T: 'static>() {
foo(|| ());
}
fn main() {
outer::<u8>();
}