Make async_idents an edition incompat lint

This commit is contained in:
Oliver Schneider 2018-07-17 19:56:41 +02:00
parent 15a8a66d5c
commit 95208044e8
9 changed files with 238 additions and 18 deletions

View File

@ -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)
}
}

View File

@ -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);
@ -224,6 +223,11 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
reference: "issue #35896 <https://github.com/rust-lang/rust/issues/35896>",
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>",

View File

@ -11,6 +11,7 @@
// edition:2015
#![feature(raw_identifiers)]
#![allow(async_idents)]
#[macro_export]
macro_rules! produces_async {

View File

@ -11,6 +11,7 @@
// edition:2018
#![feature(raw_identifiers)]
#![allow(async_idents)]
#[macro_export]
macro_rules! produces_async {

View File

@ -13,6 +13,7 @@
// compile-pass
#![feature(raw_identifiers)]
#![allow(async_idents)]
#[macro_use]
extern crate edition_kw_macro_2015;

View File

@ -13,6 +13,7 @@
// compile-pass
#![feature(raw_identifiers)]
#![allow(async_idents)]
#[macro_use]
extern crate edition_kw_macro_2015;

View File

@ -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
}

View File

@ -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
}

View File

@ -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: aborting due to 3 previous errors
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 14 previous errors