Conversation
| dcx.fatal(format!("unrecognized emission type: {typ}")) | ||
| }; | ||
|
|
||
| match typ { |
There was a problem hiding this comment.
A match (output_format, typ) { … } / match (typ, output_format) { … } looked less legible in my eyes esp. due to rustfmt's decisions.
| // If `--emit` is absent we'll register default emission types depending on the requested | ||
| // output format. We can safely use `is_empty` for this since `--emit=` ("truly empty") | ||
| // will have already been rejected above. | ||
| if emit.is_empty() { |
There was a problem hiding this comment.
Alternatively, I could change the earlier emit from FxIndexMap to Option<FxIndexMap> to avoid conflating Some([]) with None which would be more robust and future-proof but slightly more annoying to construct.
| if let OutputFormat::Doctest = output_format { | ||
| dcx.fatal("the `--emit` flag is not supported with `--output-format=doctest`"); | ||
| } |
There was a problem hiding this comment.
If you do like this PR I'll of course add a test for this.
| "the `--emit={emit_flag}` flag is not supported with `--output-format=json`", | ||
| )); | ||
| let mut emit = FxIndexMap::default(); | ||
| for list in matches.opt_strs("emit") { |
There was a problem hiding this comment.
Unrelated and already brought up in the stabilization PR, I'm more and more leaning towards fully ditching -w, --output-format in favor of --emit because the current setup makes my head spin (the loose proposal to repurpose--output and the one to add --print doesn't help ^^).
--emit=json-files and --emit=doctests could be wonderful. Of course, we probably want to make some emission types mutually exclusive then … which might not be in line with its "spirit" but oh well
Implements #155374 (comment):
Instead of maintaining the hidden assumption or invariant that
opts.emit.is_empty()actually means "emit default artifacts" (i.e.,[HtmlStaticFiles, HtmlNonStaticFiles]under output formathtml; "[???]" under output formatjson), actually reify the list of emission types so the rest of the code doesn't need to keep this in mind.I'm not sure if you like this. It's a tinge overengineered, maybe, but it's more robust I claim.
This PR also rejects
--emitwhen--output-format doctest -Zunstable-optionsis passed since the latter doesn't honor emission types at all (yet).