Skip to content

Commit 3bea64b

Browse files
authored
Remove trailing semicolon from macro expression
Trailing semicolon in macro expression is being phased out. The Rust compiler gives the following warning when compiling this code. ``` warning: trailing semicolon in macro used in expression position --> macro.rs:6:27 | 6 | println!("Hello!"); | ^ ... 12 | say_hello!() | ------------ 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 <rust-lang/rust#79813> = note: macro invocations at the end of a block are treated as expressions = note: to ignore the value produced by the macro, add a semicolon after the invocation of `say_hello` = note: this warning originates in the macro `say_hello` (in Nightly builds, run with -Z macro-backtrace for more info) warning: 1 warning emitted ```
1 parent efe23c4 commit 3bea64b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/macros.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ macro_rules! say_hello {
1616
// `()` indicates that the macro takes no argument.
1717
() => {
1818
// The macro will expand into the contents of this block.
19-
println!("Hello!");
19+
println!("Hello!")
2020
};
2121
}
2222
2323
fn main() {
24-
// This call will expand into `println!("Hello");`
24+
// This call will expand into `println!("Hello")`
2525
say_hello!()
2626
}
2727
```

0 commit comments

Comments
 (0)