aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-02-27 15:48:22 +0000
committerGitHub <[email protected]>2020-02-27 15:48:22 +0000
commitfedab39011e1225b580f5afce8607c8eedad77e1 (patch)
treeb65e2b8b20f490b6d634b52553cdc527cea610d0 /crates
parentde492d439f0cda73fe2d9b25e4d9f028f70eb095 (diff)
parentc42bbc5e37dee8b1de309a6dd5b892651de4b676 (diff)
Merge pull request #3350 from edwin0cheng/give-up-hover-in-builtin-macro
Ignore hover on builtin macro
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_ide/src/hover.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs
index 177038e20..dfa0f1d97 100644
--- a/crates/ra_ide/src/hover.rs
+++ b/crates/ra_ide/src/hover.rs
@@ -174,6 +174,12 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn
174 .ancestors() 174 .ancestors()
175 .find(|n| ast::Expr::cast(n.clone()).is_some() || ast::Pat::cast(n.clone()).is_some())?; 175 .find(|n| ast::Expr::cast(n.clone()).is_some() || ast::Pat::cast(n.clone()).is_some())?;
176 176
177 // if this node is a MACRO_CALL, it means that `descend_into_macros` is failed to resolve.
178 // (e.g expanding a builtin macro). So we give up here.
179 if node.kind() == MACRO_CALL {
180 return None;
181 }
182
177 // FIXME: Currently `hover::typeof` do not work inside 183 // FIXME: Currently `hover::typeof` do not work inside
178 // macro expansion such that if the hover range is pointing to 184 // macro expansion such that if the hover range is pointing to
179 // a string literal, the following type_of will return None. 185 // a string literal, the following type_of will return None.
@@ -802,6 +808,25 @@ fn func(foo: i32) { if true { <|>foo; }; }
802 } 808 }
803 809
804 #[test] 810 #[test]
811 fn test_hover_through_literal_string_in_builtin_macro() {
812 check_hover_no_result(
813 r#"
814 //- /lib.rs
815 #[rustc_builtin_macro]
816 macro_rules! assert {
817 ($cond:expr) => {{ /* compiler built-in */ }};
818 ($cond:expr,) => {{ /* compiler built-in */ }};
819 ($cond:expr, $($arg:tt)+) => {{ /* compiler built-in */ }};
820 }
821
822 fn foo() {
823 assert!("hel<|>lo");
824 }
825 "#,
826 );
827 }
828
829 #[test]
805 fn test_hover_non_ascii_space_doc() { 830 fn test_hover_non_ascii_space_doc() {
806 check_hover_result( 831 check_hover_result(
807 " 832 "