Skip to content

Commit

Permalink
Turn lint to allow by default and add future proofing warning
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Dec 7, 2018
1 parent ca5e89d commit fa976ba
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 77 deletions.
3 changes: 2 additions & 1 deletion src/librustc/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ pub mod parser {

declare_lint! {
pub INCORRECT_MACRO_FRAGMENT_REPETITION,
Warn,
Allow,
"detects incorrect macro fragment follow due to repetition"
}
}
Expand Down Expand Up @@ -433,6 +433,7 @@ impl LintPass for HardwiredLints {
MACRO_USE_EXTERN_CRATE,
MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS,
parser::QUESTION_MARK_MACRO_SEP,
parser::INCORRECT_MACRO_FRAGMENT_REPETITION,
)
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/librustc_lint/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ use rustc::lint::builtin::{
ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE,
ELIDED_LIFETIMES_IN_PATHS,
EXPLICIT_OUTLIVES_REQUIREMENTS,
parser::QUESTION_MARK_MACRO_SEP
parser::QUESTION_MARK_MACRO_SEP,
parser::INCORRECT_MACRO_FRAGMENT_REPETITION,
};
use rustc::session;
use rustc::util;
Expand Down Expand Up @@ -326,6 +327,11 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
reference: "issue #48075 <https://github.com/rust-lang/rust/issues/48075>",
edition: Some(Edition::Edition2018),
},
FutureIncompatibleInfo {
id: LintId::of(INCORRECT_MACRO_FRAGMENT_REPETITION),
reference: "issue #56575 <https://github.com/rust-lang/rust/issues/56575>",
edition: None,
},
FutureIncompatibleInfo {
id: LintId::of(MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS),
reference: "issue #52234 <https://github.com/rust-lang/rust/issues/52234>",
Expand Down
14 changes: 1 addition & 13 deletions src/test/ui/issues/issue-42755.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
// Copyright 2017 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.


macro_rules! foo {
($($p:vis)*) => {}
//~^ WARN `$p:vis` is followed (through repetition) by itself, which is not allowed for `vis`
//~| ERROR repetition matches empty token tree
//~^ ERROR repetition matches empty token tree
}

foo!(a);
Expand Down
15 changes: 1 addition & 14 deletions src/test/ui/issues/issue-42755.stderr
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
error: repetition matches empty token tree
--> $DIR/issue-42755.rs:13:7
--> $DIR/issue-42755.rs:2:7
|
LL | ($($p:vis)*) => {}
| ^^^^^^^^

warning: `$p:vis` is followed (through repetition) by itself, which is not allowed for `vis` fragments
--> $DIR/issue-42755.rs:13:8
|
LL | ($($p:vis)*) => {}
| ^^^^^^ this fragment is followed by itself without a valid separator
|
= note: #[warn(incorrect_macro_fragment_repetition)] on by default
= note: allowed there are: `,`, an ident or a type
help: add a valid separator for the repetition to be unambiguous, for example
|
LL | ($($p:vis),*) => {}
| ^

error: aborting due to previous error

7 changes: 6 additions & 1 deletion src/test/ui/macros/incorrrect-repetition-2.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#![deny(incorrect_macro_fragment_repetition)]

macro_rules! foo {
($($a:expr)*) => {};
//~^ WARN `$a:expr` is followed (through repetition) by itself, which is not allowed for
//~^ ERROR `$a:expr` is followed (through repetition) by itself, which is not allowed for
//~| WARN this was previously accepted by the compiler but is being phased out
}

fn main() {}
17 changes: 9 additions & 8 deletions src/test/ui/macros/incorrrect-repetition-2.stderr
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
warning: `$a:expr` is followed (through repetition) by itself, which is not allowed for `expr` fragments
--> $DIR/incorrrect-repetition-2.rs:2:8
error: `$a:expr` is followed (through repetition) by itself, which is not allowed for `expr` fragments
--> $DIR/incorrrect-repetition-2.rs:4:8
|
LL | ($($a:expr)*) => {};
| ^^^^^^^ this fragment is followed by itself without a valid separator
|
= note: #[warn(incorrect_macro_fragment_repetition)] on by default
note: lint level defined here
--> $DIR/incorrrect-repetition-2.rs:1:9
|
LL | #![deny(incorrect_macro_fragment_repetition)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #56575 <https://github.com/rust-lang/rust/issues/56575>
= note: allowed there are: `;`, `=>` or `,`
help: add a valid separator for the repetition to be unambiguous, for example
|
LL | ($($a:expr);*) => {};
| ^

error[E0601]: `main` function not found in crate `incorrrect_repetition_2`
|
= note: consider adding a `main` function to `$DIR/incorrrect-repetition-2.rs`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0601`.
7 changes: 4 additions & 3 deletions src/test/ui/macros/incorrrect-repetition.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#![deny(incorrect_macro_fragment_repetition)]

macro_rules! sneaky {
($($i:ident $e:expr)*) => {}
//~^ WARN `$e:expr` is followed (through repetition) by `$i:ident`, which is not allowed for
//~^ ERROR `$e:expr` is followed (through repetition) by `$i:ident`, which is not allowed for
//~| WARN this was previously accepted by the compiler but is being phased out
}

fn main() {
sneaky!(a b c d);
let x: () = 1;
//~^ ERROR
}
22 changes: 9 additions & 13 deletions src/test/ui/macros/incorrrect-repetition.stderr
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
warning: `$e:expr` is followed (through repetition) by `$i:ident`, which is not allowed for `expr` fragments
--> $DIR/incorrrect-repetition.rs:2:17
error: `$e:expr` is followed (through repetition) by `$i:ident`, which is not allowed for `expr` fragments
--> $DIR/incorrrect-repetition.rs:4:17
|
LL | ($($i:ident $e:expr)*) => {}
| -------- ^^^^^^^ this fragment is followed by the first fragment in this repetition without a valid separator
| |
| this is the first fragment in the evaluated repetition
|
= note: #[warn(incorrect_macro_fragment_repetition)] on by default
note: lint level defined here
--> $DIR/incorrrect-repetition.rs:1:9
|
LL | #![deny(incorrect_macro_fragment_repetition)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #56575 <https://github.com/rust-lang/rust/issues/56575>
= note: allowed there are: `;`, `=>` or `,`
help: add a valid separator for the repetition to be unambiguous, for example
|
LL | ($($i:ident $e:expr);*) => {}
| ^

error[E0308]: mismatched types
--> $DIR/incorrrect-repetition.rs:8:17
|
LL | let x: () = 1;
| ^ expected (), found integral variable
|
= note: expected type `()`
found type `{integer}`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
12 changes: 2 additions & 10 deletions src/test/ui/macros/macro-input-future-proofing.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
// Copyright 2015 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![allow(unused_macros)]
#![warn(incorrect_macro_fragment_repetition)]

macro_rules! errors_everywhere {
($ty:ty <) => (); //~ ERROR `$ty:ty` is followed by `<`, which is not allowed for `ty`
Expand All @@ -31,6 +22,7 @@ macro_rules! errors_everywhere {
( $($a:expr)* $($b:tt)* ) => { };
//~^ WARN `$a:expr` is followed (through repetition) by itself, which is not allowed for
//~| ERROR `$a:expr` is followed by `$b:tt`, which is not allowed for `expr` fragments
//~| WARN this was previously accepted by the compiler but is being phased out
( $($a:expr),* $($b:tt)* ) => { };
//~^ ERROR `$a:expr` may be followed by `$b:tt`, which is not allowed for `expr` fragments
}
Expand Down
32 changes: 19 additions & 13 deletions src/test/ui/macros/macro-input-future-proofing.stderr
Original file line number Diff line number Diff line change
@@ -1,98 +1,104 @@
error: `$ty:ty` is followed by `<`, which is not allowed for `ty` fragments
--> $DIR/macro-input-future-proofing.rs:14:13
--> $DIR/macro-input-future-proofing.rs:5:13
|
LL | ($ty:ty <) => (); //~ ERROR `$ty:ty` is followed by `<`, which is not allowed for `ty`
| ^ not allowed after `ty` fragments
|
= note: allowed there are: `,`, `{`, `[`, `=>`, `>`, `=`, `:`, `;`, `|`, `as` or `where`

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

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

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

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

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

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

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

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

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

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

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

0 comments on commit fa976ba

Please sign in to comment.