-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
mir: add used_generic_parameters_needs_subst
#74717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mir: add used_generic_parameters_needs_subst
#74717
Conversation
|
r? @oli-obk I got a crash course in polymorphization magic in https://rust-lang.zulipchat.com/#narrow/stream/216091-t-compiler.2Fwg-polymorphization/topic/tokio.20regression.20%28.2374614%29/near/205594913 |
This commit adds a `ensure_monomorphic_enough` utility function which checks whether a type needs substitution, but only for parameters that the `unused_generic_params` query considers used. `ensure_monomorphic_enough` is then used throughout interpret where `needs_subst` checks previously existed (in particular, for some pointer casts and for reflection intrinsics more precise). Signed-off-by: David Wood <[email protected]>
4d1d988 to
59e621c
Compare
|
cc @rust-lang/wg-const-eval @bors r+ |
|
📌 Commit 59e621c has been approved by |
|
☀️ Test successful - checks-actions, checks-azure |
…optimisations, r=lcnr polymorphization: various improvements This PR includes a handful of polymorphisation-related changes: - @Mark-Simulacrum's suggestions [from this comment](rust-lang#74633 (comment)): - Use a `FiniteBitSet<u32>` over a `FiniteBitSet<u64>` as most functions won't have 64 generic parameters. - Don't encode polymorphisation results in metadata when every parameter is used (in this case, just invoking polymorphisation will probably be quicker). - @lcnr's suggestion [from this comment](rust-lang#74717 (comment)). - Add an debug assertion in `ensure_monomorphic_enough` to make sure that polymorphisation did what we expect. r? @lcnr
Fixes #74636.
This PR adds a
used_generic_parameters_needs_substhelper function which checks whether a type needs substitution, but only for parameters that theunused_generic_paramsquery 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