Skip to content

Commit b9aa315

Browse files
committed
Auto merge of #5299 - ehuss:rustdoc-edition, r=matklad
Pass edition to rustdoc. Fixes #5279.
2 parents 75ec2d3 + 4eb42cd commit b9aa315

File tree

4 files changed

+40
-3
lines changed

4 files changed

+40
-3
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ matrix:
2828

2929
- env: TARGET=x86_64-unknown-linux-gnu
3030
ALT=i686-unknown-linux-gnu
31-
rust: nightly-2018-03-07
31+
rust: nightly
3232
install:
3333
- mdbook --help || cargo install mdbook --force
3434
script:

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ environment:
66

77
install:
88
- appveyor-retry appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
9-
- rustup-init.exe -y --default-host x86_64-pc-windows-msvc --default-toolchain nightly-2018-03-07
9+
- rustup-init.exe -y --default-host x86_64-pc-windows-msvc --default-toolchain nightly
1010
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
1111
- rustup target add %OTHER_TARGET%
1212
- rustc -V

src/cargo/ops/cargo_rustc/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,13 @@ fn rustdoc<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoResult
776776
rustdoc.arg("--cfg").arg(&format!("feature=\"{}\"", feat));
777777
}
778778

779+
let manifest = unit.pkg.manifest();
780+
781+
if manifest.features().is_enabled(Feature::edition()) {
782+
rustdoc.arg("-Zunstable-options");
783+
rustdoc.arg(format!("--edition={}", &manifest.edition()));
784+
}
785+
779786
if let Some(ref args) = unit.profile.rustdoc_args {
780787
rustdoc.args(args);
781788
}

tests/testsuite/doc.rs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::str;
33
use std::fs::{self, File};
44
use std::io::Read;
55

6-
use cargotest::rustc_host;
6+
use cargotest::{rustc_host, ChannelChanger};
77
use cargotest::support::{execs, project, path2url};
88
use cargotest::support::registry::Package;
99
use hamcrest::{assert_that, existing_dir, existing_file, is_not};
@@ -1464,3 +1464,33 @@ fn doc_workspace_open_help_message() {
14641464
.with_stderr_contains(" bar"),
14651465
);
14661466
}
1467+
1468+
#[test]
1469+
fn doc_edition() {
1470+
if !cargotest::is_nightly() {
1471+
// Stable rustdoc won't have the edition option. Remove this once it
1472+
// is stabilized.
1473+
return;
1474+
}
1475+
let p = project("foo")
1476+
.file(
1477+
"Cargo.toml",
1478+
r#"
1479+
cargo-features = ["edition"]
1480+
[package]
1481+
name = "foo"
1482+
version = "0.0.1"
1483+
authors = []
1484+
rust = "2018"
1485+
"#,
1486+
)
1487+
.file("src/lib.rs", "")
1488+
.build();
1489+
1490+
assert_that(
1491+
p.cargo("doc -v").masquerade_as_nightly_cargo(),
1492+
execs()
1493+
.with_status(0)
1494+
.with_stderr_contains("[RUNNING] `rustdoc [..]-Zunstable-options --edition=2018[..]"),
1495+
);
1496+
}

0 commit comments

Comments
 (0)