Skip to content
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

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

Closed
Nemo157 opened this issue Jul 13, 2018 · 2 comments
Closed

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

Nemo157 opened this issue Jul 13, 2018 · 2 comments
Assignees
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@Nemo157
Copy link
Member

Nemo157 commented Jul 13, 2018

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)
@GuillaumeGomez GuillaumeGomez self-assigned this Jul 14, 2018
@GuillaumeGomez GuillaumeGomez added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Jul 14, 2018
@GuillaumeGomez
Copy link
Member

So your problem comes from this line. But the bigger problem is: why is it 2015 and not 2018? To be more precise: we do give the edition to the parser, it just gets lost in the meantime...

@GuillaumeGomez
Copy link
Member

Found it, adding tests and then I send a PR.

kennytm added a commit to kennytm/rust that referenced this issue Jul 17, 2018
…er, r=QuietMisdreavus

Pass edition flags to compiler from rustdoc as expected

Fixes rust-lang#52357.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants