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)).
Activity
rustdoc
wanted features & bugfixes Rust-for-Linux/linux#350GuillaumeGomez commentedon Mar 21, 2024
Wow. That's... a lot. ^^'
Should be doable with a tempfile. Taking a look.
Add regression test for rust-lang#122722
rustdoc --test
: Prevent reaching the maximum size of command-line by using files for arguments if there are too many #122840ojeda commentedon Mar 21, 2024
Thanks Guillaume!
Add regression test for rust-lang#122722
Add regression test for rust-lang#122722
Rollup merge of rust-lang#122840 - GuillaumeGomez:rustdoc-test-too-ma…
25 remaining items