rust/tests/ui/macros/macro-missing-fragment.rs
Trevor Gross 8c402f125c Make missing_fragment_specifier an error in edition 2024
`missing_fragment_specifier` has been a future compatibility warning
since 2017. Uplifting it to an unconditional hard error was attempted in
2020, but eventually reverted due to fallout.

Make it an error only in edition >= 2024, leaving the lint for older
editions. This change will make it easier to support more macro syntax
that relies on usage of `$`.

Fixes <https://github.com/rust-lang/rust/issues/40107>
2024-07-27 05:33:24 -04:00

36 lines
888 B
Rust

//@ revisions: e2015 e2024
//@[e2015] edition:2015
//@[e2024] edition:2024
//@[e2024] compile-flags: -Zunstable-options
#![warn(missing_fragment_specifier)]
macro_rules! used_arm {
( $( any_token $field_rust_type )* ) => {};
//[e2015]~^ ERROR missing fragment
//[e2015]~| WARN missing fragment
//[e2015]~| WARN this was previously accepted
//[e2024]~^^^^ ERROR missing fragment
//[e2024]~| ERROR missing fragment
}
macro_rules! used_macro_unused_arm {
() => {};
( $name ) => {};
//[e2015]~^ WARN missing fragment
//[e2015]~| WARN this was previously accepted
//[e2024]~^^^ ERROR missing fragment
}
macro_rules! unused_macro {
( $name ) => {};
//[e2015]~^ WARN missing fragment
//[e2015]~| WARN this was previously accepted
//[e2024]~^^^ ERROR missing fragment
}
fn main() {
used_arm!();
used_macro_unused_arm!();
}