Skip to content
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

[red-knot] Simplify some traits in ast_ids.rs #14379

Merged
merged 2 commits into from
Nov 16, 2024
Merged

Conversation

AlexWaygood
Copy link
Member

Summary

Another small cleanup I'm splitting out from the branch I have locally working towards #13933. The traits HasScopedUseId and HasScopedAstId don't need to be generic: for both traits, the Id associated type is the same for all implementations of the trait. We can remove some complexity here by removing the associated types and specifying concrete types in the trait definitions rather than associated types.

Test Plan

cargo test -p red_knot_python_semantic

@AlexWaygood AlexWaygood added internal An internal refactor or improvement red-knot Multi-file analysis & type inference labels Nov 16, 2024
Copy link
Contributor

github-actions bot commented Nov 16, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

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

The traits were generic because we used to have many different AstIds, more than just use and expressions.

I do think removing the associated types makes sense if we only have two ids. An alternative design would be to unify the two traits instead, and use the associated type to differentiate between the different ids.

@AlexWaygood AlexWaygood enabled auto-merge (squash) November 16, 2024 17:18
@AlexWaygood AlexWaygood merged commit 81d3c41 into main Nov 16, 2024
17 checks passed
@AlexWaygood AlexWaygood deleted the alex/simplify-trait branch November 16, 2024 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal An internal refactor or improvement red-knot Multi-file analysis & type inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants