Skip to content

Conversation

@paldepind
Copy link
Contributor

@paldepind paldepind commented Mar 20, 2025

This PR attempts to address most of @aschackmull's comments over in #18632, plus a few additional tweaks to the type inference implementation.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Mar 20, 2025
@paldepind paldepind marked this pull request as ready for review March 20, 2025 15:55
Copilot AI review requested due to automatic review settings March 20, 2025 15:55
Copy link
Contributor

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.

Pull Request Overview

This PR addresses adjustments to type inference by updating generic parameter names for improved consistency.

  • Renamed the generic parameter in struct MyThing from A to T.
  • Renamed the generic parameters in traits MyTrait1, MyTrait2, and MyTrait3 to Tr1, Tr2, and Tr3 respectively.
Files not reviewed (8)
  • rust/ql/lib/codeql/rust/elements/internal/FieldExprImpl.qll: Language not supported
  • rust/ql/lib/codeql/rust/elements/internal/StructImpl.qll: Language not supported
  • rust/ql/lib/codeql/rust/elements/internal/VariantImpl.qll: Language not supported
  • rust/ql/lib/codeql/rust/internal/Type.qll: Language not supported
  • rust/ql/lib/codeql/rust/internal/TypeInference.qll: Language not supported
  • rust/ql/test/library-tests/type-inference/type-inference.expected: Language not supported
  • rust/ql/test/library-tests/type-inference/type-inference.ql: Language not supported
  • shared/typeinference/codeql/typeinference/internal/TypeInference.qll: Language not supported

Tip: If you use Visual Studio Code, you can request a review from Copilot before you push from the "Source Control" tab. Learn more

@paldepind paldepind added the no-change-note-required This PR does not need a change note label Mar 20, 2025

trait MyTrait1<A> {
fn m1(self) -> A;
trait MyTrait1<Tr1> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The expected file contained some duplicated lines, making it a bit hard to se what was what. So this renames some generics s.t. fewer names are identical.

Copy link
Contributor

@hvitved hvitved left a comment

Choose a reason for hiding this comment

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

Thanks for making these changes. I have some mostly nitpicking comments.

* the type parameter `tp` in `target`.
* the type parameter `tp` in `target`, if any.
*
* Note, that this predicate crucially does not depend on type inference,
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: No comma after Note

Comment on lines 622 to 623
* where the method call is an access and `new Sub<int>()` is an access
* position , which is the receiver of a method call, we have:
Copy link
Contributor

Choose a reason for hiding this comment

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

new Sub<int>() in not an access position, but it is at an access position.

*
* new Sub<int>().ToString();
* new Sub<int>().ToString();
* // ^^^^^^^^^^^^^^ `apos`
Copy link
Contributor

Choose a reason for hiding this comment

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

Not quite right, see comment below.


/**
* Holds if the type of `a` at `apos` has the base type `base`, and when
* viewed as an element of that type has at `path` the type `t`.
Copy link
Contributor

Choose a reason for hiding this comment

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

has at path the type t -> has the type t at path.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, let's change it. I was trying to phrase this to match the order of the parameters, but it is clumpsy.

Access a, Declaration target, TypePath path, Type t, TypeParameter tp
) {
not exists(getTypeArgument(a, target, tp, _)) and
target = a.getTarget() and
Copy link
Contributor

Choose a reason for hiding this comment

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

This may or may not introduce a bad join, let's see what DCA says.

hvitved
hvitved previously approved these changes Mar 21, 2025
@paldepind paldepind requested a review from aschackmull March 21, 2025 13:15
Copy link
Contributor

@aschackmull aschackmull left a comment

Choose a reason for hiding this comment

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

One minor typepath mistake, otherwise LGTM

Co-authored-by: Anders Schack-Mulligen <aschackmull@users.noreply.github.com>
@paldepind paldepind merged commit 860ba2e into github:main Mar 24, 2025
28 of 38 checks passed
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.

3 participants