about summary refs log tree commit diff
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2018-07-17 18:16:09 +0800
committerkennytm <kennytm@gmail.com>2018-07-17 19:24:57 +0800
commitc0db1aafeade826d37db3ca85087bbe349b45e9c (patch)
tree5fa2dfd62965b3d123b797c823915ed013a9e901
parentc052a491f15c917bd8a7b65983ecb422ef529ea4 (diff)
parent65e6b2b4a8f01e453e2bc27df9e0f0666904af42 (diff)
downloadrust-c0db1aafeade826d37db3ca85087bbe349b45e9c.tar.gz
rust-c0db1aafeade826d37db3ca85087bbe349b45e9c.zip
Rollup merge of #52385 - GuillaumeGomez:pass-edition-to-parser, r=QuietMisdreavus
Pass edition flags to compiler from rustdoc as expected

Fixes #52357.
-rw-r--r--src/librustdoc/test.rs3
-rw-r--r--src/test/rustdoc/edition-flag.rs24
2 files changed, 26 insertions, 1 deletions
diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs
index bd35cc0acda..b7040ed37d7 100644
--- a/src/librustdoc/test.rs
+++ b/src/librustdoc/test.rs
@@ -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};
+use syntax_pos::{BytePos, DUMMY_SP, Pos, Span, FileName, hygiene};
 use errors;
 use errors::emitter::ColorConfig;
 
@@ -561,6 +561,7 @@ impl Collector {
                     rustc_driver::in_rustc_thread(move || with_globals(move || {
                         io::set_panic(panic);
                         io::set_print(print);
+                        hygiene::set_default_edition(edition);
                         run_test(&test,
                                  &cratename,
                                  &filename,
diff --git a/src/test/rustdoc/edition-flag.rs b/src/test/rustdoc/edition-flag.rs
new file mode 100644
index 00000000000..3475b657d25
--- /dev/null
+++ b/src/test/rustdoc/edition-flag.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.
+
+// compile-flags:--test -Z unstable-options
+// edition:2018
+
+#![feature(async_await)]
+
+/// ```rust
+/// #![feature(async_await)]
+/// fn main() {
+///     let _ = async { };
+/// }
+/// ```
+fn main() {
+    let _ = async { };
+}