Change:
Rustdoc seems to fail on async syntax in some situations. With in , the following is a sample of some apparent issues. This should build fine, but fails when running rustdoc: Tested with a few different nightlies (rustc 1.30.0-nightly ( 2018-08-05)) and latest master ().
This is a bug between rustdoc and , where the only place that is handed to libsyntax is this specific all-in-one entry point to the compiler: However, since rustdoc manages the phases of compilation itself, this line is never hit, and thus the global state telling libsyntax what edition to use is not set. We use this call manually for building doctests (see ), but not anywhere else. I propose moving the call from to , right before it sets up the parse session. That way, rustdoc can continue to set the edition in the session options, and other consumers of aren't caught by this gotcha.

Discussion:
use syntax::fold::Folder; use syntax::parse::{self, PResult}; use syntax::util::node_count::NodeCounter; <del> use syntax_pos::FileName; </del> <ins> use syntax_pos::{FileName, hygiene}; </ins> use syntax_ext; use derive_registrar;

) -> PResult<'a, ast::Crate> { sess.diagnostic() .set_continue_after_error(control.continue_parse_after_error); <ins> hygiene::set_default_edition(sess.edition()); </ins> if sess.profile_queries() { profile::begin(sess);

use syntax::codemap::{CodeMap, FileLoader, RealFileLoader}; use syntax::feature_gate::{GatedCfg, UnstableFeatures}; use syntax::parse::{self, PResult}; <del> use syntax_pos::{hygiene, DUMMY_SP, MultiSpan, FileName}; </del> <ins> use syntax_pos::{DUMMY_SP, MultiSpan, FileName}; </ins> #[cfg(test)] mod test;

}; let (sopts, cfg) = config::build_session_options_and_crate_config(&matches); <del> hygiene::set_default_edition(sopts.edition); </del> driver::spawn_thread_pool(sopts, |sopts| { run_compiler_with_pool(matches, sopts, cfg, callbacks, file_loader, emitter_dest)

use syntax::edition::Edition; use syntax::feature_gate::UnstableFeatures; use syntax::with_globals; <del> use syntax_pos::{BytePos, DUMMY_SP, Pos, Span, FileName, hygiene}; </del> <ins> use syntax_pos::{BytePos, DUMMY_SP, Pos, Span, FileName}; </ins> use errors; use errors::emitter::ColorConfig;

rustc_driver::in_named_rustc_thread(name, move || with_globals(move || { io::set_panic(panic); io::set_print(print); <del> hygiene::set_default_edition(edition); </del> run_test(&test, &cratename, &filename,

<ins> // Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // edition:2018 // compile-flags:-Z unstable-options // FIXME: once `--edition` is stable in rustdoc, remove that `compile-flags` directive #![feature(rust_2018_preview, async_await, futures_api)] // @has async_fn/struct.S.html // @has - '//code' 'pub async fn f()' pub struct S; impl S { pub async fn f() {} } </ins>