aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2020-03-13 12:03:31 +0000
committerFlorian Diebold <[email protected]>2020-03-16 17:38:19 +0000
commitb973158aeb337041d4e1434cf5d8c609a0b02bef (patch)
treee3da1bb7a3c2d89623382865edc7ef64c039496d /crates/ra_ide
parentd3773ec1522681de117d354f0c82e753c68c6d0b (diff)
Make MBE expansion more resilient (WIP)
Diffstat (limited to 'crates/ra_ide')
-rw-r--r--crates/ra_ide/src/completion/complete_dot.rs37
-rw-r--r--crates/ra_ide/src/expand_macro.rs2
2 files changed, 38 insertions, 1 deletions
diff --git a/crates/ra_ide/src/completion/complete_dot.rs b/crates/ra_ide/src/completion/complete_dot.rs
index f07611d88..a30d1c2de 100644
--- a/crates/ra_ide/src/completion/complete_dot.rs
+++ b/crates/ra_ide/src/completion/complete_dot.rs
@@ -752,6 +752,43 @@ mod tests {
752 } 752 }
753 753
754 #[test] 754 #[test]
755 fn macro_expansion_resilient() {
756 assert_debug_snapshot!(
757 do_ref_completion(
758 r"
759 macro_rules! dbg {
760 () => {};
761 ($val:expr) => {
762 match $val { tmp => { tmp } }
763 };
764 // Trailing comma with single argument is ignored
765 ($val:expr,) => { $crate::dbg!($val) };
766 ($($val:expr),+ $(,)?) => {
767 ($($crate::dbg!($val)),+,)
768 };
769 }
770 struct A { the_field: u32 }
771 fn foo(a: A) {
772 dbg!(a.<|>)
773 }
774 ",
775 ),
776 @r###"
777 [
778 CompletionItem {
779 label: "the_field",
780 source_range: [552; 553),
781 delete: [552; 553),
782 insert: "the_field",
783 kind: Field,
784 detail: "u32",
785 },
786 ]
787 "###
788 );
789 }
790
791 #[test]
755 fn test_method_completion_3547() { 792 fn test_method_completion_3547() {
756 assert_debug_snapshot!( 793 assert_debug_snapshot!(
757 do_ref_completion( 794 do_ref_completion(
diff --git a/crates/ra_ide/src/expand_macro.rs b/crates/ra_ide/src/expand_macro.rs
index f6667cb33..e58526f31 100644
--- a/crates/ra_ide/src/expand_macro.rs
+++ b/crates/ra_ide/src/expand_macro.rs
@@ -259,7 +259,7 @@ fn some_thing() -> u32 {
259 ); 259 );
260 260
261 assert_eq!(res.name, "foo"); 261 assert_eq!(res.name, "foo");
262 assert_snapshot!(res.expansion, @r###"bar!()"###); 262 assert_snapshot!(res.expansion, @r###""###);
263 } 263 }
264 264
265 #[test] 265 #[test]