Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-def/src/macro_expansion_tests/mbe.rs')
-rw-r--r--crates/hir-def/src/macro_expansion_tests/mbe.rs80
1 files changed, 64 insertions, 16 deletions
diff --git a/crates/hir-def/src/macro_expansion_tests/mbe.rs b/crates/hir-def/src/macro_expansion_tests/mbe.rs
index 8c5bd3b6d3..abb5bd5ed7 100644
--- a/crates/hir-def/src/macro_expansion_tests/mbe.rs
+++ b/crates/hir-def/src/macro_expansion_tests/mbe.rs
@@ -35,9 +35,9 @@ macro_rules! f {
};
}
-struct#0:[email protected]#4# MyTraitMap2#0:[email protected]#2# {#0:[email protected]#4#
+struct#0:[email protected]#14336# MyTraitMap2#0:[email protected]#ROOT2024# {#0:[email protected]#14336#
+ map#0:[email protected]#14336#:#0:[email protected]#14336# #0:[email protected]#14336#::#0:[email protected]#14336#std#0:[email protected]#14336#::#0:[email protected]#14336#collections#0:[email protected]#14336#::#0:[email protected]#14336#HashSet#0:[email protected]#14336#<#0:[email protected]#14336#(#0:[email protected]#14336#)#0:[email protected]#14336#>#0:[email protected]#14336#,#0:[email protected]#14336#
+}#0:[email protected]#14336#
"#]],
);
}
@@ -75,12 +75,12 @@ macro_rules! f {
};
}
+fn#0:[email protected]#ROOT2024# main#0:[email protected]#ROOT2024#(#0:[email protected]#ROOT2024#)#0:[email protected]#ROOT2024# {#0:[email protected]#ROOT2024#
+ 1#0:[email protected]#ROOT2024#;#0:[email protected]#ROOT2024#
+ 1.0#0:[email protected]#ROOT2024#;#0:[email protected]#ROOT2024#
+ (#0:[email protected]#ROOT2024#(#0:[email protected]#ROOT2024#1#0:[email protected]#ROOT2024#,#0:[email protected]#ROOT2024# )#0:[email protected]#ROOT2024#,#0:[email protected]#ROOT2024# )#0:[email protected]#ROOT2024#.#0:[email protected]#ROOT2024#0#0:[email protected]#ROOT2024#.#0:[email protected]#ROOT2024#0#0:[email protected]#ROOT2024#;#0:[email protected]#ROOT2024#
+ let#0:[email protected]#ROOT2024# x#0:[email protected]#ROOT2024# =#0:[email protected]#ROOT2024# 1#0:[email protected]#ROOT2024#;#0:[email protected]#ROOT2024#
+}#0:[email protected]#ROOT2024#
"#]],
@@ -171,7 +171,7 @@ fn main(foo: ()) {
}
fn main(foo: ()) {
- /* error: unresolved macro unresolved */"helloworld!"#0:[email protected]#2#;
+ /* error: unresolved macro unresolved */"helloworld!"#0:[email protected]#ROOT2024#;
}
}
@@ -197,7 +197,7 @@ macro_rules! mk_struct {
#[macro_use]
mod foo;
+struct#1:[email protected]#14336# Foo#0:[email protected]#ROOT2024#(#1:[email protected]#14336#u32#0:[email protected]#ROOT2024#)#1:[email protected]#14336#;#1:[email protected]#14336#
"#]],
);
}
@@ -423,10 +423,10 @@ m! { foo, bar }
macro_rules! m {
($($i:ident),*) => ( impl Bar { $(fn $i() {})* } );
}
-impl#\4# Bar#\4# {#\4#
- fn#\4# foo#\2#(#\4#)#\4# {#\4#}#\4#
- fn#\4# bar#\2#(#\4#)#\4# {#\4#}#\4#
-}#\4#
+impl#\14336# Bar#\14336# {#\14336#
+ fn#\14336# foo#\ROOT2024#(#\14336#)#\14336# {#\14336#}#\14336#
+ fn#\14336# bar#\ROOT2024#(#\14336#)#\14336# {#\14336#}#\14336#
+}#\14336#
"#]],
);
}
@@ -1408,7 +1408,7 @@ ok!();
macro_rules! m2 {
($($a:expr => $b:ident)* _ => $c:expr) => { ok!(); }
}
-ok!();
+/* error: unexpected token in input */ok!();
"#]],
);
}
@@ -1979,3 +1979,51 @@ fn f() {
"#]],
);
}
+
+#[test]
+fn semicolon_does_not_glue() {
+ check(
+ r#"
+macro_rules! bug {
+ ($id: expr) => {
+ true
+ };
+ ($id: expr; $($attr: ident),*) => {
+ true
+ };
+ ($id: expr; $($attr: ident),*; $norm: expr) => {
+ true
+ };
+ ($id: expr; $($attr: ident),*;; $print: expr) => {
+ true
+ };
+ ($id: expr; $($attr: ident),*; $norm: expr; $print: expr) => {
+ true
+ };
+}
+
+let _ = bug!(a;;;test);
+ "#,
+ expect![[r#"
+macro_rules! bug {
+ ($id: expr) => {
+ true
+ };
+ ($id: expr; $($attr: ident),*) => {
+ true
+ };
+ ($id: expr; $($attr: ident),*; $norm: expr) => {
+ true
+ };
+ ($id: expr; $($attr: ident),*;; $print: expr) => {
+ true
+ };
+ ($id: expr; $($attr: ident),*; $norm: expr; $print: expr) => {
+ true
+ };
+}
+
+let _ = true;
+ "#]],
+ );
+}