aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-12-06 18:30:15 +0000
committerFlorian Diebold <[email protected]>2019-12-06 20:25:22 +0000
commita565072ddeac519eea3b415a57e9fd208e20e562 (patch)
tree4c76dbe6729de22de2f00862b56ed5dfd46d699b /crates/ra_ide/src
parenteae425b10fd7803ae67d2d39e9aca902daa353ba (diff)
Try to make go to definition work in format!
SourceAnalyzer didn't work properly within expression macro expansions because it didn't find the enclosing function. Fix this by going up the expansion chain to find ancestors. This makes the test work, but apparently in real usage it's still not working.
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r--crates/ra_ide/src/goto_definition.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs
index 76a741207..b1d567ca7 100644
--- a/crates/ra_ide/src/goto_definition.rs
+++ b/crates/ra_ide/src/goto_definition.rs
@@ -693,4 +693,31 @@ mod tests {
693 "foo FN_DEF FileId(1) [52; 63) [55; 58)", 693 "foo FN_DEF FileId(1) [52; 63) [55; 58)",
694 ); 694 );
695 } 695 }
696
697 #[test]
698 fn goto_through_format() {
699 check_goto(
700 "
701 //- /lib.rs
702 #[macro_export]
703 macro_rules! format {
704 ($($arg:tt)*) => ($crate::fmt::format($crate::__export::format_args!($($arg)*)))
705 }
706 #[rustc_builtin_macro]
707 #[macro_export]
708 macro_rules! format_args {
709 ($fmt:expr) => ({ /* compiler built-in */ });
710 ($fmt:expr, $($args:tt)*) => ({ /* compiler built-in */ })
711 }
712 pub mod __export {
713 pub use crate::format_args;
714 }
715 fn foo() -> i8 {}
716 fn test() {
717 format!(\"{}\", fo<|>o())
718 }
719 ",
720 "foo FN_DEF FileId(1) [359; 376) [362; 365)",
721 );
722 }
696} 723}