Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide/src/expand_macro.rs')
-rw-r--r--crates/ide/src/expand_macro.rs61
1 files changed, 61 insertions, 0 deletions
diff --git a/crates/ide/src/expand_macro.rs b/crates/ide/src/expand_macro.rs
index 7c396339c1..f31886b969 100644
--- a/crates/ide/src/expand_macro.rs
+++ b/crates/ide/src/expand_macro.rs
@@ -800,4 +800,65 @@ foo();
foo();"#]],
);
}
+
+ #[test]
+ fn works_in_sig() {
+ check(
+ r#"
+macro_rules! foo {
+ () => { u32 };
+}
+fn foo() -> foo$0!() {
+ 42
+}
+"#,
+ expect![[r#"
+ foo!
+ u32"#]],
+ );
+ check(
+ r#"
+macro_rules! foo {
+ () => { u32 };
+}
+fn foo(_: foo$0!() ) {}
+"#,
+ expect![[r#"
+ foo!
+ u32"#]],
+ );
+ }
+
+ #[test]
+ fn works_in_generics() {
+ check(
+ r#"
+trait Trait {}
+macro_rules! foo {
+ () => { Trait };
+}
+impl<const C: foo$0!()> Trait for () {}
+"#,
+ expect![[r#"
+ foo!
+ Trait"#]],
+ );
+ }
+
+ #[test]
+ fn works_in_fields() {
+ check(
+ r#"
+macro_rules! foo {
+ () => { u32 };
+}
+struct S {
+ field: foo$0!(),
+}
+"#,
+ expect![[r#"
+ foo!
+ u32"#]],
+ );
+ }
}