forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#87385 - Aaron1011:final-enable-semi, r=petr…
…ochenkov Make `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` warn by default This PR makes the `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` lint warn by default. To avoid showing a large number of un-actionable warnings to users, we only enable the lint for macros defined in the same crate. This ensures that users will be able to fix the warning by simply removing a semicolon. In the future, I'd like to enable this lint unconditionally, and eventually make it into a hard error in a future edition. This PR is a step towards that goal.
- Loading branch information
Showing
21 changed files
with
135 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ pub mod foo { | |
mod bar { | ||
fn f() -> u32 { 1 } | ||
pub macro m() { | ||
f(); | ||
f() | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,5 @@ macro_rules! foo { | |
} | ||
|
||
pub fn main() { | ||
'x: loop { foo!() } | ||
'x: loop { foo!(); } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,6 @@ macro_rules! foo { | |
|
||
pub fn main() { | ||
'x: for _ in 0..1 { | ||
foo!() | ||
foo!(); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
...i/lint/semicolon-in-expressions-from-macros/allow-semicolon-in-expressions-from-macros.rs
This file was deleted.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
src/test/ui/lint/semicolon-in-expressions-from-macros/auxiliary/foreign-crate.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#[macro_export] | ||
macro_rules! my_macro { | ||
() => { true; } | ||
} |
9 changes: 9 additions & 0 deletions
9
src/test/ui/lint/semicolon-in-expressions-from-macros/foreign-crate.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// aux-build:foreign-crate.rs | ||
// check-pass | ||
|
||
extern crate foreign_crate; | ||
|
||
// Test that we do not lint for a macro in a foreign crate | ||
fn main() { | ||
let _ = foreign_crate::my_macro!(); | ||
} |
16 changes: 16 additions & 0 deletions
16
...ui/lint/semicolon-in-expressions-from-macros/warn-semicolon-in-expressions-from-macros.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// check-pass | ||
// Ensure that trailing semicolons cause warnings by default | ||
|
||
macro_rules! foo { | ||
() => { | ||
true; //~ WARN trailing semicolon in macro | ||
//~| WARN this was previously | ||
} | ||
} | ||
|
||
fn main() { | ||
let _val = match true { | ||
true => false, | ||
_ => foo!() | ||
}; | ||
} |
16 changes: 16 additions & 0 deletions
16
...int/semicolon-in-expressions-from-macros/warn-semicolon-in-expressions-from-macros.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
warning: trailing semicolon in macro used in expression position | ||
--> $DIR/warn-semicolon-in-expressions-from-macros.rs:6:13 | ||
| | ||
LL | true; | ||
| ^ | ||
... | ||
LL | _ => foo!() | ||
| ------ in this macro invocation | ||
| | ||
= note: `#[warn(semicolon_in_expressions_from_macros)]` on by default | ||
= 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 #79813 <https://github.com/rust-lang/rust/issues/79813> | ||
= note: this warning originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
warning: 1 warning emitted | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
fn f1(_: &str) {} | ||
macro_rules! m1 { | ||
($e:expr) => { | ||
f1($e); | ||
f1($e) | ||
}; | ||
} | ||
macro_rules! m3 { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
fn f1(_: &str) {} | ||
macro_rules! m2 { | ||
($e:expr) => { | ||
f1(*$e); | ||
f1(*$e) | ||
}; | ||
} | ||
macro_rules! m3 { | ||
|