Skip to content

Commit 9520804

Browse files
committed
Make async_idents an edition incompat lint
1 parent 15a8a66 commit 9520804

9 files changed

+238
-18
lines changed

src/librustc_lint/builtin.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,7 +1788,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnnameableTestFunctions {
17881788

17891789
declare_lint! {
17901790
pub ASYNC_IDENTS,
1791-
Allow,
1791+
Deny,
17921792
"detects `async` being used as an identifier"
17931793
}
17941794

@@ -1798,7 +1798,7 @@ pub struct Async2018;
17981798

17991799
impl LintPass for Async2018 {
18001800
fn get_lints(&self) -> LintArray {
1801-
lint_array!()
1801+
lint_array!(ASYNC_IDENTS)
18021802
}
18031803
}
18041804

src/librustc_lint/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
189189
add_lint_group!(sess,
190190
"rust_2018_idioms",
191191
BARE_TRAIT_OBJECTS,
192-
ASYNC_IDENTS,
193192
UNREACHABLE_PUB,
194193
UNUSED_EXTERN_CRATES,
195194
ELLIPSIS_INCLUSIVE_RANGE_PATTERNS);
@@ -224,6 +223,11 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
224223
reference: "issue #35896 <https://github.com/rust-lang/rust/issues/35896>",
225224
edition: Some(Edition::Edition2018),
226225
},
226+
FutureIncompatibleInfo {
227+
id: LintId::of(ASYNC_IDENTS),
228+
reference: "issue #49716 <https://github.com/rust-lang/rust/issues/49716>",
229+
edition: Some(Edition::Edition2018),
230+
},
227231
FutureIncompatibleInfo {
228232
id: LintId::of(SAFE_EXTERN_STATICS),
229233
reference: "issue #36247 <https://github.com/rust-lang/rust/issues/36247>",

src/test/ui/auxiliary/edition-kw-macro-2015.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// edition:2015
1212

1313
#![feature(raw_identifiers)]
14+
#![allow(async_idents)]
1415

1516
#[macro_export]
1617
macro_rules! produces_async {

src/test/ui/auxiliary/edition-kw-macro-2018.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// edition:2018
1212

1313
#![feature(raw_identifiers)]
14+
#![allow(async_idents)]
1415

1516
#[macro_export]
1617
macro_rules! produces_async {

src/test/ui/edition-keywords-2015-2015-expansion.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// compile-pass
1414

1515
#![feature(raw_identifiers)]
16+
#![allow(async_idents)]
1617

1718
#[macro_use]
1819
extern crate edition_kw_macro_2015;

src/test/ui/edition-keywords-2018-2015-expansion.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// compile-pass
1414

1515
#![feature(raw_identifiers)]
16+
#![allow(async_idents)]
1617

1718
#[macro_use]
1819
extern crate edition_kw_macro_2015;

src/test/ui/rust-2018/async-ident.fixed

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,21 @@
99
// except according to those terms.
1010

1111
#![feature(raw_identifiers)]
12-
#![deny(rust_2018_idioms)]
13-
#![allow(dead_code)]
12+
#![allow(dead_code, unused_variables, non_camel_case_types, non_upper_case_globals)]
1413

14+
// edition:2015
1515
// run-rustfix
1616

1717
fn r#async() {} //~ ERROR async
18+
//~^ WARN hard error in the 2018 edition
1819

1920
macro_rules! foo {
2021
($foo:ident) => {};
2122
($r#async:expr, r#async) => {};
2223
//~^ ERROR async
2324
//~| ERROR async
25+
//~| WARN hard error in the 2018 edition
26+
//~| WARN hard error in the 2018 edition
2427
}
2528

2629
foo!(async);
@@ -29,4 +32,56 @@ mod dont_lint_raw {
2932
fn r#async() {}
3033
}
3134

32-
fn main() {}
35+
mod async_trait {
36+
trait r#async {}
37+
//~^ ERROR async
38+
//~| WARN hard error in the 2018 edition
39+
struct MyStruct;
40+
impl r#async for MyStruct {}
41+
//~^ ERROR async
42+
//~| WARN hard error in the 2018 edition
43+
}
44+
45+
mod async_static {
46+
static r#async: u32 = 0;
47+
//~^ ERROR async
48+
//~| WARN hard error in the 2018 edition
49+
}
50+
51+
mod async_const {
52+
const r#async: u32 = 0;
53+
//~^ ERROR async
54+
//~| WARN hard error in the 2018 edition
55+
}
56+
57+
struct Foo;
58+
impl Foo { fn r#async() {} }
59+
//~^ ERROR async
60+
//~| WARN hard error in the 2018 edition
61+
62+
fn main() {
63+
struct r#async {}
64+
//~^ ERROR async
65+
//~| WARN hard error in the 2018 edition
66+
let r#async: r#async = r#async {};
67+
//~^ ERROR async
68+
//~| WARN hard error in the 2018 edition
69+
//~| ERROR async
70+
//~| WARN hard error in the 2018 edition
71+
//~| ERROR async
72+
//~| WARN hard error in the 2018 edition
73+
}
74+
75+
#[macro_export]
76+
macro_rules! produces_async {
77+
() => (pub fn r#async() {})
78+
//~^ ERROR async
79+
//~| WARN hard error in the 2018 edition
80+
}
81+
82+
#[macro_export]
83+
macro_rules! consumes_async {
84+
(r#async) => (1)
85+
//~^ ERROR async
86+
//~| WARN hard error in the 2018 edition
87+
}

src/test/ui/rust-2018/async-ident.rs

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,21 @@
99
// except according to those terms.
1010

1111
#![feature(raw_identifiers)]
12-
#![deny(rust_2018_idioms)]
13-
#![allow(dead_code)]
12+
#![allow(dead_code, unused_variables, non_camel_case_types, non_upper_case_globals)]
1413

14+
// edition:2015
1515
// run-rustfix
1616

1717
fn async() {} //~ ERROR async
18+
//~^ WARN hard error in the 2018 edition
1819

1920
macro_rules! foo {
2021
($foo:ident) => {};
2122
($async:expr, async) => {};
2223
//~^ ERROR async
2324
//~| ERROR async
25+
//~| WARN hard error in the 2018 edition
26+
//~| WARN hard error in the 2018 edition
2427
}
2528

2629
foo!(async);
@@ -29,4 +32,56 @@ mod dont_lint_raw {
2932
fn r#async() {}
3033
}
3134

32-
fn main() {}
35+
mod async_trait {
36+
trait async {}
37+
//~^ ERROR async
38+
//~| WARN hard error in the 2018 edition
39+
struct MyStruct;
40+
impl async for MyStruct {}
41+
//~^ ERROR async
42+
//~| WARN hard error in the 2018 edition
43+
}
44+
45+
mod async_static {
46+
static async: u32 = 0;
47+
//~^ ERROR async
48+
//~| WARN hard error in the 2018 edition
49+
}
50+
51+
mod async_const {
52+
const async: u32 = 0;
53+
//~^ ERROR async
54+
//~| WARN hard error in the 2018 edition
55+
}
56+
57+
struct Foo;
58+
impl Foo { fn async() {} }
59+
//~^ ERROR async
60+
//~| WARN hard error in the 2018 edition
61+
62+
fn main() {
63+
struct async {}
64+
//~^ ERROR async
65+
//~| WARN hard error in the 2018 edition
66+
let async: async = async {};
67+
//~^ ERROR async
68+
//~| WARN hard error in the 2018 edition
69+
//~| ERROR async
70+
//~| WARN hard error in the 2018 edition
71+
//~| ERROR async
72+
//~| WARN hard error in the 2018 edition
73+
}
74+
75+
#[macro_export]
76+
macro_rules! produces_async {
77+
() => (pub fn async() {})
78+
//~^ ERROR async
79+
//~| WARN hard error in the 2018 edition
80+
}
81+
82+
#[macro_export]
83+
macro_rules! consumes_async {
84+
(async) => (1)
85+
//~^ ERROR async
86+
//~| WARN hard error in the 2018 edition
87+
}

src/test/ui/rust-2018/async-ident.stderr

Lines changed: 111 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,126 @@ error: `async` is a keyword in the 2018 edition
44
LL | fn async() {} //~ ERROR async
55
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#async`
66
|
7-
note: lint level defined here
8-
--> $DIR/async-ident.rs:12:9
9-
|
10-
LL | #![deny(rust_2018_idioms)]
11-
| ^^^^^^^^^^^^^^^^
12-
= note: #[deny(async_idents)] implied by #[deny(rust_2018_idioms)]
7+
= note: #[deny(async_idents)] on by default
8+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
9+
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
1310

1411
error: `async` is a keyword in the 2018 edition
15-
--> $DIR/async-ident.rs:21:7
12+
--> $DIR/async-ident.rs:22:7
1613
|
1714
LL | ($async:expr, async) => {};
1815
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#async`
16+
|
17+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
18+
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
1919

2020
error: `async` is a keyword in the 2018 edition
21-
--> $DIR/async-ident.rs:21:19
21+
--> $DIR/async-ident.rs:22:19
2222
|
2323
LL | ($async:expr, async) => {};
2424
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#async`
25+
|
26+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
27+
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
28+
29+
error: `async` is a keyword in the 2018 edition
30+
--> $DIR/async-ident.rs:36:11
31+
|
32+
LL | trait async {}
33+
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#async`
34+
|
35+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
36+
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
37+
38+
error: `async` is a keyword in the 2018 edition
39+
--> $DIR/async-ident.rs:40:10
40+
|
41+
LL | impl async for MyStruct {}
42+
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#async`
43+
|
44+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
45+
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
46+
47+
error: `async` is a keyword in the 2018 edition
48+
--> $DIR/async-ident.rs:46:12
49+
|
50+
LL | static async: u32 = 0;
51+
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#async`
52+
|
53+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
54+
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
55+
56+
error: `async` is a keyword in the 2018 edition
57+
--> $DIR/async-ident.rs:52:11
58+
|
59+
LL | const async: u32 = 0;
60+
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#async`
61+
|
62+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
63+
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
64+
65+
error: `async` is a keyword in the 2018 edition
66+
--> $DIR/async-ident.rs:58:15
67+
|
68+
LL | impl Foo { fn async() {} }
69+
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#async`
70+
|
71+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
72+
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
73+
74+
error: `async` is a keyword in the 2018 edition
75+
--> $DIR/async-ident.rs:63:12
76+
|
77+
LL | struct async {}
78+
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#async`
79+
|
80+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
81+
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
82+
83+
error: `async` is a keyword in the 2018 edition
84+
--> $DIR/async-ident.rs:66:9
85+
|
86+
LL | let async: async = async {};
87+
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#async`
88+
|
89+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
90+
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
91+
92+
error: `async` is a keyword in the 2018 edition
93+
--> $DIR/async-ident.rs:66:16
94+
|
95+
LL | let async: async = async {};
96+
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#async`
97+
|
98+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
99+
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
100+
101+
error: `async` is a keyword in the 2018 edition
102+
--> $DIR/async-ident.rs:66:24
103+
|
104+
LL | let async: async = async {};
105+
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#async`
106+
|
107+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
108+
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
109+
110+
error: `async` is a keyword in the 2018 edition
111+
--> $DIR/async-ident.rs:77:19
112+
|
113+
LL | () => (pub fn async() {})
114+
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#async`
115+
|
116+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
117+
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
118+
119+
error: `async` is a keyword in the 2018 edition
120+
--> $DIR/async-ident.rs:84:6
121+
|
122+
LL | (async) => (1)
123+
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#async`
124+
|
125+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
126+
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
25127

26-
error: aborting due to 3 previous errors
128+
error: aborting due to 14 previous errors
27129

0 commit comments

Comments
 (0)