pub static SEMICOLON_IN_EXPRESSIONS_FROM_NON_LOCAL_MACROS: &'static LintExpand description
The semicolon_in_expressions_from_non_local_macros lint detects trailing semicolons in
macro bodies when the macro is invoked in expression position. This was previously accepted,
but is being phased out. This is similar to the semicolon_in_expressions_from_macros lint,
but applies to macros expanded from a different crate.
§Example
fn main() {
let val = match true {
true => false,
_ => example_separate_crate::foo!()
};
}where the crate example-separate-crate contains:
#[macro_export]
macro_rules! foo {
() => { true; }
}produces:
warning: trailing semicolon in macro used in expression position
--> src/main.rs:4:14
|
4 | _ => example_separate_crate::foo!()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= 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: `#[warn(semicolon_in_expressions_from_non_local_macros)]` (part of `#[warn(future_incompatible)]`) on by default
= note: this warning originates in the macro `example_separate_crate::foo` (in Nightly builds, run with -Z macro-backtrace for more info)§Explanation
Previous, Rust ignored trailing semicolon in a macro body when a macro was invoked in expression position. However, this makes the treatment of semicolons in the language inconsistent, and could lead to unexpected runtime behavior in some circumstances (e.g. if the macro author expects a value to be dropped).
This is a future-incompatible lint to transition this to a hard error in the future. See issue #79813 for more details.