-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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] Refactor KnownFunction::takes_expression_arguments()
#15406
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Using bitset!
over a hand written bitset would probably have been an alternative solution.
/// Whether a specific parameter in the function expects a type expression can be queried | ||
/// using [`ParameterExpectations::expectation_at_index`]. | ||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)] | ||
enum ParameterExpectations { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really have a better suggestion but the name is somewhat vague. ParameterKindness
? ParameterValueKind
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it's not a great name but I can't think of anything better, and I'm not sure I love either of these 😆
Yeah -- I considered it, but ultimately concluded it wouldn't buy us much here, since there's only a limited number of special-cased functions anyway |
Pretty sure this will use more memory than a bitset (I don't think Rust will pack a slice of one-bit enums into a bitset automatically?) but yeah, it shouldn't matter. |
Yeah, it should be 2 words but we never store the data structure anywhere so... |
I also agree that I don't think it matters, but if it makes you happier I've switched to a representation where it's now smaller than on |
8dae19f
to
860c523
Compare
860c523
to
656ef0c
Compare
Summary
Refactors the
KnownFunction::takes_expression_arguments()
. By introducing a custom type rather than passing around au32
everywhere, we improve readability, the documentation of the code, and type safety, without introducing any allocation.Test Plan
cargo test -p red_knot_python_semantic