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.
Superseed #538
Target of this PR:
What works
Unsafe use
I defined a "File" like that:
I need to store the statements for code action, and as you can see, they have a lifetime of
'static.In numbat-cli, that's not a big deal, as we can
Box::leakthe file. But in the lsp where each file modification generates an entirely new file, that's not possible.Since the statements depend on the content, which is stored in the same struct, that also means we're doing a self-referential thingy.
I solved the issue by:
Pinning the content so we're sure it never moves, and the ref stays valid in the statementsoriginal_stmtswe have to "cast" their slice to'staticwith an unsafemem::transmuteWhat needs to be fixed
usestmts we sometimes have to emit errors, and sometimes we must override the current env