]> git.lizzy.rs Git - rust.git/blob - crates/hir_def/src/macro_expansion_tests/mbe/matching.rs
internal: docs
[rust.git] / crates / hir_def / src / macro_expansion_tests / mbe / matching.rs
1 //! Test that `$var:expr` captures function correctly.
2
3 use expect_test::expect;
4
5 use crate::macro_expansion_tests::check;
6
7 #[test]
8 fn unary_minus_is_a_literal() {
9     check(
10         r#"
11 macro_rules! m { ($x:literal) => (literal!()); ($x:tt) => (not_a_literal!()); }
12 m!(92);
13 m!(-92);
14 m!(-9.2);
15 m!(--92);
16 "#,
17         expect![[r#"
18 macro_rules! m { ($x:literal) => (literal!()); ($x:tt) => (not_a_literal!()); }
19 literal!()
20 literal!()
21 literal!()
22 /* error: leftover tokens */not_a_literal!()
23 "#]],
24     )
25 }