-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Support const generics #8655
Copy link
Copy link
Open
Labels
A-tytype system / type inference / traits / method resolutiontype system / type inference / traits / method resolutionC-bugCategory: bugCategory: bugC-featureCategory: feature requestCategory: feature requestE-hardE-has-instructionsIssue has some instructions and pointers to code to get startedIssue has some instructions and pointers to code to get startedS-actionableSomeone could pick this issue up and work on it right nowSomeone could pick this issue up and work on it right now
Metadata
Metadata
Assignees
Labels
A-tytype system / type inference / traits / method resolutiontype system / type inference / traits / method resolutionC-bugCategory: bugCategory: bugC-featureCategory: feature requestCategory: feature requestE-hardE-has-instructionsIssue has some instructions and pointers to code to get startedIssue has some instructions and pointers to code to get startedS-actionableSomeone could pick this issue up and work on it right nowSomeone could pick this issue up and work on it right now
Type
Fields
Give feedbackNo fields configured for issues without a type.
There's a bunch of stuff we need to implement to support const generics at least enough to get method resolution right in simple cases:
hir_tythat currently assume only type parameters exist. A good place to start is probably theGenericshelper inhir_ty'sutil.rsInternedConcreteConstin ourInternerfrom()to an enum that can represent these numbersconst_eqmethod onInternerResult<Binders<Const>, ConstEvalError>that can be either a concrete const, aBoundVarreferring to a const param, or an error if the expression is too complicated. We'll want to handle errors differently depending on the situation (while inferring bodies, we could replace them by const variables, for example). We should stick to only evaluating simple integer literals for now. We'll need to call this query during type lowering.{ N + 1 }(whereNis a const param), we need support in Chalk for unevaluated consts that doesn't exist yet