Skip to content

Rust: More path resolution improvements #18823

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 4 commits into from
Feb 24, 2025

Conversation

hvitved
Copy link
Contributor

@hvitved hvitved commented Feb 20, 2025

Add support for resolving trait items with default implementations, and items defined in type parameter bounds.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Feb 20, 2025
@hvitved hvitved force-pushed the rust/path-resolution-more branch from b6c3a1b to 496f485 Compare February 20, 2025 12:57
@hvitved hvitved marked this pull request as ready for review February 20, 2025 19:41
@hvitved hvitved requested a review from paldepind February 20, 2025 19:41

/** Holds if this `impl` block declares an associated item named `name`. */
pragma[nomagic]
predicate declares(string name) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think a name like hasAssocItem would be more immediately understandable.

Comment on lines 159 to 163
this =
any(TypeParamItemNode param |
result = param.resolveABound().getASuccessorRec(name) and
result instanceof AssocItemNode
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
this =
any(TypeParamItemNode param |
result = param.resolveABound().getASuccessorRec(name) and
result instanceof AssocItemNode
)
result = this.(TypeParamItemNode).resolveABound().getASuccessorRec(name).(AssocItemNode)

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to worry about lifetime bounds on type parameters? Filter them out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lifetime type parameters are not part of ItemNode, so I don't think any filtering is needed.

Copy link
Contributor

@paldepind paldepind left a comment

Choose a reason for hiding this comment

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

Looks great. There certainly are a lot of different cases to handle.

Comment on lines 159 to 163
this =
any(TypeParamItemNode param |
result = param.resolveABound().getASuccessorRec(name) and
result instanceof AssocItemNode
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to worry about lifetime bounds on type parameters? Filter them out?

Copy link
Contributor

@paldepind paldepind 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 425fa0d into github:main Feb 24, 2025
16 checks passed
@hvitved hvitved deleted the rust/path-resolution-more branch February 24, 2025 11:46
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.

2 participants