Skip to content

Commit fa976ba

Browse files
committed
Turn lint to allow by default and add future proofing warning
1 parent ca5e89d commit fa976ba

10 files changed

+60
-77
lines changed

src/librustc/lint/builtin.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ pub mod parser {
366366

367367
declare_lint! {
368368
pub INCORRECT_MACRO_FRAGMENT_REPETITION,
369-
Warn,
369+
Allow,
370370
"detects incorrect macro fragment follow due to repetition"
371371
}
372372
}
@@ -433,6 +433,7 @@ impl LintPass for HardwiredLints {
433433
MACRO_USE_EXTERN_CRATE,
434434
MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS,
435435
parser::QUESTION_MARK_MACRO_SEP,
436+
parser::INCORRECT_MACRO_FRAGMENT_REPETITION,
436437
)
437438
}
438439
}

src/librustc_lint/lib.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ use rustc::lint::builtin::{
4747
ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE,
4848
ELIDED_LIFETIMES_IN_PATHS,
4949
EXPLICIT_OUTLIVES_REQUIREMENTS,
50-
parser::QUESTION_MARK_MACRO_SEP
50+
parser::QUESTION_MARK_MACRO_SEP,
51+
parser::INCORRECT_MACRO_FRAGMENT_REPETITION,
5152
};
5253
use rustc::session;
5354
use rustc::util;
@@ -326,6 +327,11 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
326327
reference: "issue #48075 <https://github.com/rust-lang/rust/issues/48075>",
327328
edition: Some(Edition::Edition2018),
328329
},
330+
FutureIncompatibleInfo {
331+
id: LintId::of(INCORRECT_MACRO_FRAGMENT_REPETITION),
332+
reference: "issue #56575 <https://github.com/rust-lang/rust/issues/56575>",
333+
edition: None,
334+
},
329335
FutureIncompatibleInfo {
330336
id: LintId::of(MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS),
331337
reference: "issue #52234 <https://github.com/rust-lang/rust/issues/52234>",

src/test/ui/issues/issue-42755.rs

+1-13
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
1-
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2-
// file at the top-level directory of this distribution and at
3-
// http://rust-lang.org/COPYRIGHT.
4-
//
5-
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6-
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7-
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8-
// option. This file may not be copied, modified, or distributed
9-
// except according to those terms.
10-
11-
121
macro_rules! foo {
132
($($p:vis)*) => {}
14-
//~^ WARN `$p:vis` is followed (through repetition) by itself, which is not allowed for `vis`
15-
//~| ERROR repetition matches empty token tree
3+
//~^ ERROR repetition matches empty token tree
164
}
175

186
foo!(a);

src/test/ui/issues/issue-42755.stderr

+1-14
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,8 @@
11
error: repetition matches empty token tree
2-
--> $DIR/issue-42755.rs:13:7
2+
--> $DIR/issue-42755.rs:2:7
33
|
44
LL | ($($p:vis)*) => {}
55
| ^^^^^^^^
66

7-
warning: `$p:vis` is followed (through repetition) by itself, which is not allowed for `vis` fragments
8-
--> $DIR/issue-42755.rs:13:8
9-
|
10-
LL | ($($p:vis)*) => {}
11-
| ^^^^^^ this fragment is followed by itself without a valid separator
12-
|
13-
= note: #[warn(incorrect_macro_fragment_repetition)] on by default
14-
= note: allowed there are: `,`, an ident or a type
15-
help: add a valid separator for the repetition to be unambiguous, for example
16-
|
17-
LL | ($($p:vis),*) => {}
18-
| ^
19-
207
error: aborting due to previous error
218

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1+
#![deny(incorrect_macro_fragment_repetition)]
2+
13
macro_rules! foo {
24
($($a:expr)*) => {};
3-
//~^ WARN `$a:expr` is followed (through repetition) by itself, which is not allowed for
5+
//~^ ERROR `$a:expr` is followed (through repetition) by itself, which is not allowed for
6+
//~| WARN this was previously accepted by the compiler but is being phased out
47
}
8+
9+
fn main() {}

src/test/ui/macros/incorrrect-repetition-2.stderr

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
warning: `$a:expr` is followed (through repetition) by itself, which is not allowed for `expr` fragments
2-
--> $DIR/incorrrect-repetition-2.rs:2:8
1+
error: `$a:expr` is followed (through repetition) by itself, which is not allowed for `expr` fragments
2+
--> $DIR/incorrrect-repetition-2.rs:4:8
33
|
44
LL | ($($a:expr)*) => {};
55
| ^^^^^^^ this fragment is followed by itself without a valid separator
66
|
7-
= note: #[warn(incorrect_macro_fragment_repetition)] on by default
7+
note: lint level defined here
8+
--> $DIR/incorrrect-repetition-2.rs:1:9
9+
|
10+
LL | #![deny(incorrect_macro_fragment_repetition)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
13+
= note: for more information, see issue #56575 <https://github.com/rust-lang/rust/issues/56575>
814
= note: allowed there are: `;`, `=>` or `,`
915
help: add a valid separator for the repetition to be unambiguous, for example
1016
|
1117
LL | ($($a:expr);*) => {};
1218
| ^
1319

14-
error[E0601]: `main` function not found in crate `incorrrect_repetition_2`
15-
|
16-
= note: consider adding a `main` function to `$DIR/incorrrect-repetition-2.rs`
17-
1820
error: aborting due to previous error
1921

20-
For more information about this error, try `rustc --explain E0601`.
+4-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
#![deny(incorrect_macro_fragment_repetition)]
2+
13
macro_rules! sneaky {
24
($($i:ident $e:expr)*) => {}
3-
//~^ WARN `$e:expr` is followed (through repetition) by `$i:ident`, which is not allowed for
5+
//~^ ERROR `$e:expr` is followed (through repetition) by `$i:ident`, which is not allowed for
6+
//~| WARN this was previously accepted by the compiler but is being phased out
47
}
58

69
fn main() {
710
sneaky!(a b c d);
8-
let x: () = 1;
9-
//~^ ERROR
1011
}
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,23 @@
1-
warning: `$e:expr` is followed (through repetition) by `$i:ident`, which is not allowed for `expr` fragments
2-
--> $DIR/incorrrect-repetition.rs:2:17
1+
error: `$e:expr` is followed (through repetition) by `$i:ident`, which is not allowed for `expr` fragments
2+
--> $DIR/incorrrect-repetition.rs:4:17
33
|
44
LL | ($($i:ident $e:expr)*) => {}
55
| -------- ^^^^^^^ this fragment is followed by the first fragment in this repetition without a valid separator
66
| |
77
| this is the first fragment in the evaluated repetition
88
|
9-
= note: #[warn(incorrect_macro_fragment_repetition)] on by default
9+
note: lint level defined here
10+
--> $DIR/incorrrect-repetition.rs:1:9
11+
|
12+
LL | #![deny(incorrect_macro_fragment_repetition)]
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
15+
= note: for more information, see issue #56575 <https://github.com/rust-lang/rust/issues/56575>
1016
= note: allowed there are: `;`, `=>` or `,`
1117
help: add a valid separator for the repetition to be unambiguous, for example
1218
|
1319
LL | ($($i:ident $e:expr);*) => {}
1420
| ^
1521

16-
error[E0308]: mismatched types
17-
--> $DIR/incorrrect-repetition.rs:8:17
18-
|
19-
LL | let x: () = 1;
20-
| ^ expected (), found integral variable
21-
|
22-
= note: expected type `()`
23-
found type `{integer}`
24-
2522
error: aborting due to previous error
2623

27-
For more information about this error, try `rustc --explain E0308`.

src/test/ui/macros/macro-input-future-proofing.rs

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
1-
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2-
// file at the top-level directory of this distribution and at
3-
// http://rust-lang.org/COPYRIGHT.
4-
//
5-
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6-
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7-
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8-
// option. This file may not be copied, modified, or distributed
9-
// except according to those terms.
10-
111
#![allow(unused_macros)]
2+
#![warn(incorrect_macro_fragment_repetition)]
123

134
macro_rules! errors_everywhere {
145
($ty:ty <) => (); //~ ERROR `$ty:ty` is followed by `<`, which is not allowed for `ty`
@@ -31,6 +22,7 @@ macro_rules! errors_everywhere {
3122
( $($a:expr)* $($b:tt)* ) => { };
3223
//~^ WARN `$a:expr` is followed (through repetition) by itself, which is not allowed for
3324
//~| ERROR `$a:expr` is followed by `$b:tt`, which is not allowed for `expr` fragments
25+
//~| WARN this was previously accepted by the compiler but is being phased out
3426
( $($a:expr),* $($b:tt)* ) => { };
3527
//~^ ERROR `$a:expr` may be followed by `$b:tt`, which is not allowed for `expr` fragments
3628
}

src/test/ui/macros/macro-input-future-proofing.stderr

+19-13
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,104 @@
11
error: `$ty:ty` is followed by `<`, which is not allowed for `ty` fragments
2-
--> $DIR/macro-input-future-proofing.rs:14:13
2+
--> $DIR/macro-input-future-proofing.rs:5:13
33
|
44
LL | ($ty:ty <) => (); //~ ERROR `$ty:ty` is followed by `<`, which is not allowed for `ty`
55
| ^ not allowed after `ty` fragments
66
|
77
= note: allowed there are: `,`, `{`, `[`, `=>`, `>`, `=`, `:`, `;`, `|`, `as` or `where`
88

99
error: `$ty:ty` is followed by `<`, which is not allowed for `ty` fragments
10-
--> $DIR/macro-input-future-proofing.rs:15:13
10+
--> $DIR/macro-input-future-proofing.rs:6:13
1111
|
1212
LL | ($ty:ty < foo ,) => (); //~ ERROR `$ty:ty` is followed by `<`, which is not allowed for `ty`
1313
| ^ not allowed after `ty` fragments
1414
|
1515
= note: allowed there are: `,`, `{`, `[`, `=>`, `>`, `=`, `:`, `;`, `|`, `as` or `where`
1616

1717
error: `$pa:pat` is followed by `>`, which is not allowed for `pat` fragments
18-
--> $DIR/macro-input-future-proofing.rs:21:14
18+
--> $DIR/macro-input-future-proofing.rs:12:14
1919
|
2020
LL | ($pa:pat >) => (); //~ ERROR `$pa:pat` is followed by `>`, which is not allowed for `pat`
2121
| ^ not allowed after `pat` fragments
2222
|
2323
= note: allowed there are: `=>`, `,`, `=`, `|`, `if` or `in`
2424

2525
error: `$pa:pat` is followed by `$pb:pat`, which is not allowed for `pat` fragments
26-
--> $DIR/macro-input-future-proofing.rs:23:14
26+
--> $DIR/macro-input-future-proofing.rs:14:14
2727
|
2828
LL | ($pa:pat $pb:pat $ty:ty ,) => ();
2929
| ^^^^^^^ not allowed after `pat` fragments
3030
|
3131
= note: allowed there are: `=>`, `,`, `=`, `|`, `if` or `in`
3232

3333
error: `$pb:pat` is followed by `$ty:ty`, which is not allowed for `pat` fragments
34-
--> $DIR/macro-input-future-proofing.rs:23:22
34+
--> $DIR/macro-input-future-proofing.rs:14:22
3535
|
3636
LL | ($pa:pat $pb:pat $ty:ty ,) => ();
3737
| ^^^^^^ not allowed after `pat` fragments
3838
|
3939
= note: allowed there are: `=>`, `,`, `=`, `|`, `if` or `in`
4040

4141
error: `$ty:ty` is followed by `-`, which is not allowed for `ty` fragments
42-
--> $DIR/macro-input-future-proofing.rs:26:13
42+
--> $DIR/macro-input-future-proofing.rs:17:13
4343
|
4444
LL | ($ty:ty -) => (); //~ ERROR `$ty:ty` is followed by `-`
4545
| ^ not allowed after `ty` fragments
4646
|
4747
= note: allowed there are: `,`, `{`, `[`, `=>`, `>`, `=`, `:`, `;`, `|`, `as` or `where`
4848

4949
error: `$b:ty` is followed by `-`, which is not allowed for `ty` fragments
50-
--> $DIR/macro-input-future-proofing.rs:27:19
50+
--> $DIR/macro-input-future-proofing.rs:18:19
5151
|
5252
LL | ($a:ty, $b:ty -) => (); //~ ERROR `$b:ty` is followed by `-`
5353
| ^ not allowed after `ty` fragments
5454
|
5555
= note: allowed there are: `,`, `{`, `[`, `=>`, `>`, `=`, `:`, `;`, `|`, `as` or `where`
5656

5757
error: `$ty:ty` is followed by `-`, which is not allowed for `ty` fragments
58-
--> $DIR/macro-input-future-proofing.rs:28:7
58+
--> $DIR/macro-input-future-proofing.rs:19:7
5959
|
6060
LL | ($($ty:ty)-+) => (); //~ ERROR `$ty:ty` is followed by `-`, which is not allowed for `ty`
6161
| ^^^^^^^^ not allowed after `ty` fragments
6262
|
6363
= note: allowed there are: `,`, `{`, `[`, `=>`, `>`, `=`, `:`, `;`, `|`, `as` or `where`
6464

6565
error: `$a:expr` is followed by `$b:tt`, which is not allowed for `expr` fragments
66-
--> $DIR/macro-input-future-proofing.rs:29:17
66+
--> $DIR/macro-input-future-proofing.rs:20:17
6767
|
6868
LL | ( $a:expr $($b:tt)* ) => { };
6969
| ^^^^^ not allowed after `expr` fragments
7070
|
7171
= note: allowed there are: `;`, `=>` or `,`
7272

7373
error: `$a:expr` is followed by `$b:tt`, which is not allowed for `expr` fragments
74-
--> $DIR/macro-input-future-proofing.rs:31:21
74+
--> $DIR/macro-input-future-proofing.rs:22:21
7575
|
7676
LL | ( $($a:expr)* $($b:tt)* ) => { };
7777
| ^^^^^ not allowed after `expr` fragments
7878
|
7979
= note: allowed there are: `;`, `=>` or `,`
8080

8181
error: `$a:expr` may be followed by `$b:tt`, which is not allowed for `expr` fragments
82-
--> $DIR/macro-input-future-proofing.rs:34:22
82+
--> $DIR/macro-input-future-proofing.rs:26:22
8383
|
8484
LL | ( $($a:expr),* $($b:tt)* ) => { };
8585
| ^^^^^ not allowed after `expr` fragments
8686
|
8787
= note: allowed there are: `;`, `=>` or `,`
8888

8989
warning: `$a:expr` is followed (through repetition) by itself, which is not allowed for `expr` fragments
90-
--> $DIR/macro-input-future-proofing.rs:31:9
90+
--> $DIR/macro-input-future-proofing.rs:22:9
9191
|
9292
LL | ( $($a:expr)* $($b:tt)* ) => { };
9393
| ^^^^^^^ this fragment is followed by itself without a valid separator
9494
|
95-
= note: #[warn(incorrect_macro_fragment_repetition)] on by default
95+
note: lint level defined here
96+
--> $DIR/macro-input-future-proofing.rs:2:9
97+
|
98+
LL | #![warn(incorrect_macro_fragment_repetition)]
99+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
100+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
101+
= note: for more information, see issue #56575 <https://github.com/rust-lang/rust/issues/56575>
96102
= note: allowed there are: `;`, `=>` or `,`
97103
help: add a valid separator for the repetition to be unambiguous, for example
98104
|

0 commit comments

Comments
 (0)