From 3cff5963fd5aba1d85f631a6fa286fc5a505de9e Mon Sep 17 00:00:00 2001 From: "Jonas T. Hansen" Date: Wed, 6 May 2026 22:23:12 +0200 Subject: [PATCH 1/3] fix(rustdoc): Remove --test(s), --bench(es) and "--all-targets" arguments See (#13427). Using --test(s) in a project with integration tests causes import errors. --bench(es) does not cause errors, but also doesn't work correctly and is not supported by rustdoc. --all-targets have the same issues as --test(s) as it implicitly includes the --tests argument. Removing these also means that the "rustdoc" command now have the same targets as the "doc" command. In projects without integration tests these arguments doesn't cause errors, but they also don't work correctly. There is a chance that someone uses these arguments for whom this is a breaking change. --- src/bin/cargo/commands/rustdoc.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/bin/cargo/commands/rustdoc.rs b/src/bin/cargo/commands/rustdoc.rs index d310d98580c..2d3a35dee06 100644 --- a/src/bin/cargo/commands/rustdoc.rs +++ b/src/bin/cargo/commands/rustdoc.rs @@ -19,17 +19,12 @@ pub fn cli() -> Command { .arg_message_format() .arg_silent_suggestion() .arg_package("Package to document") - .arg_targets_all( + .arg_targets_lib_bin_example( "Build only this package's library", "Build only the specified binary", "Build all binaries", "Build only the specified example", "Build all examples", - "Build only the specified test target", - "Build all targets that have `test = true` set", - "Build only the specified bench target", - "Build all targets that have `bench = true` set", - "Build all targets", ) .arg_features() .arg_parallel() From 0c52a152c8aa723ba8285ce8ea7b9c13500d1f66 Mon Sep 17 00:00:00 2001 From: "Jonas T. Hansen" Date: Wed, 6 May 2026 22:23:30 +0200 Subject: [PATCH 2/3] fix(test): Fix tests that broke due to removing the rustdoc arguments `rustdoc_bench` and `rustdoc_test` were both testing that the --test and --bench arguments were working, but now that those arguments have been removed, change the tests to make sure the --test and --bench arguments are not recognized. The `cargo_rustdoc::help::case` test is checking for the output of `rustdoc --help`, but this help output has changed. Remove --test and --bench checks in rustdoc_list_availables --- .../cargo_rustdoc/help/stdout.term.svg | 60 ++++++++----------- tests/testsuite/glob_targets.rs | 16 ++--- tests/testsuite/list_availables.rs | 26 -------- 3 files changed, 31 insertions(+), 71 deletions(-) diff --git a/tests/testsuite/cargo_rustdoc/help/stdout.term.svg b/tests/testsuite/cargo_rustdoc/help/stdout.term.svg index 750ed3c754c..e11ced8aaff 100644 --- a/tests/testsuite/cargo_rustdoc/help/stdout.term.svg +++ b/tests/testsuite/cargo_rustdoc/help/stdout.term.svg @@ -1,4 +1,4 @@ - +
-
--lib

Document the package’s library.

@@ -104,45 +95,6 @@ and supports common Unix glob patterns.

-
--test name
-

Document the specified integration test. This flag may be specified -multiple times and supports common Unix glob patterns.

-
- - -
--tests
-

Document all targets that have the test = true manifest -flag set. By default this includes the library and binaries built as -unittests, and integration tests. Be aware that this will also build any -required dependencies, so the lib target may be built twice (once as a -unittest, and once as a dependency for binaries, integration tests, etc.). -Targets may be enabled or disabled by setting the test flag in the -manifest settings for the target.

-
- - -
--bench name
-

Document the specified benchmark. This flag may be specified multiple -times and supports common Unix glob patterns.

-
- - -
--benches
-

Document all targets that have the bench = true -manifest flag set. By default this includes the library and binaries built -as benchmarks, and bench targets. Be aware that this will also build any -required dependencies, so the lib target may be built twice (once as a -benchmark, and once as a dependency for binaries, benchmarks, etc.). -Targets may be enabled or disabled by setting the bench flag in the -manifest settings for the target.

-
- - -
--all-targets
-

Document all targets. This is equivalent to specifying --lib --bins --tests --benches --examples.

-
- -
### Feature Selection diff --git a/src/etc/man/cargo-rustdoc.1 b/src/etc/man/cargo-rustdoc.1 index c624de72c2f..5bd93253c51 100644 --- a/src/etc/man/cargo-rustdoc.1 +++ b/src/etc/man/cargo-rustdoc.1 @@ -52,14 +52,6 @@ binary and library targets of the selected package. The binary will be skipped if its name is the same as the lib target. Binaries are skipped if they have \fBrequired\-features\fR that are missing. .sp -Passing target selection flags will document only the specified -targets. -.sp -Note that \fB\-\-bin\fR, \fB\-\-example\fR, \fB\-\-test\fR and \fB\-\-bench\fR flags also -support common Unix glob patterns like \fB*\fR, \fB?\fR and \fB[]\fR\&. However, to avoid your -shell accidentally expanding glob patterns before Cargo handles them, you must -use single quotes or double quotes around each glob pattern. -.sp \fB\-\-lib\fR .RS 4 Document the package\[cq]s library. @@ -86,45 +78,6 @@ and supports common Unix glob patterns. .RS 4 Document all example targets. .RE -.sp -\fB\-\-test\fR \fIname\fR\[u2026] -.RS 4 -Document the specified integration test. This flag may be specified -multiple times and supports common Unix glob patterns. -.RE -.sp -\fB\-\-tests\fR -.RS 4 -Document all targets that have the \fBtest = true\fR manifest -flag set. By default this includes the library and binaries built as -unittests, and integration tests. Be aware that this will also build any -required dependencies, so the lib target may be built twice (once as a -unittest, and once as a dependency for binaries, integration tests, etc.). -Targets may be enabled or disabled by setting the \fBtest\fR flag in the -manifest settings for the target. -.RE -.sp -\fB\-\-bench\fR \fIname\fR\[u2026] -.RS 4 -Document the specified benchmark. This flag may be specified multiple -times and supports common Unix glob patterns. -.RE -.sp -\fB\-\-benches\fR -.RS 4 -Document all targets that have the \fBbench = true\fR -manifest flag set. By default this includes the library and binaries built -as benchmarks, and bench targets. Be aware that this will also build any -required dependencies, so the lib target may be built twice (once as a -benchmark, and once as a dependency for binaries, benchmarks, etc.). -Targets may be enabled or disabled by setting the \fBbench\fR flag in the -manifest settings for the target. -.RE -.sp -\fB\-\-all\-targets\fR -.RS 4 -Document all targets. This is equivalent to specifying \fB\-\-lib \-\-bins \-\-tests \-\-benches \-\-examples\fR\&. -.RE .SS "Feature Selection" The feature flags allow you to control which features are enabled. When no feature options are given, the \fBdefault\fR feature is activated for every