Skip to content

Rust: Add type inference inline expectations for all function calls #19993

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

Conversation

hvitved
Copy link
Contributor

@hvitved hvitved commented Jul 7, 2025

Adds inline expectations for all kinds of calls, not just calls to methods.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Jul 7, 2025
@hvitved hvitved force-pushed the rust/type-inference-function-call-expectations branch from c59d15e to fad5e0d Compare July 7, 2025 15:20
@hvitved hvitved added the no-change-note-required This PR does not need a change note label Jul 7, 2025
@hvitved hvitved marked this pull request as ready for review July 7, 2025 15:21
@Copilot Copilot AI review requested due to automatic review settings July 7, 2025 15:21
@hvitved hvitved requested a review from a team as a code owner July 7, 2025 15:21
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

@aibaars aibaars left a comment

Choose a reason for hiding this comment

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

This looks good to me.

@@ -15,3 +15,6 @@ import codeql.rust.elements.AsyncBlockExpr
import codeql.rust.elements.Variable
import codeql.rust.elements.NamedFormatArgument
import codeql.rust.elements.PositionalFormatArgument
private import codeql.rust.elements.Call as Call
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not simply

import codeql.rust.elements.Call

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It also exposes the class ArgumentPosition, which I'm not sure we want to.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok makes sense. Perhaps ArgumentPosition should have been in another file.

fn call_trait_m1<T1, T2: MyTrait<T1>>(x: T2) -> T1 {
x.m1() // $ method=m1 type=x.m1():T1
}

// Type parameter with bound occurs nested within another type.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's not shift line numbers for no good reason

Suggested change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These linebreaks are actually all deliberate; otherwise the comments are treated as identifiers for the proceeding methods, and that breaks inline expectations.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah ok, it looked like a formatter gone wrong.

@hvitved hvitved merged commit 33e6310 into github:main Jul 7, 2025
22 checks passed
@hvitved hvitved deleted the rust/type-inference-function-call-expectations branch July 7, 2025 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-change-note-required This PR does not need a change note Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants