Files
rust/tests/ui/parser/macro/bad-macro-definition.rs
Josh Triplett 0403990000 mbe: Gracefully handle macro rules that end after =>
Add a test for various cases of invalid macro definitions.

Closes: https://github.com/rust-lang/rust/issues/143351
2025-07-03 20:56:05 -07:00

23 lines
566 B
Rust

#![crate_type = "lib"]
macro_rules! a { {} => }
//~^ ERROR: macro definition ended unexpectedly
macro_rules! b { 0 => }
//~^ ERROR: macro definition ended unexpectedly
//~| ERROR: invalid macro matcher
macro_rules! c { x => }
//~^ ERROR: macro definition ended unexpectedly
//~| ERROR: invalid macro matcher
macro_rules! d { _ => }
//~^ ERROR: macro definition ended unexpectedly
//~| ERROR: invalid macro matcher
macro_rules! e { {} }
//~^ ERROR: expected `=>`, found end of macro arguments
macro_rules! f {}
//~^ ERROR: macros must contain at least one rule