diff --git a/src/bin/cargo/cli.rs b/src/bin/cargo/cli.rs index 74b9e436eb1..7395a80842d 100644 --- a/src/bin/cargo/cli.rs +++ b/src/bin/cargo/cli.rs @@ -36,7 +36,6 @@ Available unstable (nightly-only) flags: -Z unstable-options -- Allow the usage of unstable options -Z timings -- Display concurrency information -Z doctest-xcompile -- Compile and run doctests for non-host target using runner config - -Z crate-versions -- Add crate versions to generated docs -Z terminal-width -- Provide a terminal width to rustc for error truncation Run with 'cargo -Z [FLAG] [SUBCOMMAND]'" diff --git a/src/cargo/core/compiler/mod.rs b/src/cargo/core/compiler/mod.rs index 91d444cce05..84fd5e18da2 100644 --- a/src/cargo/core/compiler/mod.rs +++ b/src/cargo/core/compiler/mod.rs @@ -579,7 +579,9 @@ fn rustdoc(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult { rustdoc.args(bcx.rustdocflags_args(unit)); - add_crate_versions_if_requested(bcx, unit, &mut rustdoc); + if !crate_version_flag_already_present(&rustdoc) { + append_crate_version_flag(unit, &mut rustdoc); + } let name = unit.pkg.name().to_string(); let build_script_outputs = Arc::clone(&cx.build_script_outputs); @@ -617,16 +619,6 @@ fn rustdoc(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult { })) } -fn add_crate_versions_if_requested( - bcx: &BuildContext<'_, '_>, - unit: &Unit, - rustdoc: &mut ProcessBuilder, -) { - if bcx.config.cli_unstable().crate_versions && !crate_version_flag_already_present(rustdoc) { - append_crate_version_flag(unit, rustdoc); - } -} - // The --crate-version flag could have already been passed in RUSTDOCFLAGS // or as an extra compiler argument for rustdoc fn crate_version_flag_already_present(rustdoc: &ProcessBuilder) -> bool { diff --git a/src/cargo/core/features.rs b/src/cargo/core/features.rs index c8993451ad1..5b3fbce1977 100644 --- a/src/cargo/core/features.rs +++ b/src/cargo/core/features.rs @@ -356,7 +356,6 @@ pub struct CliUnstable { pub panic_abort_tests: bool, pub jobserver_per_rustc: bool, pub features: Option>, - pub crate_versions: bool, pub separate_nightlies: bool, pub multitarget: bool, pub rustdoc_map: bool, @@ -462,7 +461,6 @@ impl CliUnstable { "panic-abort-tests" => self.panic_abort_tests = parse_empty(k, v)?, "jobserver-per-rustc" => self.jobserver_per_rustc = parse_empty(k, v)?, "features" => self.features = Some(parse_features(v)), - "crate-versions" => self.crate_versions = parse_empty(k, v)?, "separate-nightlies" => self.separate_nightlies = parse_empty(k, v)?, "multitarget" => self.multitarget = parse_empty(k, v)?, "rustdoc-map" => self.rustdoc_map = parse_empty(k, v)?, diff --git a/src/doc/src/reference/unstable.md b/src/doc/src/reference/unstable.md index b2998dd4a7f..dda843bdfee 100644 --- a/src/doc/src/reference/unstable.md +++ b/src/doc/src/reference/unstable.md @@ -646,13 +646,6 @@ resolver = "2" The `resolver` field is ignored in dependencies, only the top-level project or workspace can control the new behavior. -### crate-versions -* Tracking Issue: [#7907](https://github.com/rust-lang/cargo/issues/7907) - -The `-Z crate-versions` flag will make `cargo doc` include appropriate crate versions for the current crate and all of its dependencies (unless `--no-deps` was provided) in the compiled documentation. - -You can find an example screenshot for the cargo itself in the tracking issue. - ### unit-graph * Tracking Issue: [#8002](https://github.com/rust-lang/cargo/issues/8002) diff --git a/tests/testsuite/doc.rs b/tests/testsuite/doc.rs index 0a4a914ef67..3077359f46e 100644 --- a/tests/testsuite/doc.rs +++ b/tests/testsuite/doc.rs @@ -1483,10 +1483,6 @@ fn bin_private_items_deps() { #[cargo_test] fn crate_versions() { - // Testing flag that will reach stable on 1.44 - if !is_nightly() { - return; - } let p = project() .file( "Cargo.toml", @@ -1500,8 +1496,14 @@ fn crate_versions() { .file("src/lib.rs", "") .build(); - p.cargo("-Z crate-versions doc") - .masquerade_as_nightly_cargo() + p.cargo("doc -v") + .with_stderr( + "\ +[DOCUMENTING] foo v1.2.4 [..] +[RUNNING] `rustdoc --crate-type lib --crate-name foo src/lib.rs [..]--crate-version 1.2.4` +[FINISHED] [..] +", + ) .run(); let output_path = p.root().join("target/doc/foo/index.html"); @@ -1512,10 +1514,6 @@ fn crate_versions() { #[cargo_test] fn crate_versions_flag_is_overridden() { - // Testing flag that will reach stable on 1.44 - if !is_nightly() { - return; - } let p = project() .file( "Cargo.toml", @@ -1538,16 +1536,13 @@ fn crate_versions_flag_is_overridden() { assert!(html.contains("Version 2.0.3")); }; - p.cargo("-Z crate-versions doc") - .masquerade_as_nightly_cargo() + p.cargo("doc") .env("RUSTDOCFLAGS", "--crate-version 2.0.3") .run(); asserts(output_documentation()); p.build_dir().rm_rf(); - p.cargo("-Z crate-versions rustdoc -- --crate-version 2.0.3") - .masquerade_as_nightly_cargo() - .run(); + p.cargo("rustdoc -- --crate-version 2.0.3").run(); asserts(output_documentation()); } diff --git a/tests/testsuite/rustdoc.rs b/tests/testsuite/rustdoc.rs index 860428a9223..3364557ad0a 100644 --- a/tests/testsuite/rustdoc.rs +++ b/tests/testsuite/rustdoc.rs @@ -1,6 +1,6 @@ //! Tests for the `cargo rustdoc` command. -use cargo_test_support::{basic_manifest, project}; +use cargo_test_support::{basic_manifest, cross_compile, project}; #[cargo_test] fn rustdoc_simple() { @@ -13,7 +13,7 @@ fn rustdoc_simple() { [RUNNING] `rustdoc [..]--crate-name foo src/lib.rs [..]\ -o [CWD]/target/doc \ [..] \ - -L dependency=[CWD]/target/debug/deps` + -L dependency=[CWD]/target/debug/deps [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", ) @@ -32,7 +32,7 @@ fn rustdoc_args() { -o [CWD]/target/doc \ [..] \ --cfg=foo \ - -L dependency=[CWD]/target/debug/deps` + -L dependency=[CWD]/target/debug/deps [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", ) @@ -122,7 +122,7 @@ fn rustdoc_only_bar_dependency() { -o [CWD]/target/doc \ [..] \ --cfg=foo \ - -L dependency=[CWD]/target/debug/deps` + -L dependency=[CWD]/target/debug/deps [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", ) @@ -144,7 +144,7 @@ fn rustdoc_same_name_documents_lib() { -o [CWD]/target/doc \ [..] \ --cfg=foo \ - -L dependency=[CWD]/target/debug/deps` + -L dependency=[CWD]/target/debug/deps [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", ) @@ -203,21 +203,26 @@ fn proc_macro_crate_type() { } #[cargo_test] -#[cfg(all(target_arch = "x86_64", target_os = "linux", target_env = "gnu"))] fn rustdoc_target() { + if cross_compile::disabled() { + return; + } + let p = project().file("src/lib.rs", "").build(); - p.cargo("rustdoc --verbose --target x86_64-unknown-linux-gnu") - .with_stderr( + p.cargo("rustdoc --verbose --target") + .arg(cross_compile::alternate()) + .with_stderr(format!( "\ [DOCUMENTING] foo v0.0.1 ([..]) [RUNNING] `rustdoc [..]--crate-name foo src/lib.rs [..]\ - --target x86_64-unknown-linux-gnu \ - -o [CWD]/target/x86_64-unknown-linux-gnu/doc \ + --target {target} \ + -o [CWD]/target/{target}/doc \ [..] \ - -L dependency=[CWD]/target/x86_64-unknown-linux-gnu/debug/deps \ - -L dependency=[CWD]/target/debug/deps` + -L dependency=[CWD]/target/{target}/debug/deps \ + -L dependency=[CWD]/target/debug/deps[..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]", - ) + target = cross_compile::alternate() + )) .run(); }