diff options
| author | Stuart Cook <Zalathar@users.noreply.github.com> | 2025-09-04 10:02:04 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-04 10:02:04 +1000 |
| commit | 8fc568e905990d06f2435aa32959d08da188fc7e (patch) | |
| tree | aada2b4e541188df946612e1d7a69d6502d16b53 /src | |
| parent | 9214b1854caf1557b85f6f779ec3db03658260ed (diff) | |
| parent | c5dd32e483593ab9751cfac50b907e4ce06f1249 (diff) | |
| download | rust-8fc568e905990d06f2435aa32959d08da188fc7e.tar.gz rust-8fc568e905990d06f2435aa32959d08da188fc7e.zip | |
Rollup merge of #146150 - weihanglo:rustdoc-emit, r=aDotInTheVoid
fix(rustdoc): match rustc `--emit` precedence Resolves rust-lang/rust#141664 This changes rustdoc's `--emit` to allow only one instance of each type, regardless of the actual data that `--emit` carries. This matches rustc's `--emit` behavior. As of the writing, only `dep-info` emit type carries extra data.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustdoc/config.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 450ac04b40d..1220a05e458 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -454,15 +454,22 @@ impl Options { return None; } - let mut emit = Vec::new(); + let mut emit = FxIndexMap::<_, EmitType>::default(); for list in matches.opt_strs("emit") { for kind in list.split(',') { match kind.parse() { - Ok(kind) => emit.push(kind), + Ok(kind) => { + // De-duplicate emit types and the last wins. + // Only one instance for each type is allowed + // regardless the actual data it carries. + // This matches rustc's `--emit` behavior. + emit.insert(std::mem::discriminant(&kind), kind); + } Err(()) => dcx.fatal(format!("unrecognized emission type: {kind}")), } } } + let emit = emit.into_values().collect::<Vec<_>>(); let show_coverage = matches.opt_present("show-coverage"); let output_format_s = matches.opt_str("output-format"); |
