Skip to content

rustdoc: edition flag isn't propagated to doc-tests #52357

Closed
@Nemo157

Description

@Nemo157

Given a file:

#![feature(async_await)]

/// ```rust
/// #![feature(async_await)]
/// fn main() {
///     let _ = async { };
/// }
/// ```
fn main() {
    let _ = async { };
}

compiling it with rustc --edition 2018 temp.rs works. Attempting to run the doc-test via rustdoc -Z unstable-options --edition 2018 --test temp.rs gives:

running 1 test
test temp.rs - main (line 3) ... FAILED

failures:

---- temp.rs - main (line 3) stdout ----
error[E0422]: cannot find struct, variant or union type `async` in this scope
 --> temp.rs:6:13
  |
4 |     let _ = async { };
  |             ^^^^^ not found in this scope

thread 'temp.rs - main (line 3)' panicked at 'couldn't compile the test', librustdoc/test.rs:327:17
note: Run with `RUST_BACKTRACE=1` for a backtrace.


failures:
    temp.rs - main (line 3)

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out

which is the same error that rustc --edition 2015 temp.rs gives.

EDIT: Tested on versions:

rustdoc 1.29.0-nightly (960f6046c 2018-07-08)
rustdoc 1.29.0-nightly (64f7de921 2018-07-12)

Metadata

Metadata

Labels

T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions