about summary refs log tree commit diff
path: root/src/test/ui/polymorphization
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-08-01 02:48:34 +0000
committerbors <bors@rust-lang.org>2020-08-01 02:48:34 +0000
commit22e6099330cde0e7b1529774fe27874f8326de7a (patch)
tree64aab0e950abc22324e65bee68b7f36e44bc2824 /src/test/ui/polymorphization
parentb544b43b10fa64f2f09e7e265a2bb7c624535c8e (diff)
parent59e621c1969fb03c5d367e9c713c0279461e772f (diff)
downloadrust-22e6099330cde0e7b1529774fe27874f8326de7a.tar.gz
rust-22e6099330cde0e7b1529774fe27874f8326de7a.zip
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
Diffstat (limited to 'src/test/ui/polymorphization')
-rw-r--r--src/test/ui/polymorphization/issue-74636.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/test/ui/polymorphization/issue-74636.rs b/src/test/ui/polymorphization/issue-74636.rs
new file mode 100644
index 00000000000..4c532f451e3
--- /dev/null
+++ b/src/test/ui/polymorphization/issue-74636.rs
@@ -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>();
+}