]> git.lizzy.rs Git - rust.git/commitdiff
Pass edition flags to compiler from rustdoc as expected
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Sat, 14 Jul 2018 18:45:44 +0000 (20:45 +0200)
committerGuillaume Gomez <guillaume1.gomez@gmail.com>
Sat, 14 Jul 2018 18:45:44 +0000 (20:45 +0200)
src/librustdoc/test.rs
src/test/rustdoc/edition-flag.rs [new file with mode: 0644]

index 53032b9b98c5d79fa7305720637c76025a310071..eb57ca74755f67765814b71269629f9cff8db802 100644 (file)
@@ -37,7 +37,7 @@
 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 @@ pub fn add_test(&mut self, test: String,
                     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 (file)
index 0000000..3475b65
--- /dev/null
@@ -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 { };
+}