diff options
author | Edwin Cheng <[email protected]> | 2020-02-27 15:03:18 +0000 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2020-02-27 15:03:18 +0000 |
commit | c42bbc5e37dee8b1de309a6dd5b892651de4b676 (patch) | |
tree | ba013c582f4c6e1c24adf3d1c943da939c751362 /crates/ra_ide/src/hover.rs | |
parent | 57f0d6cba3b2c7b0a2ac384ab0cb73983afd2a5e (diff) |
Ignore hover on builtin macro
Diffstat (limited to 'crates/ra_ide/src/hover.rs')
-rw-r--r-- | crates/ra_ide/src/hover.rs | 25 |
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 | " |