Add unsafe versions of inlining macros #826
Merged
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.
Closes #825.
(note: replace BACKEND by
fstar
,coq
, etc. in the text of this PR)This PR:
hax_lib::inline_unsafe
function, hidden in documentation, that allows to inline BACKEND code of any type directly as an expression. This is an internal function, it not supposed to be used directly.It exists only when compiling through hax(see my last reverted commit). The body of this function is anunreachable!
.hax_lib_macro:BACKEND_unsafe_expr
macro (exposed ashax_lib::BACKEND_unsafe_expr
, hidden in doc) which leveragesinline_unsafe
to produce inlined BACKEND code of any type.hax_lib_macro:BACKEND_unsafe_expr
locally asBACKEND
in pre and post conditions. Thus we can use e.g.fstar!("forall x. ...")
in ensures and requires clauses.future(...)
within a quote (e.g.fstar!("... ${future(arg)} ...")
): due to the way macros expand in a fixed sequence (thefstar!("...")
expands afterrequires
expands, so therequires
macro cannot rewrite future nodes in"..."
-- note that will be the same thing, but withold
instead offuture
, when Pre/post&mut
argument: removefuture
in favor ofold
#773 will be fixed)Example of what you can do:
https://hax-playground.cryspen.com/#fstar/88b4821690/gist=49d80be217020e9fd41f9e0a6a23714e