Skip to content

Commit

Permalink
set the syntax edition in the driver's phase 1
Browse files Browse the repository at this point in the history
  • Loading branch information
QuietMisdreavus committed Aug 9, 2018
1 parent fbb6275 commit 0511b01
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/librustc_driver/driver.rs
Expand Up @@ -57,7 +57,7 @@ use syntax::ext::base::ExtCtxt;
use syntax::fold::Folder;
use syntax::parse::{self, PResult};
use syntax::util::node_count::NodeCounter;
use syntax_pos::FileName;
use syntax_pos::{FileName, hygiene};
use syntax_ext;

use derive_registrar;
Expand Down Expand Up @@ -670,6 +670,7 @@ pub fn phase_1_parse_input<'a>(
) -> PResult<'a, ast::Crate> {
sess.diagnostic()
.set_continue_after_error(control.continue_parse_after_error);
hygiene::set_default_edition(sess.edition());

if sess.profile_queries() {
profile::begin(sess);
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_driver/lib.rs
Expand Up @@ -109,7 +109,7 @@ use syntax::ast;
use syntax::codemap::{CodeMap, FileLoader, RealFileLoader};
use syntax::feature_gate::{GatedCfg, UnstableFeatures};
use syntax::parse::{self, PResult};
use syntax_pos::{hygiene, DUMMY_SP, MultiSpan, FileName};
use syntax_pos::{DUMMY_SP, MultiSpan, FileName};

#[cfg(test)]
mod test;
Expand Down Expand Up @@ -477,7 +477,6 @@ pub fn run_compiler<'a>(args: &[String],
};

let (sopts, cfg) = config::build_session_options_and_crate_config(&matches);
hygiene::set_default_edition(sopts.edition);

driver::spawn_thread_pool(sopts, |sopts| {
run_compiler_with_pool(matches, sopts, cfg, callbacks, file_loader, emitter_dest)
Expand Down
3 changes: 1 addition & 2 deletions src/librustdoc/test.rs
Expand Up @@ -37,7 +37,7 @@ use syntax::codemap::CodeMap;
use syntax::edition::Edition;
use syntax::feature_gate::UnstableFeatures;
use syntax::with_globals;
use syntax_pos::{BytePos, DUMMY_SP, Pos, Span, FileName, hygiene};
use syntax_pos::{BytePos, DUMMY_SP, Pos, Span, FileName};
use errors;
use errors::emitter::ColorConfig;

Expand Down Expand Up @@ -562,7 +562,6 @@ impl Collector {
rustc_driver::in_named_rustc_thread(name, move || with_globals(move || {
io::set_panic(panic);
io::set_print(print);
hygiene::set_default_edition(edition);
run_test(&test,
&cratename,
&filename,
Expand Down
24 changes: 24 additions & 0 deletions src/test/rustdoc/async-fn.rs
@@ -0,0 +1,24 @@
// 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() {}
}

0 comments on commit 0511b01

Please sign in to comment.