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:
commit
22e6099330
7 changed files with 108 additions and 20 deletions
|
|
@ -1,3 +1,4 @@
|
|||
// compile-flags:-Zpolymorphize=on
|
||||
// build-pass
|
||||
|
||||
fn test<T>() {
|
||||
|
|
|
|||
16
src/test/ui/polymorphization/issue-74636.rs
Normal file
16
src/test/ui/polymorphization/issue-74636.rs
Normal 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>();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue