Skip to content

Commit 886dea2

Browse files
committed
Make SEMICOLON_IN_EXPRESSIONS_FROM_MACROS warn by default
1 parent 3bc9dd0 commit 886dea2

16 files changed

+91
-28
lines changed

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2799,7 +2799,7 @@ declare_lint! {
27992799
/// [issue #79813]: https://github.com/rust-lang/rust/issues/79813
28002800
/// [future-incompatible]: ../index.md#future-incompatible-lints
28012801
pub SEMICOLON_IN_EXPRESSIONS_FROM_MACROS,
2802-
Allow,
2802+
Warn,
28032803
"trailing semicolon in macro body used as expression",
28042804
@future_incompatible = FutureIncompatibleInfo {
28052805
reference: "issue #79813 <https://github.com/rust-lang/rust/issues/79813>",

library/std/src/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ macro_rules! dbg {
290290
// `$val` expression could be a block (`{ .. }`), in which case the `eprintln!`
291291
// will be malformed.
292292
() => {
293-
$crate::eprintln!("[{}:{}]", $crate::file!(), $crate::line!());
293+
$crate::eprintln!("[{}:{}]", $crate::file!(), $crate::line!())
294294
};
295295
($val:expr $(,)?) => {
296296
// Use of `match` here is intentional because it affects the lifetimes

src/test/ui/hygiene/auxiliary/intercrate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub mod foo {
55
mod bar {
66
fn f() -> u32 { 1 }
77
pub macro m() {
8-
f();
8+
f()
99
}
1010
}
1111
}

src/test/ui/hygiene/hygienic-label-1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ macro_rules! foo {
33
}
44

55
pub fn main() {
6-
'x: loop { foo!() }
6+
'x: loop { foo!(); }
77
}

src/test/ui/hygiene/hygienic-label-1.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ error[E0426]: use of undeclared label `'x`
44
LL | () => { break 'x; }
55
| ^^ undeclared label `'x`
66
...
7-
LL | 'x: loop { foo!() }
8-
| ------ in this macro invocation
7+
LL | 'x: loop { foo!(); }
8+
| ------- in this macro invocation
99
|
1010
= note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
1111

src/test/ui/hygiene/hygienic-label-3.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ macro_rules! foo {
44

55
pub fn main() {
66
'x: for _ in 0..1 {
7-
foo!()
7+
foo!();
88
};
99
}

src/test/ui/hygiene/hygienic-label-3.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ error[E0426]: use of undeclared label `'x`
44
LL | () => { break 'x; }
55
| ^^ undeclared label `'x`
66
...
7-
LL | foo!()
8-
| ------ in this macro invocation
7+
LL | foo!();
8+
| ------- in this macro invocation
99
|
1010
= note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
1111

src/test/ui/lint/semicolon-in-expressions-from-macros/allow-semicolon-in-expressions-from-macros.rs

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// check-pass
2+
// Ensure that trailing semicolons cause warnings by default
3+
4+
macro_rules! foo {
5+
() => {
6+
true; //~ WARN trailing semicolon in macro
7+
//~| WARN this was previously
8+
}
9+
}
10+
11+
fn main() {
12+
let _val = match true {
13+
true => false,
14+
_ => foo!()
15+
};
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
warning: trailing semicolon in macro used in expression position
2+
--> $DIR/warn-semicolon-in-expressions-from-macros.rs:6:13
3+
|
4+
LL | true;
5+
| ^
6+
...
7+
LL | _ => foo!()
8+
| ------ in this macro invocation
9+
|
10+
= note: `#[warn(semicolon_in_expressions_from_macros)]` on by default
11+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
12+
= note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813>
13+
= note: this warning originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
14+
15+
warning: 1 warning emitted
16+

0 commit comments

Comments
 (0)