Skip to content

Commit 0511b01

Browse files
set the syntax edition in the driver's phase 1
1 parent fbb6275 commit 0511b01

File tree

4 files changed

+28
-5
lines changed

4 files changed

+28
-5
lines changed

src/librustc_driver/driver.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ use syntax::ext::base::ExtCtxt;
5757
use syntax::fold::Folder;
5858
use syntax::parse::{self, PResult};
5959
use syntax::util::node_count::NodeCounter;
60-
use syntax_pos::FileName;
60+
use syntax_pos::{FileName, hygiene};
6161
use syntax_ext;
6262

6363
use derive_registrar;
@@ -670,6 +670,7 @@ pub fn phase_1_parse_input<'a>(
670670
) -> PResult<'a, ast::Crate> {
671671
sess.diagnostic()
672672
.set_continue_after_error(control.continue_parse_after_error);
673+
hygiene::set_default_edition(sess.edition());
673674

674675
if sess.profile_queries() {
675676
profile::begin(sess);

src/librustc_driver/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ use syntax::ast;
109109
use syntax::codemap::{CodeMap, FileLoader, RealFileLoader};
110110
use syntax::feature_gate::{GatedCfg, UnstableFeatures};
111111
use syntax::parse::{self, PResult};
112-
use syntax_pos::{hygiene, DUMMY_SP, MultiSpan, FileName};
112+
use syntax_pos::{DUMMY_SP, MultiSpan, FileName};
113113

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

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

482481
driver::spawn_thread_pool(sopts, |sopts| {
483482
run_compiler_with_pool(matches, sopts, cfg, callbacks, file_loader, emitter_dest)

src/librustdoc/test.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use syntax::codemap::CodeMap;
3737
use syntax::edition::Edition;
3838
use syntax::feature_gate::UnstableFeatures;
3939
use syntax::with_globals;
40-
use syntax_pos::{BytePos, DUMMY_SP, Pos, Span, FileName, hygiene};
40+
use syntax_pos::{BytePos, DUMMY_SP, Pos, Span, FileName};
4141
use errors;
4242
use errors::emitter::ColorConfig;
4343

@@ -562,7 +562,6 @@ impl Collector {
562562
rustc_driver::in_named_rustc_thread(name, move || with_globals(move || {
563563
io::set_panic(panic);
564564
io::set_print(print);
565-
hygiene::set_default_edition(edition);
566565
run_test(&test,
567566
&cratename,
568567
&filename,

src/test/rustdoc/async-fn.rs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// edition:2018
12+
// compile-flags:-Z unstable-options
13+
14+
// FIXME: once `--edition` is stable in rustdoc, remove that `compile-flags` directive
15+
16+
#![feature(rust_2018_preview, async_await, futures_api)]
17+
18+
// @has async_fn/struct.S.html
19+
// @has - '//code' 'pub async fn f()'
20+
pub struct S;
21+
22+
impl S {
23+
pub async fn f() {}
24+
}

0 commit comments

Comments
 (0)