Repository navigation
async move breaks doc tests #59313
Description
Activity
- addedT-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.C-bugCategory: This is a bug.Category: This is a bug.A-async-awaitArea: Async & AwaitArea: Async & AwaitA-doctestsArea: Documentation tests, run by rustdocArea: Documentation tests, run by rustdoc
on Mar 20, 2019 This seems to work outside of rustdoc
- addedAsyncAwait-PolishAsync-await issues that are part of the "polish" areaAsync-await issues that are part of the "polish" area
on Apr 16, 2019 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
movekeyword, it just... dies. I'm having trouble pinning down exactly where (and how) it fails, since it's not panicking, and setting-Z treat-err-as-bug(which i have to modify the code to do since we usually don't pass that into doctests) makes it fail at an earlier spot.I've sometimes seen problems around
FatalError.raise()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
} else if self.last_unexpected_token_span == Some(self.span) { FatalError.raise(); 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
async moveblock. What's confusing is how this has never been a problem until now... 🤔Reacted by Squirrel and EloffI'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
async { let foo = 5; }(which fails to compile on edition 2015) and that works fine (unsurprisingly sincefuturesuse a lot of doc-tests containing something similar).Plain
asyncblocks probably pass in the current nightly because they fail after the initial parse, or perhaps they bubble up a single error fromparse_iteminstead of emitting it directly, which causes rustdoc to stop parsing and continue creating the doctest. The difference withasync moveblocks is that they use a keyword that exists in 2015, which causes it to attempt parsing a closure (instead of a struct expression), so it totally fails to parse instead of just creating a real expression that would fail a later check.- added a commit that references this issue
on May 19, 2019
Steps to reproduce:
lib.rs:moveinsideasync move {}: