Repository navigation
Skip virtual dispatches when collecting default impl mono items - #158822
peterphitran wants to merge 2 commits into
Conversation
|
Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @TaKO8Ki (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
|
This PR changes a file inside |
|
☔ The latest upstream changes (presumably #159407) made this pull request unmergeable. Please resolve the merge conflicts by rebasing. |
|
@rustbot reroll |
|
@rustbot reroll |
|
r? oli-obk (or at least you might know someone specific that is able to review, instead of random chance) |
|
Please state how and where an LLM was used in the process of creating this PR |
Side note:
|
|
Since the PR change is rather trivial, and you predate the policy, I'll give it a shot, but if this results in you just running the LLM for me, then please just close the PR. Why do we land in this situation, but not for impls that are directly on |
Fixes #158411. Fixes #114198.
With -Clink-dead-code,
create_mono_items_for_default_implsresolves each inherited provided method of a trait impl. When the impl's self type normalizes to the trait's own object type (via a type alias or projection, which coherence accepts, see #57893), resolution picks the builtin object candidate and returnsInstanceKind::Virtual, which was pushed as a mono item and ICEd in instance_mir. This skips Virtual instances there, asvisit_instance_usealready does on the lazy path. Nothing reachable is lost: calls on dyn Trait always go through the vtable. Rejecting these impls instead would break tests/ui/traits/object/ambiguity-vtable-segfault.rs. Reproduces on nightly without feature gates (impl Trait for <Ty as Owner>::Structwith Struct = dyn Trait).Test plan (build-pass with -Clink-dead-code):