Skip to content

Rust: Unify call resolution logic#21355

Draft
hvitved wants to merge 2 commits intogithub:mainfrom
hvitved:rust/type-inference-unify
Draft

Rust: Unify call resolution logic#21355
hvitved wants to merge 2 commits intogithub:mainfrom
hvitved:rust/type-inference-unify

Conversation

@hvitved
Copy link
Contributor

@hvitved hvitved commented Feb 23, 2026

I was investigating a type inference performance issue on tayu0110/exml, and came up with a small reproduction case (first commit), which revealed that we are not correctly handling resolution of calls to non-method associated functions when the argument used to resolve the call has multiple trait bounds.

For method calls we are handling multiple trait bounds correctly since #21043, so the obvious solution would be to replicate this logic for non-method calls as well.

However, with #21217 we have:

As for calls to methods, we now also always check the Self type for calls to associated non-methods f.

which allows us to instead unify the resolution logic for calls to methods (module MethodResolution) and calls to non-methods (module NonMethodResolution) in a single implementation encompassing calls to all associated functions (module AssocFunctionResolution). Calls to non-associated functions does not rely on type inference (but instead on path resolution only), which is handled in the class NonAssocCallExpr.

Just like we can unify call resolution logic, we can also unify propagation of type information for resolved calls for calls to methods (module MethodCallMatching) and calls to non-methods (module NonMethodCallMatching) in a single implementation (module FunctionCallMatching), and type inference for tuple-like variant and struct constructions such as Option::Some(42) is then done in a separate module TupleLikeConstructionMatching.

LOC removed

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Feb 23, 2026
@hvitved hvitved force-pushed the rust/type-inference-unify branch from 46c92f3 to ed0c757 Compare February 23, 2026 18:17
@hvitved hvitved force-pushed the rust/type-inference-unify branch from 786d5bd to 9a87116 Compare February 23, 2026 21:01
@hvitved hvitved force-pushed the rust/type-inference-unify branch 4 times, most recently from 0eaade9 to 237b806 Compare February 25, 2026 07:49
@hvitved hvitved force-pushed the rust/type-inference-unify branch from 237b806 to b647e6f Compare February 25, 2026 08:44
@hvitved hvitved force-pushed the rust/type-inference-unify branch 7 times, most recently from 7bd16e0 to 331d5d5 Compare February 27, 2026 13:54
@hvitved hvitved force-pushed the rust/type-inference-unify branch 7 times, most recently from d7ac787 to eeb8264 Compare March 4, 2026 11:17
@hvitved hvitved force-pushed the rust/type-inference-unify branch 2 times, most recently from d7ac787 to eeb8264 Compare March 4, 2026 11:17
@hvitved hvitved force-pushed the rust/type-inference-unify branch 3 times, most recently from 9db7fbd to aca2ce0 Compare March 5, 2026 08:45
@hvitved hvitved force-pushed the rust/type-inference-unify branch 2 times, most recently from b4dd418 to 3e14fec Compare March 6, 2026 08:00
@hvitved hvitved force-pushed the rust/type-inference-unify branch from 3e14fec to 6a0ac3a Compare March 6, 2026 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant