Avoid compilation for justfile formatting#3103
Conversation
|
Related: #3088 |
casey
left a comment
There was a problem hiding this comment.
This is definitely a good feature, although I'm not sure I like the duplication that it introduces. Lexing and parsing was previously only done in Compiler::compile, but now it's done both there and in Subcommand::format. Can this be de-duplicated? Perhaps by creating a helper function on Compiler which does lexing and parsing for a Source, which can be called in both places?
|
Is this ready for another look? I ignore notifications from pushed changes to a branch, since they're often just noise. |
No worries, yeah this should be ready. I lifted out a I also don't know if this should live on |
casey
left a comment
There was a problem hiding this comment.
I agree that putting it on Parser is better. Ideally, we could replace Parser::parse with something that would take a Source, but if that doesn't work Parser::parse_source that takes a Source is fine.
|
Why did the |
|
|
What was it testing? Are there other tests testing the same thing, or did we lose coverage by deleting it? |
It was testing that |
--fmtonly uses the root AST'sDisplayimpl, but previously went through full compilation, including import and module resolution. This meant--fmtwould fail withMissingImportFileorMissingModuleFileerrors for files it never needed.This diff moves
Formathandling to before theSelf::compile()call, similar toEdit, so it loads, lexes, and parses only the root file. The unstable check inspects the AST directly for set unstable rather than going throughConfig::require_unstable, which requires a fully compiled Justfile.