Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-def/src/macro_expansion_tests/mbe/matching.rs')
-rw-r--r--crates/hir-def/src/macro_expansion_tests/mbe/matching.rs49
1 files changed, 49 insertions, 0 deletions
diff --git a/crates/hir-def/src/macro_expansion_tests/mbe/matching.rs b/crates/hir-def/src/macro_expansion_tests/mbe/matching.rs
index fc90c6e9f3..26f16542cb 100644
--- a/crates/hir-def/src/macro_expansion_tests/mbe/matching.rs
+++ b/crates/hir-def/src/macro_expansion_tests/mbe/matching.rs
@@ -136,3 +136,52 @@ macro_rules! m { ($($i:ident)? $vis:vis) => () }
"#]],
)
}
+
+// For this test and the one below, see rust-lang/rust#86730.
+#[test]
+fn expr_dont_match_let_expr() {
+ check(
+ r#"
+macro_rules! foo {
+ ($e:expr) => { $e }
+}
+
+fn test() {
+ foo!(let a = 3);
+}
+"#,
+ expect![[r#"
+macro_rules! foo {
+ ($e:expr) => { $e }
+}
+
+fn test() {
+ /* error: no rule matches input tokens */missing;
+}
+"#]],
+ );
+}
+
+#[test]
+fn expr_dont_match_inline_const() {
+ check(
+ r#"
+macro_rules! foo {
+ ($e:expr) => { $e }
+}
+
+fn test() {
+ foo!(const { 3 });
+}
+"#,
+ expect![[r#"
+macro_rules! foo {
+ ($e:expr) => { $e }
+}
+
+fn test() {
+ /* error: no rule matches input tokens */missing;
+}
+"#]],
+ );
+}