rust-lang / rust-lang/rust

`--emit KIND=PATH` cannot handle paths containing commas

Open
#159,743 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-CLI C-bug needs-triage
Dominant language
Rust
Stars
119k
Forks
16.2k
PR merge metrics
PR metrics pending

Description

I tried this code:

#!/usr/bin/env bash
set -eu

rustc=$(rustup which rustc)
rustdoc=$(rustup which rustdoc)
tmp=$(mktemp -d); trap 'rm -rf "$tmp"' EXIT
out="$tmp/with,comma"; mkdir "$out"
echo '' > "$tmp/lib.rs"

check() {  # $1=label; rest=command
  echo "### $1"; shift
  "$@" 2>&1 | sed 's/^/    /'
  echo
}

"$rustc" --version; echo
check "rustc" \
  "$rustc" --crate-name t --crate-type lib --out-dir "$out" \
  --emit=dep-info="$out/t.d" "$tmp/lib.rs"

check "rustdoc" \
  "$rustdoc" --crate-name t -o "$out" \
  --emit=html-non-static-files,dep-info="$out/t.d" "$tmp/lib.rs"

I expected to see this happen:

rustc 1.99.0-nightly (9f36de775 2026-07-19)

### rustc

### rustdoc

(all three invocations succeed and write dep-info file to the path under with,comma/)

Instead, this happened:

rustc 1.99.0-nightly (9f36de775 2026-07-19)

### rustc: single kind
    error: unknown emission type: `comma/t.d` - expected one of: `asm`, `llvm-bc`, `dep-info`, `link`, `llvm-ir`, `metadata`, `mir`, `obj`, `thin-link-bitcode`

### rustdoc
    error: unrecognized emission type: comma/t.d

Both rustc and rustdoc split the entire --emit value on commas before recognizing the KIND=PATH form,
so everything after a comma inside PATH is misparsed as another emission type.

There is no escape mechanism btw.
Isolating a single KIND=PATH in its own --emit also doesn't help.

Meta

rustc --version --verbose:

rustc 1.99.0-nightly (9f36de775 2026-07-19)
binary: rustc
commit-hash: 9f36de775bc636c8e88c31a173c2bcb6995956a0
commit-date: 2026-07-19
host: aarch64-apple-darwin
release: 1.99.0-nightly
LLVM version: 22.1.8
How this was discovered

While stabilizing -Zrustdoc-depinfo,
Cargo started passing --emit=html-static-files,html-non-static-files,dep-info=<path> to rustdoc,
where <path> is an absolute path under the target directory.
If there is a comma in the target-dir path,
cargo doc would fail with unrecognized emission type.

Thanks @0xpoe for catching that in https://github.com/rust-lang/cargo/pull/17020#issuecomment-5051279941!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the comma-path failure with the rustc and rustdoc entry points shown in the issue, then trace how each parses the --emit value. Add regression coverage for KIND=PATH values containing commas and verify the commands write dep-info successfully under such paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.