Skip to content

Rust: Improve type inference for for loops and range expressions #19971

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

Merged
merged 3 commits into from
Jul 8, 2025

Conversation

hvitved
Copy link
Contributor

@hvitved hvitved commented Jul 3, 2025

This PR generalizes the existing logic for inferring types of for loops to be based on the IntoIterator trait, cf. how for loops are desugared. Additionally, this PR also adds type inference for range expressions like 1..10.

DCA looks good; more resolved calls, no significant slowdown.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Jul 3, 2025
@hvitved hvitved force-pushed the rust/type-inference-for-range branch from 2e9addd to 2c8f0b8 Compare July 3, 2025 16:01
@hvitved hvitved force-pushed the rust/type-inference-for-range branch 2 times, most recently from a36c9ec to 7647bc3 Compare July 4, 2025 12:48
@hvitved hvitved marked this pull request as ready for review July 7, 2025 07:35
@Copilot Copilot AI review requested due to automatic review settings July 7, 2025 07:35
@hvitved hvitved requested a review from a team as a code owner July 7, 2025 07:35
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Contributor

@geoffw0 geoffw0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few questions, but otherwise looks great, as does the DCA run.

let path = e.path(); // $ Alert[rust/summary/taint-sources]
let file_name = e.file_name(); // $ Alert[rust/summary/taint-sources]
sink(path); // $ hasTaintFlow
sink(file_name); // $ hasTaintFlow
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really happy to see these! 🎉

@hvitved hvitved force-pushed the rust/type-inference-for-range branch from f741e41 to 1518cad Compare July 8, 2025 09:29
@hvitved hvitved requested a review from geoffw0 July 8, 2025 09:42
Copy link
Contributor

@geoffw0 geoffw0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@hvitved hvitved merged commit 411aa6d into github:main Jul 8, 2025
20 checks passed
@hvitved hvitved deleted the rust/type-inference-for-range branch July 8, 2025 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy