-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
async move
breaks doc tests
#59313
Comments
This seems to work outside of rustdoc |
Marking as blocking for async await stabilization pending some investigation. cc @rust-lang/rustdoc -- can you all give any tips to try and gain insight into what error is occurring etc? |
Can you give a try to: //! #![feature(async_await)]
//!
//! # fn main() {
//! fn foo() {
//! drop(async move {});
//! }
//! # foo();
//! # }
But beyond that, I'm wondering if it isn't just a missing flag or something along the line? Maybe you have other ideas @QuietMisdreavus ? |
I spent some time yesterday poking at this, and it seems like it's failing somewhere in the pre-parsing of the doctest. Some time around the part where it parses the |
I've sometimes seen problems around |
Funny you should say that... It looks like one of those is being hit when processing this sample: rust/src/libsyntax/parse/parser.rs Lines 791 to 792 in 8260e96
It doesn't seem to hit this when compiling regularly, though. |
I think i've figured it out. The "pre-parse" step of doctest execution runs the parser separately from the later execution of it. In this run, the "default edition" is never set, so libsyntax assumes everything is being run under Rust 2015. This causes it to fail when parsing the |
I've got a PR posted that should fix this: #60065 |
Hmm, I was going to suggest that might be the issue, but I tried a test containing |
Plain |
rustdoc: set the default edition when pre-parsing a doctest Fixes #59313 (possibly more? i think we've had issues with parsing edition-specific syntax in doctests at some point) When handling a doctest, rustdoc needs to parse it beforehand, so that it can see whether it declares a `fn main` or `extern crate my_crate` explicitly. However, while doing this, rustdoc doesn't set the "default edition" used by the parser like the regular compilation runs do. This caused a problem when parsing a doctest with an `async move` block in it, since it was expecting the `move` keyword to start a closure, not a block. This PR changes the `rustdoc::test::make_test` function to set the parser's default edition while looking for a main function and `extern crate` statement. However, to do this, `make_test` needs to know what edition to set. Since this is also used during the HTML rendering process (to make playground URLs), now the HTML renderer needs to know about the default edition. Upshot: rendering standalone markdown files can now accept a "default edition" for their doctests with the `--edition` flag! (I'm pretty sure i waffled around how to set that a long time ago when we first added the `--edition` flag... `>_>`) I'm posting this before i stop for the night so that i can write this description while it's still in my head, but before this merges i want to make sure that (1) the `rustdoc-ui/failed-doctest-output` test still works (i expect it doesn't), and (2) i add a test with the sample from the linked issue.
Steps to reproduce:
lib.rs
:move
insideasync move {}
:The text was updated successfully, but these errors were encountered: