about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Schneider <github35764891676564198441@oli-obk.de>2018-07-17 19:56:41 +0200
committerOliver Schneider <github35764891676564198441@oli-obk.de>2018-07-17 19:56:41 +0200
commit95208044e86af21569484c67a6b5bfd7eaa32b2f (patch)
tree3ecc1b58caf59c7bc4739079cbe3ab71f0b16766
parent15a8a66d5c17868c617825ead1db05a158002384 (diff)
downloadrust-95208044e86af21569484c67a6b5bfd7eaa32b2f.tar.gz
rust-95208044e86af21569484c67a6b5bfd7eaa32b2f.zip
Make `async_idents` an edition incompat lint
-rw-r--r--src/librustc_lint/builtin.rs4
-rw-r--r--src/librustc_lint/lib.rs6
-rw-r--r--src/test/ui/auxiliary/edition-kw-macro-2015.rs1
-rw-r--r--src/test/ui/auxiliary/edition-kw-macro-2018.rs1
-rw-r--r--src/test/ui/edition-keywords-2015-2015-expansion.rs1
-rw-r--r--src/test/ui/edition-keywords-2018-2015-expansion.rs1
-rw-r--r--src/test/ui/rust-2018/async-ident.fixed61
-rw-r--r--src/test/ui/rust-2018/async-ident.rs61
-rw-r--r--src/test/ui/rust-2018/async-ident.stderr120
9 files changed, 238 insertions, 18 deletions
diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs
index 6950166a5cd..4897b7406f8 100644
--- a/src/librustc_lint/builtin.rs
+++ b/src/librustc_lint/builtin.rs
@@ -1788,7 +1788,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnnameableTestFunctions {
 
 declare_lint! {
     pub ASYNC_IDENTS,
-    Allow,
+    Deny,
     "detects `async` being used as an identifier"
 }
 
@@ -1798,7 +1798,7 @@ pub struct Async2018;
 
 impl LintPass for Async2018 {
     fn get_lints(&self) -> LintArray {
-        lint_array!()
+        lint_array!(ASYNC_IDENTS)
     }
 }
 
diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs
index 399725c0023..bb0f0e7832f 100644
--- a/src/librustc_lint/lib.rs
+++ b/src/librustc_lint/lib.rs
@@ -189,7 +189,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
     add_lint_group!(sess,
                     "rust_2018_idioms",
                     BARE_TRAIT_OBJECTS,
-                    ASYNC_IDENTS,
                     UNREACHABLE_PUB,
                     UNUSED_EXTERN_CRATES,
                     ELLIPSIS_INCLUSIVE_RANGE_PATTERNS);
@@ -225,6 +224,11 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
             edition: Some(Edition::Edition2018),
         },
         FutureIncompatibleInfo {
+            id: LintId::of(ASYNC_IDENTS),
+            reference: "issue #49716 <https://github.com/rust-lang/rust/issues/49716>",
+            edition: Some(Edition::Edition2018),
+        },
+        FutureIncompatibleInfo {
             id: LintId::of(SAFE_EXTERN_STATICS),
             reference: "issue #36247 <https://github.com/rust-lang/rust/issues/36247>",
             edition: None,
diff --git a/src/test/ui/auxiliary/edition-kw-macro-2015.rs b/src/test/ui/auxiliary/edition-kw-macro-2015.rs
index 69952e9f90a..8f80e000e3c 100644
--- a/src/test/ui/auxiliary/edition-kw-macro-2015.rs
+++ b/src/test/ui/auxiliary/edition-kw-macro-2015.rs
@@ -11,6 +11,7 @@
 // edition:2015
 
 #![feature(raw_identifiers)]
+#![allow(async_idents)]
 
 #[macro_export]
 macro_rules! produces_async {
diff --git a/src/test/ui/auxiliary/edition-kw-macro-2018.rs b/src/test/ui/auxiliary/edition-kw-macro-2018.rs
index 415988586a0..d42014766ec 100644
--- a/src/test/ui/auxiliary/edition-kw-macro-2018.rs
+++ b/src/test/ui/auxiliary/edition-kw-macro-2018.rs
@@ -11,6 +11,7 @@
 // edition:2018
 
 #![feature(raw_identifiers)]
+#![allow(async_idents)]
 
 #[macro_export]
 macro_rules! produces_async {
diff --git a/src/test/ui/edition-keywords-2015-2015-expansion.rs b/src/test/ui/edition-keywords-2015-2015-expansion.rs
index 349ab3e27ad..3b78ce80be2 100644
--- a/src/test/ui/edition-keywords-2015-2015-expansion.rs
+++ b/src/test/ui/edition-keywords-2015-2015-expansion.rs
@@ -13,6 +13,7 @@
 // compile-pass
 
 #![feature(raw_identifiers)]
+#![allow(async_idents)]
 
 #[macro_use]
 extern crate edition_kw_macro_2015;
diff --git a/src/test/ui/edition-keywords-2018-2015-expansion.rs b/src/test/ui/edition-keywords-2018-2015-expansion.rs
index 6e2073e0e49..be22d8b9b01 100644
--- a/src/test/ui/edition-keywords-2018-2015-expansion.rs
+++ b/src/test/ui/edition-keywords-2018-2015-expansion.rs
@@ -13,6 +13,7 @@
 // compile-pass
 
 #![feature(raw_identifiers)]
+#![allow(async_idents)]
 
 #[macro_use]
 extern crate edition_kw_macro_2015;
diff --git a/src/test/ui/rust-2018/async-ident.fixed b/src/test/ui/rust-2018/async-ident.fixed
index 8ede6c07bf8..dc44fec912e 100644
--- a/src/test/ui/rust-2018/async-ident.fixed
+++ b/src/test/ui/rust-2018/async-ident.fixed
@@ -9,18 +9,21 @@
 // except according to those terms.
 
 #![feature(raw_identifiers)]
-#![deny(rust_2018_idioms)]
-#![allow(dead_code)]
+#![allow(dead_code, unused_variables, non_camel_case_types, non_upper_case_globals)]
 
+// edition:2015
 // run-rustfix
 
 fn r#async() {} //~ ERROR async
+//~^ WARN hard error in the 2018 edition
 
 macro_rules! foo {
     ($foo:ident) => {};
     ($r#async:expr, r#async) => {};
     //~^ ERROR async
     //~| ERROR async
+    //~| WARN hard error in the 2018 edition
+    //~| WARN hard error in the 2018 edition
 }
 
 foo!(async);
@@ -29,4 +32,56 @@ mod dont_lint_raw {
     fn r#async() {}
 }
 
-fn main() {}
+mod async_trait {
+    trait r#async {}
+    //~^ ERROR async
+    //~| WARN hard error in the 2018 edition
+    struct MyStruct;
+    impl r#async for MyStruct {}
+    //~^ ERROR async
+    //~| WARN hard error in the 2018 edition
+}
+
+mod async_static {
+    static r#async: u32 = 0;
+    //~^ ERROR async
+    //~| WARN hard error in the 2018 edition
+}
+
+mod async_const {
+    const r#async: u32 = 0;
+    //~^ ERROR async
+    //~| WARN hard error in the 2018 edition
+}
+
+struct Foo;
+impl Foo { fn r#async() {} }
+    //~^ ERROR async
+    //~| WARN hard error in the 2018 edition
+
+fn main() {
+    struct r#async {}
+    //~^ ERROR async
+    //~| WARN hard error in the 2018 edition
+    let r#async: r#async = r#async {};
+    //~^ ERROR async
+    //~| WARN hard error in the 2018 edition
+    //~| ERROR async
+    //~| WARN hard error in the 2018 edition
+    //~| ERROR async
+    //~| WARN hard error in the 2018 edition
+}
+
+#[macro_export]
+macro_rules! produces_async {
+    () => (pub fn r#async() {})
+    //~^ ERROR async
+    //~| WARN hard error in the 2018 edition
+}
+
+#[macro_export]
+macro_rules! consumes_async {
+    (r#async) => (1)
+    //~^ ERROR async
+    //~| WARN hard error in the 2018 edition
+}
\ No newline at end of file
diff --git a/src/test/ui/rust-2018/async-ident.rs b/src/test/ui/rust-2018/async-ident.rs
index 6e529ec0229..6fffad0ce9b 100644
--- a/src/test/ui/rust-2018/async-ident.rs
+++ b/src/test/ui/rust-2018/async-ident.rs
@@ -9,18 +9,21 @@
 // except according to those terms.
 
 #![feature(raw_identifiers)]
-#![deny(rust_2018_idioms)]
-#![allow(dead_code)]
+#![allow(dead_code, unused_variables, non_camel_case_types, non_upper_case_globals)]
 
+// edition:2015
 // run-rustfix
 
 fn async() {} //~ ERROR async
+//~^ WARN hard error in the 2018 edition
 
 macro_rules! foo {
     ($foo:ident) => {};
     ($async:expr, async) => {};
     //~^ ERROR async
     //~| ERROR async
+    //~| WARN hard error in the 2018 edition
+    //~| WARN hard error in the 2018 edition
 }
 
 foo!(async);
@@ -29,4 +32,56 @@ mod dont_lint_raw {
     fn r#async() {}
 }
 
-fn main() {}
+mod async_trait {
+    trait async {}
+    //~^ ERROR async
+    //~| WARN hard error in the 2018 edition
+    struct MyStruct;
+    impl async for MyStruct {}
+    //~^ ERROR async
+    //~| WARN hard error in the 2018 edition
+}
+
+mod async_static {
+    static async: u32 = 0;
+    //~^ ERROR async
+    //~| WARN hard error in the 2018 edition
+}
+
+mod async_const {
+    const async: u32 = 0;
+    //~^ ERROR async
+    //~| WARN hard error in the 2018 edition
+}
+
+struct Foo;
+impl Foo { fn async() {} }
+    //~^ ERROR async
+    //~| WARN hard error in the 2018 edition
+
+fn main() {
+    struct async {}
+    //~^ ERROR async
+    //~| WARN hard error in the 2018 edition
+    let async: async = async {};
+    //~^ ERROR async
+    //~| WARN hard error in the 2018 edition
+    //~| ERROR async
+    //~| WARN hard error in the 2018 edition
+    //~| ERROR async
+    //~| WARN hard error in the 2018 edition
+}
+
+#[macro_export]
+macro_rules! produces_async {
+    () => (pub fn async() {})
+    //~^ ERROR async
+    //~| WARN hard error in the 2018 edition
+}
+
+#[macro_export]
+macro_rules! consumes_async {
+    (async) => (1)
+    //~^ ERROR async
+    //~| WARN hard error in the 2018 edition
+}
\ No newline at end of file
diff --git a/src/test/ui/rust-2018/async-ident.stderr b/src/test/ui/rust-2018/async-ident.stderr
index 22a3e1aedcc..85596e8fe6b 100644
--- a/src/test/ui/rust-2018/async-ident.stderr
+++ b/src/test/ui/rust-2018/async-ident.stderr
@@ -4,24 +4,126 @@ error: `async` is a keyword in the 2018 edition
 LL | fn async() {} //~ ERROR async
    |    ^^^^^ help: you can use a raw identifier to stay compatible: `r#async`
    |
-note: lint level defined here
-  --> $DIR/async-ident.rs:12:9
-   |
-LL | #![deny(rust_2018_idioms)]
-   |         ^^^^^^^^^^^^^^^^
-   = note: #[deny(async_idents)] implied by #[deny(rust_2018_idioms)]
+   = note: #[deny(async_idents)] on by default
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
 
 error: `async` is a keyword in the 2018 edition
-  --> $DIR/async-ident.rs:21:7
+  --> $DIR/async-ident.rs:22:7
    |
 LL |     ($async:expr, async) => {};
    |       ^^^^^ help: you can use a raw identifier to stay compatible: `r#async`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
 
 error: `async` is a keyword in the 2018 edition
-  --> $DIR/async-ident.rs:21:19
+  --> $DIR/async-ident.rs:22:19
    |
 LL |     ($async:expr, async) => {};
    |                   ^^^^^ help: you can use a raw identifier to stay compatible: `r#async`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: `async` is a keyword in the 2018 edition
+  --> $DIR/async-ident.rs:36:11
+   |
+LL |     trait async {}
+   |           ^^^^^ help: you can use a raw identifier to stay compatible: `r#async`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: `async` is a keyword in the 2018 edition
+  --> $DIR/async-ident.rs:40:10
+   |
+LL |     impl async for MyStruct {}
+   |          ^^^^^ help: you can use a raw identifier to stay compatible: `r#async`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: `async` is a keyword in the 2018 edition
+  --> $DIR/async-ident.rs:46:12
+   |
+LL |     static async: u32 = 0;
+   |            ^^^^^ help: you can use a raw identifier to stay compatible: `r#async`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: `async` is a keyword in the 2018 edition
+  --> $DIR/async-ident.rs:52:11
+   |
+LL |     const async: u32 = 0;
+   |           ^^^^^ help: you can use a raw identifier to stay compatible: `r#async`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: `async` is a keyword in the 2018 edition
+  --> $DIR/async-ident.rs:58:15
+   |
+LL | impl Foo { fn async() {} }
+   |               ^^^^^ help: you can use a raw identifier to stay compatible: `r#async`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: `async` is a keyword in the 2018 edition
+  --> $DIR/async-ident.rs:63:12
+   |
+LL |     struct async {}
+   |            ^^^^^ help: you can use a raw identifier to stay compatible: `r#async`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: `async` is a keyword in the 2018 edition
+  --> $DIR/async-ident.rs:66:9
+   |
+LL |     let async: async = async {};
+   |         ^^^^^ help: you can use a raw identifier to stay compatible: `r#async`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: `async` is a keyword in the 2018 edition
+  --> $DIR/async-ident.rs:66:16
+   |
+LL |     let async: async = async {};
+   |                ^^^^^ help: you can use a raw identifier to stay compatible: `r#async`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: `async` is a keyword in the 2018 edition
+  --> $DIR/async-ident.rs:66:24
+   |
+LL |     let async: async = async {};
+   |                        ^^^^^ help: you can use a raw identifier to stay compatible: `r#async`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: `async` is a keyword in the 2018 edition
+  --> $DIR/async-ident.rs:77:19
+   |
+LL |     () => (pub fn async() {})
+   |                   ^^^^^ help: you can use a raw identifier to stay compatible: `r#async`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: `async` is a keyword in the 2018 edition
+  --> $DIR/async-ident.rs:84:6
+   |
+LL |     (async) => (1)
+   |      ^^^^^ help: you can use a raw identifier to stay compatible: `r#async`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
 
-error: aborting due to 3 previous errors
+error: aborting due to 14 previous errors