Skip to content

Conversation

@hvitved
Copy link
Contributor

@hvitved hvitved commented Oct 23, 2025

Type propagation into arguments is needed in cases like

let x = Vec::new();
x.push(0); // the type `i32` must propagate into `x` to infer that `x` has type `Vec<i32>`

Up until now, we have unconditionally propagated types into all arguments, which can sometimes lead to explosions in inferred types.

This PR circumvents such explosions by only propagating type information into arguments when those arguments are potentially context-typed (such as Vec::new and Default::default).

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Oct 23, 2025
tp instanceof TSelfTypeParameter and
exists(getCallExprTypeQualifier(a, _))
)
) and

Check warning

Code scanning / CodeQL

Omittable 'exists' variable Warning

This exists variable can be omitted by using a don't-care expression
in this argument
.
@hvitved hvitved force-pushed the rust/type-inference-arg-target-typed branch 5 times, most recently from 9097870 to a5e8fdb Compare October 27, 2025 12:41
* argument/receiver of a method call.
*/
pragma[nomagic]
private Type inferMethodCallType(AstNode n, TypePath path) {

Check warning

Code scanning / CodeQL

Omittable 'exists' variable Warning

This exists variable can be omitted by using a don't-care expression
in this argument
.
@hvitved hvitved force-pushed the rust/type-inference-arg-target-typed branch 5 times, most recently from f4b6449 to e05b287 Compare October 31, 2025 09:15
@hvitved hvitved force-pushed the rust/type-inference-arg-target-typed branch from e05b287 to fb8aabc Compare October 31, 2025 13: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