Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix #548
This PR at current state is just for early feedback, and contains several todos.
My approach is this: Caller of chalk sees code that contains unevaluated const generic parameter. That can be arbitrary expression (which may contains block expressions, let, loop, ...) , but caller (after possible normalizing and partial evaluation, which currently there isn't any) changes them to a simple named function. For example it will change
N < 128
to#le128(N)
(or#F324(N)
). The only thing that chalk knows about that functions is that it will return same output for the same input. And caller of chalk should provide aconst_eval
function that chalk can call it when all arguments of a function are concrete constants. In this way the complexity of arbitary rust syntax and const evaluation with miri would be abstracted away in chalk. So, this example from it's time to get hyped:Would become this in chalk:
This currently passes in my branch. If this is the correct way, we can continue this PR, otherwise we can close this and/or talk about what the correct approach is.