From bbb2b92ef8750aacf1a034613715ae572ffd674c Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Thu, 5 Apr 2018 05:39:50 -0700 Subject: [PATCH 1/3] Pass edition to rustdoc. Fixes #5279. --- src/cargo/ops/cargo_rustc/mod.rs | 7 +++++++ tests/testsuite/doc.rs | 32 +++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 5f756948243..f467cc6eeac 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -776,6 +776,13 @@ fn rustdoc<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoResult rustdoc.arg("--cfg").arg(&format!("feature=\"{}\"", feat)); } + let manifest = unit.pkg.manifest(); + + if manifest.features().is_enabled(Feature::edition()) { + rustdoc.arg("-Zunstable-options"); + rustdoc.arg(format!("--edition={}", &manifest.edition())); + } + if let Some(ref args) = unit.profile.rustdoc_args { rustdoc.args(args); } diff --git a/tests/testsuite/doc.rs b/tests/testsuite/doc.rs index 7b6ea41e356..e3ca13e921c 100644 --- a/tests/testsuite/doc.rs +++ b/tests/testsuite/doc.rs @@ -3,7 +3,7 @@ use std::str; use std::fs::{self, File}; use std::io::Read; -use cargotest::rustc_host; +use cargotest::{rustc_host, ChannelChanger}; use cargotest::support::{execs, project, path2url}; use cargotest::support::registry::Package; use hamcrest::{assert_that, existing_dir, existing_file, is_not}; @@ -1464,3 +1464,33 @@ fn doc_workspace_open_help_message() { .with_stderr_contains(" bar"), ); } + +#[test] +fn doc_edition() { + if !cargotest::is_nightly() { + // Stable rustdoc won't have the edition option. Remove this once it + // is stabilized. + return; + } + let p = project("foo") + .file( + "Cargo.toml", + r#" + cargo-features = ["edition"] + [package] + name = "foo" + version = "0.0.1" + authors = [] + rust = "2018" + "#, + ) + .file("src/lib.rs", "") + .build(); + + assert_that( + p.cargo("doc").arg("-v").masquerade_as_nightly_cargo(), + execs() + .with_status(0) + .with_stderr_contains("[RUNNING] `rustdoc [..]-Zunstable-options --edition=2018[..]"), + ); +} From 187bb0ad9ac725d2dcc803fff56d834966463c66 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Thu, 5 Apr 2018 06:04:45 -0700 Subject: [PATCH 2/3] Don't use .arg() in test. --- tests/testsuite/doc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testsuite/doc.rs b/tests/testsuite/doc.rs index e3ca13e921c..b1ea625fcd0 100644 --- a/tests/testsuite/doc.rs +++ b/tests/testsuite/doc.rs @@ -1488,7 +1488,7 @@ fn doc_edition() { .build(); assert_that( - p.cargo("doc").arg("-v").masquerade_as_nightly_cargo(), + p.cargo("doc -v").masquerade_as_nightly_cargo(), execs() .with_status(0) .with_stderr_contains("[RUNNING] `rustdoc [..]-Zunstable-options --edition=2018[..]"), From 4eb42cd877b852e3f27165368e81017e7781c928 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Thu, 5 Apr 2018 06:42:48 -0700 Subject: [PATCH 3/3] Unpin nightly version in CI. Removes temporary workaround for rust-lang/rust#49033. --- .travis.yml | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a9b85bc9077..f036981901a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,7 +28,7 @@ matrix: - env: TARGET=x86_64-unknown-linux-gnu ALT=i686-unknown-linux-gnu - rust: nightly-2018-03-07 + rust: nightly install: - mdbook --help || cargo install mdbook --force script: diff --git a/appveyor.yml b/appveyor.yml index d85f19d225d..d901dbe1860 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,7 +6,7 @@ environment: install: - appveyor-retry appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe - - rustup-init.exe -y --default-host x86_64-pc-windows-msvc --default-toolchain nightly-2018-03-07 + - rustup-init.exe -y --default-host x86_64-pc-windows-msvc --default-toolchain nightly - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin - rustup target add %OTHER_TARGET% - rustc -V