diff --git a/src/test/run-pass/auxiliary/edition-kw-macro-2015.rs b/src/test/run-pass/auxiliary/edition-kw-macro-2015.rs new file mode 100644 index 00000000000..1dc0562a9f0 --- /dev/null +++ b/src/test/run-pass/auxiliary/edition-kw-macro-2015.rs @@ -0,0 +1,65 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --edition=2015 + +#![feature(raw_identifiers)] + +// `async` +#[macro_export] +macro_rules! produces_async { + () => (pub fn async() {}) +} + +#[macro_export] +macro_rules! produces_async_raw { + () => (pub fn r#async() {}) +} + +#[macro_export] +macro_rules! consumes_async { + (async) => (1) +} + +#[macro_export] +macro_rules! consumes_async_raw { + (r#async) => (1) +} + +#[macro_export] +macro_rules! passes_ident { + ($i: ident) => ($i) +} + +// `proc` +#[macro_export] +macro_rules! produces_proc { + () => (pub fn proc() {}) +} + +#[macro_export] +macro_rules! produces_proc_raw { + () => (pub fn r#proc() {}) +} + +#[macro_export] +macro_rules! consumes_proc { + (proc) => (1) +} + +#[macro_export] +macro_rules! consumes_proc_raw { + (r#proc) => (1) +} + +#[macro_export] +macro_rules! passes_ident { + ($i: ident) => ($i) +} diff --git a/src/test/run-pass/auxiliary/edition-kw-macro-2018.rs b/src/test/run-pass/auxiliary/edition-kw-macro-2018.rs new file mode 100644 index 00000000000..fb018a36231 --- /dev/null +++ b/src/test/run-pass/auxiliary/edition-kw-macro-2018.rs @@ -0,0 +1,65 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --edition=2018 + +#![feature(raw_identifiers)] + +// `async` +#[macro_export] +macro_rules! produces_async { + () => (pub fn async() {}) +} + +#[macro_export] +macro_rules! produces_async_raw { + () => (pub fn r#async() {}) +} + +#[macro_export] +macro_rules! consumes_async { + (async) => (1) +} + +#[macro_export] +macro_rules! consumes_async_raw { + (r#async) => (1) +} + +#[macro_export] +macro_rules! passes_ident { + ($i: ident) => ($i) +} + +// `proc` +#[macro_export] +macro_rules! produces_proc { + () => (pub fn proc() {}) +} + +#[macro_export] +macro_rules! produces_proc_raw { + () => (pub fn r#proc() {}) +} + +#[macro_export] +macro_rules! consumes_proc { + (proc) => (1) +} + +#[macro_export] +macro_rules! consumes_proc_raw { + (r#proc) => (1) +} + +#[macro_export] +macro_rules! passes_ident { + ($i: ident) => ($i) +} diff --git a/src/test/run-pass/edition-keywords-2015-2015.rs b/src/test/run-pass/edition-keywords-2015-2015.rs new file mode 100644 index 00000000000..b66d35cfc37 --- /dev/null +++ b/src/test/run-pass/edition-keywords-2015-2015.rs @@ -0,0 +1,69 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --edition=2015 +// aux-build:edition-kw-macro-2015.rs + +#![feature(raw_identifiers)] + +#[macro_use] +extern crate edition_kw_macro_2015; + +// `async` +pub fn check_async() { + let mut async = 1; // OK + let mut r#async = 1; // OK + + r#async = consumes_async!(async); // OK + // r#async = consumes_async!(r#async); // ERROR, not a match + // r#async = consumes_async_raw!(async); // ERROR, not a match + r#async = consumes_async_raw!(r#async); // OK + + if passes_ident!(async) == 1 {} // OK + if passes_ident!(r#async) == 1 {} // OK + one_async::async(); // OK + one_async::r#async(); // OK + two_async::async(); // OK + two_async::r#async(); // OK +} + +mod one_async { + produces_async! {} // OK +} +mod two_async { + produces_async_raw! {} // OK +} + +// `proc` +pub fn check_proc() { + // let mut proc = 1; // ERROR, reserved + let mut r#proc = 1; // OK + + r#proc = consumes_proc!(proc); // OK + // r#proc = consumes_proc!(r#proc); // ERROR, not a match + // r#proc = consumes_proc_raw!(proc); // ERROR, not a match + r#proc = consumes_proc_raw!(r#proc); // OK + + // if passes_ident!(proc) == 1 {} // ERROR, reserved + if passes_ident!(r#proc) == 1 {} // OK + // one_proc::proc(); // ERROR, reserved + // one_proc::r#proc(); // ERROR, unresolved name + // two_proc::proc(); // ERROR, reserved + two_proc::r#proc(); // OK +} + +mod one_proc { + // produces_proc! {} // ERROR, reserved +} +mod two_proc { + produces_proc_raw! {} // OK +} + +fn main() {} diff --git a/src/test/run-pass/edition-keywords-2015-2018.rs b/src/test/run-pass/edition-keywords-2015-2018.rs new file mode 100644 index 00000000000..7395ffc23c7 --- /dev/null +++ b/src/test/run-pass/edition-keywords-2015-2018.rs @@ -0,0 +1,69 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --edition=2015 +// aux-build:edition-kw-macro-2018.rs + +#![feature(raw_identifiers)] + +#[macro_use] +extern crate edition_kw_macro_2018; + +// `async` +pub fn check_async() { + let mut async = 1; // OK + let mut r#async = 1; // OK + + r#async = consumes_async!(async); // OK + // r#async = consumes_async!(r#async); // ERROR, not a match + // r#async = consumes_async_raw!(async); // ERROR, not a match + r#async = consumes_async_raw!(r#async); // OK + + if passes_ident!(async) == 1 {} // OK + if passes_ident!(r#async) == 1 {} // OK + one_async::async(); // OK + one_async::r#async(); // OK + two_async::async(); // OK + two_async::r#async(); // OK +} + +mod one_async { + produces_async! {} // ERROR, FIXME +} +mod two_async { + produces_async_raw! {} // OK +} + +// `proc` +pub fn check_proc() { + // let mut proc = 1; // ERROR, reserved + let mut r#proc = 1; // OK + + r#proc = consumes_proc!(proc); // OK + // r#proc = consumes_proc!(r#proc); // ERROR, not a match + // r#proc = consumes_proc_raw!(proc); // ERROR, not a match + r#proc = consumes_proc_raw!(r#proc); // OK + + // if passes_ident!(proc) == 1 {} // ERROR, reserved + if passes_ident!(r#proc) == 1 {} // OK + // one_proc::proc(); // ERROR, reserved + // one_proc::r#proc(); // OK, FIXME + // two_proc::proc(); // ERROR, reserved + two_proc::r#proc(); // OK +} + +mod one_proc { + // produces_proc! {} // OK, FIXME +} +mod two_proc { + produces_proc_raw! {} // OK +} + +fn main() {} diff --git a/src/test/run-pass/edition-keywords-2018-2015.rs b/src/test/run-pass/edition-keywords-2018-2015.rs new file mode 100644 index 00000000000..f131d2143ef --- /dev/null +++ b/src/test/run-pass/edition-keywords-2018-2015.rs @@ -0,0 +1,69 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --edition=2018 +// aux-build:edition-kw-macro-2015.rs + +#![feature(raw_identifiers)] + +#[macro_use] +extern crate edition_kw_macro_2015; + +// `async` +pub fn check_async() { + // let mut async = 1; // ERROR, reserved + let mut r#async = 1; // OK + + r#async = consumes_async!(async); // OK + // r#async = consumes_async!(r#async); // ERROR, not a match + // r#async = consumes_async_raw!(async); // ERROR, not a match + r#async = consumes_async_raw!(r#async); // OK + + // if passes_ident!(async) == 1 {} // ERROR, reserved + if passes_ident!(r#async) == 1 {} // OK + // one_async::async(); // ERROR, reserved + // one_async::r#async(); // OK, FIXME + // two_async::async(); // ERROR, reserved + two_async::r#async(); // OK +} + +mod one_async { + // produces_async! {} // OK, FIXME +} +mod two_async { + produces_async_raw! {} // OK +} + +// `proc` +pub fn check_proc() { + let mut proc = 1; // OK + let mut r#proc = 1; // OK + + r#proc = consumes_proc!(proc); // OK + // r#proc = consumes_proc!(r#proc); // ERROR, not a match + // r#proc = consumes_proc_raw!(proc); // ERROR, not a match + r#proc = consumes_proc_raw!(r#proc); // OK + + if passes_ident!(proc) == 1 {} // OK + if passes_ident!(r#proc) == 1 {} // OK + one_proc::proc(); // OK + one_proc::r#proc(); // OK + two_proc::proc(); // OK + two_proc::r#proc(); // OK +} + +mod one_proc { + produces_proc! {} // ERROR, FIXME +} +mod two_proc { + produces_proc_raw! {} // OK +} + +fn main() {} diff --git a/src/test/run-pass/edition-keywords-2018-2018.rs b/src/test/run-pass/edition-keywords-2018-2018.rs new file mode 100644 index 00000000000..e3da165eb35 --- /dev/null +++ b/src/test/run-pass/edition-keywords-2018-2018.rs @@ -0,0 +1,69 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --edition=2018 +// aux-build:edition-kw-macro-2018.rs + +#![feature(raw_identifiers)] + +#[macro_use] +extern crate edition_kw_macro_2018; + +// `async` +pub fn check_async() { + // let mut async = 1; // ERROR, reserved + let mut r#async = 1; // OK + + r#async = consumes_async!(async); // OK + // r#async = consumes_async!(r#async); // ERROR, not a match + // r#async = consumes_async_raw!(async); // ERROR, not a match + r#async = consumes_async_raw!(r#async); // OK + + // if passes_ident!(async) == 1 {} // ERROR, reserved + if passes_ident!(r#async) == 1 {} // OK + // one_async::async(); // ERROR, reserved + // one_async::r#async(); // ERROR, unresolved name + // two_async::async(); // ERROR, reserved + two_async::r#async(); // OK +} + +mod one_async { + // produces_async! {} // ERROR, reserved +} +mod two_async { + produces_async_raw! {} // OK +} + +// `proc` +pub fn check_proc() { + let mut proc = 1; // OK + let mut r#proc = 1; // OK + + r#proc = consumes_proc!(proc); // OK + // r#proc = consumes_proc!(r#proc); // ERROR, not a match + // r#proc = consumes_proc_raw!(proc); // ERROR, not a match + r#proc = consumes_proc_raw!(r#proc); // OK + + if passes_ident!(proc) == 1 {} // OK + if passes_ident!(r#proc) == 1 {} // OK + one_proc::proc(); // OK + one_proc::r#proc(); // OK + two_proc::proc(); // OK + two_proc::r#proc(); // OK +} + +mod one_proc { + produces_proc! {} // OK +} +mod two_proc { + produces_proc_raw! {} // OK +} + +fn main() {} diff --git a/src/test/ui/auxiliary/edition-kw-macro-2015.rs b/src/test/ui/auxiliary/edition-kw-macro-2015.rs new file mode 100644 index 00000000000..1dc0562a9f0 --- /dev/null +++ b/src/test/ui/auxiliary/edition-kw-macro-2015.rs @@ -0,0 +1,65 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --edition=2015 + +#![feature(raw_identifiers)] + +// `async` +#[macro_export] +macro_rules! produces_async { + () => (pub fn async() {}) +} + +#[macro_export] +macro_rules! produces_async_raw { + () => (pub fn r#async() {}) +} + +#[macro_export] +macro_rules! consumes_async { + (async) => (1) +} + +#[macro_export] +macro_rules! consumes_async_raw { + (r#async) => (1) +} + +#[macro_export] +macro_rules! passes_ident { + ($i: ident) => ($i) +} + +// `proc` +#[macro_export] +macro_rules! produces_proc { + () => (pub fn proc() {}) +} + +#[macro_export] +macro_rules! produces_proc_raw { + () => (pub fn r#proc() {}) +} + +#[macro_export] +macro_rules! consumes_proc { + (proc) => (1) +} + +#[macro_export] +macro_rules! consumes_proc_raw { + (r#proc) => (1) +} + +#[macro_export] +macro_rules! passes_ident { + ($i: ident) => ($i) +} diff --git a/src/test/ui/auxiliary/edition-kw-macro-2018.rs b/src/test/ui/auxiliary/edition-kw-macro-2018.rs new file mode 100644 index 00000000000..fb018a36231 --- /dev/null +++ b/src/test/ui/auxiliary/edition-kw-macro-2018.rs @@ -0,0 +1,65 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --edition=2018 + +#![feature(raw_identifiers)] + +// `async` +#[macro_export] +macro_rules! produces_async { + () => (pub fn async() {}) +} + +#[macro_export] +macro_rules! produces_async_raw { + () => (pub fn r#async() {}) +} + +#[macro_export] +macro_rules! consumes_async { + (async) => (1) +} + +#[macro_export] +macro_rules! consumes_async_raw { + (r#async) => (1) +} + +#[macro_export] +macro_rules! passes_ident { + ($i: ident) => ($i) +} + +// `proc` +#[macro_export] +macro_rules! produces_proc { + () => (pub fn proc() {}) +} + +#[macro_export] +macro_rules! produces_proc_raw { + () => (pub fn r#proc() {}) +} + +#[macro_export] +macro_rules! consumes_proc { + (proc) => (1) +} + +#[macro_export] +macro_rules! consumes_proc_raw { + (r#proc) => (1) +} + +#[macro_export] +macro_rules! passes_ident { + ($i: ident) => ($i) +} diff --git a/src/test/ui/edition-keywords-2015-2015-expansion.rs b/src/test/ui/edition-keywords-2015-2015-expansion.rs new file mode 100644 index 00000000000..13d95e6751e --- /dev/null +++ b/src/test/ui/edition-keywords-2015-2015-expansion.rs @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --edition=2015 +// aux-build:edition-kw-macro-2015.rs + +#![feature(raw_identifiers)] + +#[macro_use] +extern crate edition_kw_macro_2015; + +// `async` +mod one_async { + produces_async! {} // OK +} +mod two_async { + produces_async_raw! {} // OK +} + +// `proc` +mod one_proc { + produces_proc! {} // ERROR expected identifier, found reserved keyword `proc` +} +mod two_proc { + produces_proc_raw! {} // OK +} diff --git a/src/test/ui/edition-keywords-2015-2015-expansion.stderr b/src/test/ui/edition-keywords-2015-2015-expansion.stderr new file mode 100644 index 00000000000..dd4a35c1f05 --- /dev/null +++ b/src/test/ui/edition-keywords-2015-2015-expansion.stderr @@ -0,0 +1,10 @@ +error: expected identifier, found reserved keyword `proc` + --> $DIR/edition-keywords-2015-2015-expansion.rs:29:5 + | +LL | produces_proc! {} // ERROR expected identifier, found reserved keyword `proc` + | ^^^^^^^^^^^^^^^^^ expected identifier, found reserved keyword + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: aborting due to previous error + diff --git a/src/test/ui/edition-keywords-2015-2015-parsing.rs b/src/test/ui/edition-keywords-2015-2015-parsing.rs new file mode 100644 index 00000000000..1f8390796d3 --- /dev/null +++ b/src/test/ui/edition-keywords-2015-2015-parsing.rs @@ -0,0 +1,49 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --edition=2015 +// aux-build:edition-kw-macro-2015.rs + +#![feature(raw_identifiers)] + +#[macro_use] +extern crate edition_kw_macro_2015; + +// `async` +pub fn check_async() { + let mut async = 1; // OK + let mut r#async = 1; // OK + + r#async = consumes_async!(async); // OK + r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async` + r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async` + r#async = consumes_async_raw!(r#async); // OK + + if passes_ident!(async) == 1 {} // OK + if passes_ident!(r#async) == 1 {} // OK + module::async(); // OK + module::r#async(); // OK +} + +// `proc` +pub fn check_proc() { + let mut proc = 1; //~ ERROR expected identifier, found reserved keyword `proc` + let mut r#proc = 1; // OK + + r#proc = consumes_proc!(proc); // OK + r#proc = consumes_proc!(r#proc); //~ ERROR no rules expected the token `r#proc` + r#proc = consumes_proc_raw!(proc); //~ ERROR no rules expected the token `proc` + r#proc = consumes_proc_raw!(r#proc); // OK + + if passes_ident!(proc) == 1 {} //~ ERROR expected expression, found reserved keyword `proc` + if passes_ident!(r#proc) == 1 {} // OK + module::proc(); //~ ERROR expected identifier, found reserved keyword `proc` + module::r#proc(); // OK +} diff --git a/src/test/ui/edition-keywords-2015-2015-parsing.stderr b/src/test/ui/edition-keywords-2015-2015-parsing.stderr new file mode 100644 index 00000000000..c40de006edc --- /dev/null +++ b/src/test/ui/edition-keywords-2015-2015-parsing.stderr @@ -0,0 +1,44 @@ +error: expected identifier, found reserved keyword `proc` + --> $DIR/edition-keywords-2015-2015-parsing.rs:37:13 + | +LL | let mut proc = 1; //~ ERROR expected identifier, found reserved keyword `proc` + | ^^^^ expected identifier, found reserved keyword + +error: expected identifier, found reserved keyword `proc` + --> $DIR/edition-keywords-2015-2015-parsing.rs:47:13 + | +LL | module::proc(); //~ ERROR expected identifier, found reserved keyword `proc` + | ^^^^ expected identifier, found reserved keyword + +error: no rules expected the token `r#async` + --> $DIR/edition-keywords-2015-2015-parsing.rs:25:31 + | +LL | r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async` + | ^^^^^^^ + +error: no rules expected the token `async` + --> $DIR/edition-keywords-2015-2015-parsing.rs:26:35 + | +LL | r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async` + | ^^^^^ + +error: no rules expected the token `r#proc` + --> $DIR/edition-keywords-2015-2015-parsing.rs:41:29 + | +LL | r#proc = consumes_proc!(r#proc); //~ ERROR no rules expected the token `r#proc` + | ^^^^^^ + +error: no rules expected the token `proc` + --> $DIR/edition-keywords-2015-2015-parsing.rs:42:33 + | +LL | r#proc = consumes_proc_raw!(proc); //~ ERROR no rules expected the token `proc` + | ^^^^ + +error: expected expression, found reserved keyword `proc` + --> $DIR/edition-keywords-2015-2015-parsing.rs:45:22 + | +LL | if passes_ident!(proc) == 1 {} //~ ERROR expected expression, found reserved keyword `proc` + | ^^^^ expected expression + +error: aborting due to 7 previous errors + diff --git a/src/test/ui/edition-keywords-2015-2018-expansion.rs b/src/test/ui/edition-keywords-2015-2018-expansion.rs new file mode 100644 index 00000000000..7d6c55a523e --- /dev/null +++ b/src/test/ui/edition-keywords-2015-2018-expansion.rs @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --edition=2015 +// aux-build:edition-kw-macro-2018.rs + +#![feature(raw_identifiers)] + +#[macro_use] +extern crate edition_kw_macro_2018; + +// `async` +mod one_async { + produces_async! {} // ERROR, FIXME +} +mod two_async { + produces_async_raw! {} // OK +} + +// `proc` +mod one_proc { + produces_proc! {} // OK, FIXME +} +mod two_proc { + produces_proc_raw! {} // OK +} diff --git a/src/test/ui/edition-keywords-2015-2018-expansion.stderr b/src/test/ui/edition-keywords-2015-2018-expansion.stderr new file mode 100644 index 00000000000..66759387b2a --- /dev/null +++ b/src/test/ui/edition-keywords-2015-2018-expansion.stderr @@ -0,0 +1,10 @@ +error: expected identifier, found reserved keyword `proc` + --> $DIR/edition-keywords-2015-2018-expansion.rs:29:5 + | +LL | produces_proc! {} // OK, FIXME + | ^^^^^^^^^^^^^^^^^ expected identifier, found reserved keyword + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: aborting due to previous error + diff --git a/src/test/ui/edition-keywords-2015-2018-parsing.rs b/src/test/ui/edition-keywords-2015-2018-parsing.rs new file mode 100644 index 00000000000..6405a94f842 --- /dev/null +++ b/src/test/ui/edition-keywords-2015-2018-parsing.rs @@ -0,0 +1,49 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --edition=2015 +// aux-build:edition-kw-macro-2018.rs + +#![feature(raw_identifiers)] + +#[macro_use] +extern crate edition_kw_macro_2018; + +// `async` +pub fn check_async() { + let mut async = 1; // OK + let mut r#async = 1; // OK + + r#async = consumes_async!(async); // OK + r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async` + r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async` + r#async = consumes_async_raw!(r#async); // OK + + if passes_ident!(async) == 1 {} // OK + if passes_ident!(r#async) == 1 {} // OK + module::async(); // OK + module::r#async(); // OK +} + +// `proc` +pub fn check_proc() { + let mut proc = 1; //~ ERROR expected identifier, found reserved keyword `proc` + let mut r#proc = 1; // OK + + r#proc = consumes_proc!(proc); // OK + r#proc = consumes_proc!(r#proc); //~ ERROR no rules expected the token `r#proc` + r#proc = consumes_proc_raw!(proc); //~ ERROR no rules expected the token `proc` + r#proc = consumes_proc_raw!(r#proc); // OK + + if passes_ident!(proc) == 1 {} //~ ERROR expected expression, found reserved keyword `proc` + if passes_ident!(r#proc) == 1 {} // OK + module::proc(); //~ ERROR expected identifier, found reserved keyword `proc` + module::r#proc(); // OK +} diff --git a/src/test/ui/edition-keywords-2015-2018-parsing.stderr b/src/test/ui/edition-keywords-2015-2018-parsing.stderr new file mode 100644 index 00000000000..3510f898025 --- /dev/null +++ b/src/test/ui/edition-keywords-2015-2018-parsing.stderr @@ -0,0 +1,44 @@ +error: expected identifier, found reserved keyword `proc` + --> $DIR/edition-keywords-2015-2018-parsing.rs:37:13 + | +LL | let mut proc = 1; //~ ERROR expected identifier, found reserved keyword `proc` + | ^^^^ expected identifier, found reserved keyword + +error: expected identifier, found reserved keyword `proc` + --> $DIR/edition-keywords-2015-2018-parsing.rs:47:13 + | +LL | module::proc(); //~ ERROR expected identifier, found reserved keyword `proc` + | ^^^^ expected identifier, found reserved keyword + +error: no rules expected the token `r#async` + --> $DIR/edition-keywords-2015-2018-parsing.rs:25:31 + | +LL | r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async` + | ^^^^^^^ + +error: no rules expected the token `async` + --> $DIR/edition-keywords-2015-2018-parsing.rs:26:35 + | +LL | r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async` + | ^^^^^ + +error: no rules expected the token `r#proc` + --> $DIR/edition-keywords-2015-2018-parsing.rs:41:29 + | +LL | r#proc = consumes_proc!(r#proc); //~ ERROR no rules expected the token `r#proc` + | ^^^^^^ + +error: no rules expected the token `proc` + --> $DIR/edition-keywords-2015-2018-parsing.rs:42:33 + | +LL | r#proc = consumes_proc_raw!(proc); //~ ERROR no rules expected the token `proc` + | ^^^^ + +error: expected expression, found reserved keyword `proc` + --> $DIR/edition-keywords-2015-2018-parsing.rs:45:22 + | +LL | if passes_ident!(proc) == 1 {} //~ ERROR expected expression, found reserved keyword `proc` + | ^^^^ expected expression + +error: aborting due to 7 previous errors + diff --git a/src/test/ui/edition-keywords-2018-2015-expansion.rs b/src/test/ui/edition-keywords-2018-2015-expansion.rs new file mode 100644 index 00000000000..7543920b328 --- /dev/null +++ b/src/test/ui/edition-keywords-2018-2015-expansion.rs @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --edition=2018 +// aux-build:edition-kw-macro-2015.rs + +#![feature(raw_identifiers)] + +#[macro_use] +extern crate edition_kw_macro_2015; + +// `async` +mod one_async { + produces_async! {} // OK, FIXME +} +mod two_async { + produces_async_raw! {} // OK +} + +// `proc` +mod one_proc { + produces_proc! {} // ERROR, FIXME +} +mod two_proc { + produces_proc_raw! {} // OK +} diff --git a/src/test/ui/edition-keywords-2018-2015-expansion.stderr b/src/test/ui/edition-keywords-2018-2015-expansion.stderr new file mode 100644 index 00000000000..14f90292fb1 --- /dev/null +++ b/src/test/ui/edition-keywords-2018-2015-expansion.stderr @@ -0,0 +1,10 @@ +error: expected identifier, found reserved keyword `async` + --> $DIR/edition-keywords-2018-2015-expansion.rs:21:5 + | +LL | produces_async! {} // OK, FIXME + | ^^^^^^^^^^^^^^^^^^ expected identifier, found reserved keyword + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: aborting due to previous error + diff --git a/src/test/ui/edition-keywords-2018-2015-parsing.rs b/src/test/ui/edition-keywords-2018-2015-parsing.rs new file mode 100644 index 00000000000..26a503d642d --- /dev/null +++ b/src/test/ui/edition-keywords-2018-2015-parsing.rs @@ -0,0 +1,49 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --edition=2018 +// aux-build:edition-kw-macro-2015.rs + +#![feature(raw_identifiers)] + +#[macro_use] +extern crate edition_kw_macro_2015; + +// `proc` +pub fn check_proc() { + let mut proc = 1; // OK + let mut r#proc = 1; // OK + + r#proc = consumes_proc!(proc); // OK + r#proc = consumes_proc!(r#proc); //~ ERROR no rules expected the token `r#proc` + r#proc = consumes_proc_raw!(proc); //~ ERROR no rules expected the token `proc` + r#proc = consumes_proc_raw!(r#proc); // OK + + if passes_ident!(proc) == 1 {} // OK + if passes_ident!(r#proc) == 1 {} // OK + module::proc(); // OK + module::r#proc(); // OK +} + +// `async` +pub fn check_async() { + let mut async = 1; //~ ERROR expected identifier, found reserved keyword `async` + let mut r#async = 1; // OK + + r#async = consumes_async!(async); // OK + r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async` + r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async` + r#async = consumes_async_raw!(r#async); // OK + + if passes_ident!(async) == 1 {} //~ ERROR expected expression, found reserved keyword `async` + if passes_ident!(r#async) == 1 {} // OK + module::async(); //~ ERROR expected identifier, found reserved keyword `async` + module::r#async(); // OK +} diff --git a/src/test/ui/edition-keywords-2018-2015-parsing.stderr b/src/test/ui/edition-keywords-2018-2015-parsing.stderr new file mode 100644 index 00000000000..d39d5a8a901 --- /dev/null +++ b/src/test/ui/edition-keywords-2018-2015-parsing.stderr @@ -0,0 +1,44 @@ +error: expected identifier, found reserved keyword `async` + --> $DIR/edition-keywords-2018-2015-parsing.rs:37:13 + | +LL | let mut async = 1; //~ ERROR expected identifier, found reserved keyword `async` + | ^^^^^ expected identifier, found reserved keyword + +error: expected identifier, found reserved keyword `async` + --> $DIR/edition-keywords-2018-2015-parsing.rs:47:13 + | +LL | module::async(); //~ ERROR expected identifier, found reserved keyword `async` + | ^^^^^ expected identifier, found reserved keyword + +error: no rules expected the token `r#proc` + --> $DIR/edition-keywords-2018-2015-parsing.rs:25:29 + | +LL | r#proc = consumes_proc!(r#proc); //~ ERROR no rules expected the token `r#proc` + | ^^^^^^ + +error: no rules expected the token `proc` + --> $DIR/edition-keywords-2018-2015-parsing.rs:26:33 + | +LL | r#proc = consumes_proc_raw!(proc); //~ ERROR no rules expected the token `proc` + | ^^^^ + +error: no rules expected the token `r#async` + --> $DIR/edition-keywords-2018-2015-parsing.rs:41:31 + | +LL | r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async` + | ^^^^^^^ + +error: no rules expected the token `async` + --> $DIR/edition-keywords-2018-2015-parsing.rs:42:35 + | +LL | r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async` + | ^^^^^ + +error: expected expression, found reserved keyword `async` + --> $DIR/edition-keywords-2018-2015-parsing.rs:45:22 + | +LL | if passes_ident!(async) == 1 {} //~ ERROR expected expression, found reserved keyword `async` + | ^^^^^ expected expression + +error: aborting due to 7 previous errors + diff --git a/src/test/ui/edition-keywords-2018-2018-expansion.rs b/src/test/ui/edition-keywords-2018-2018-expansion.rs new file mode 100644 index 00000000000..55732da8bc0 --- /dev/null +++ b/src/test/ui/edition-keywords-2018-2018-expansion.rs @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --edition=2018 +// aux-build:edition-kw-macro-2018.rs + +#![feature(raw_identifiers)] + +#[macro_use] +extern crate edition_kw_macro_2018; + +// `async` +mod one_async { + produces_async! {} // ERROR expected identifier, found reserved keyword `async` +} +mod two_async { + produces_async_raw! {} // OK +} + +// `proc` +mod one_proc { + produces_proc! {} // OK +} +mod two_proc { + produces_proc_raw! {} // OK +} diff --git a/src/test/ui/edition-keywords-2018-2018-expansion.stderr b/src/test/ui/edition-keywords-2018-2018-expansion.stderr new file mode 100644 index 00000000000..236409c9628 --- /dev/null +++ b/src/test/ui/edition-keywords-2018-2018-expansion.stderr @@ -0,0 +1,10 @@ +error: expected identifier, found reserved keyword `async` + --> $DIR/edition-keywords-2018-2018-expansion.rs:21:5 + | +LL | produces_async! {} // ERROR expected identifier, found reserved keyword `async` + | ^^^^^^^^^^^^^^^^^^ expected identifier, found reserved keyword + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: aborting due to previous error + diff --git a/src/test/ui/edition-keywords-2018-2018-parsing.rs b/src/test/ui/edition-keywords-2018-2018-parsing.rs new file mode 100644 index 00000000000..7fc7450d5b2 --- /dev/null +++ b/src/test/ui/edition-keywords-2018-2018-parsing.rs @@ -0,0 +1,49 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --edition=2018 +// aux-build:edition-kw-macro-2018.rs + +#![feature(raw_identifiers)] + +#[macro_use] +extern crate edition_kw_macro_2018; + +// `proc` +pub fn check_proc() { + let mut proc = 1; // OK + let mut r#proc = 1; // OK + + r#proc = consumes_proc!(proc); // OK + r#proc = consumes_proc!(r#proc); //~ ERROR no rules expected the token `r#proc` + r#proc = consumes_proc_raw!(proc); //~ ERROR no rules expected the token `proc` + r#proc = consumes_proc_raw!(r#proc); // OK + + if passes_ident!(proc) == 1 {} // OK + if passes_ident!(r#proc) == 1 {} // OK + module::proc(); // OK + module::r#proc(); // OK +} + +// `async` +pub fn check_async() { + let mut async = 1; //~ ERROR expected identifier, found reserved keyword `async` + let mut r#async = 1; // OK + + r#async = consumes_async!(async); // OK + r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async` + r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async` + r#async = consumes_async_raw!(r#async); // OK + + if passes_ident!(async) == 1 {} //~ ERROR expected expression, found reserved keyword `async` + if passes_ident!(r#async) == 1 {} // OK + module::async(); //~ ERROR expected identifier, found reserved keyword `async` + module::r#async(); // OK +} diff --git a/src/test/ui/edition-keywords-2018-2018-parsing.stderr b/src/test/ui/edition-keywords-2018-2018-parsing.stderr new file mode 100644 index 00000000000..fba1ec6d18a --- /dev/null +++ b/src/test/ui/edition-keywords-2018-2018-parsing.stderr @@ -0,0 +1,44 @@ +error: expected identifier, found reserved keyword `async` + --> $DIR/edition-keywords-2018-2018-parsing.rs:37:13 + | +LL | let mut async = 1; //~ ERROR expected identifier, found reserved keyword `async` + | ^^^^^ expected identifier, found reserved keyword + +error: expected identifier, found reserved keyword `async` + --> $DIR/edition-keywords-2018-2018-parsing.rs:47:13 + | +LL | module::async(); //~ ERROR expected identifier, found reserved keyword `async` + | ^^^^^ expected identifier, found reserved keyword + +error: no rules expected the token `r#proc` + --> $DIR/edition-keywords-2018-2018-parsing.rs:25:29 + | +LL | r#proc = consumes_proc!(r#proc); //~ ERROR no rules expected the token `r#proc` + | ^^^^^^ + +error: no rules expected the token `proc` + --> $DIR/edition-keywords-2018-2018-parsing.rs:26:33 + | +LL | r#proc = consumes_proc_raw!(proc); //~ ERROR no rules expected the token `proc` + | ^^^^ + +error: no rules expected the token `r#async` + --> $DIR/edition-keywords-2018-2018-parsing.rs:41:31 + | +LL | r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async` + | ^^^^^^^ + +error: no rules expected the token `async` + --> $DIR/edition-keywords-2018-2018-parsing.rs:42:35 + | +LL | r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async` + | ^^^^^ + +error: expected expression, found reserved keyword `async` + --> $DIR/edition-keywords-2018-2018-parsing.rs:45:22 + | +LL | if passes_ident!(async) == 1 {} //~ ERROR expected expression, found reserved keyword `async` + | ^^^^^ expected expression + +error: aborting due to 7 previous errors +