Description
rustdoc
's --test
option may call rustc
with too many arguments, e.g. due to --cfg
s, ICE'ing with:
thread 'x.rs - S (line 1)' panicked at src/librustdoc/doctest.rs:407:38:
Failed to spawn rustc process: Os { code: 7, kind: ArgumentListTooLong, message: "Argument list too long" }
In particular, the original call to rustdoc
(i.e. the user's call) may not suffer from this if they used @args
to pass many arguments, but rustdoc
will then try to spawn rustc
passing them as parameters, and thus failing.
A reproducer may look like, for large enough N:
echo -e '//! ```\n//! ```' > x.rs
yes -- --cfg=A | head -n $N > cfgs
rustdoc --test @cfgs x.rs
Since different systems may have different limits, it may be best to have rustdoc
use a temporary file for all arguments that come from unbounded lists. Or perhaps using the original @args
, if that is possible, since users using too many e.g. --cfg
s are probably using them already.
In the kernel we are close to hitting the limit: we have 28k+ --cfg
s arguments in big configurations, and we may start soon passing --check-cfg
s for those too. Passing our @cfgs
twice already hits the limit.
Meta
Can be reproduced with both the latest stable (1.76.0) and the latest nightly (1.79.0-nightly (3c85e56 2024-03-18)).