Skip to content

Pass edition to rustdoc. #5299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/cargo/ops/cargo_rustc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
32 changes: 31 additions & 1 deletion tests/testsuite/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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[..]"),
);
}