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 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..b1ea625fcd0 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 -v").masquerade_as_nightly_cargo(), + execs() + .with_status(0) + .with_stderr_contains("[RUNNING] `rustdoc [..]-Zunstable-options --edition=2018[..]"), + ); +}