diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-03-12 15:38:04 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-03-12 15:38:04 +0000 |
commit | 944bd2cbc3af1a11eb6dbaec96fcc0030f42232a (patch) | |
tree | a397f2d024d08c253386242d27e6543ab2fb790f /crates/ra_ide | |
parent | b08f26c0f8bcc640ee54914ac91da2e0d1b3e607 (diff) | |
parent | 8f7703b006bb35ab08959b01ed8ffb27d07f4d0b (diff) |
Merge #3559
3559: Implement builtin assert! macro r=matklad a=edwin0cheng
This PR add a dummy implementation for `assert!` macro, which mainly make `hover` and `goto-def` works on arguments inside it.
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_ide')
-rw-r--r-- | crates/ra_ide/src/hover.rs | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs index 25e038a55..0bbba4855 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs | |||
@@ -833,19 +833,34 @@ fn func(foo: i32) { if true { <|>foo; }; } | |||
833 | } | 833 | } |
834 | 834 | ||
835 | #[test] | 835 | #[test] |
836 | fn test_hover_through_assert_macro() { | ||
837 | let hover_on = check_hover_result( | ||
838 | r#" | ||
839 | //- /lib.rs | ||
840 | #[rustc_builtin_macro] | ||
841 | macro_rules! assert {} | ||
842 | |||
843 | fn bar() -> bool { true } | ||
844 | fn foo() { | ||
845 | assert!(ba<|>r()); | ||
846 | } | ||
847 | "#, | ||
848 | &["fn bar() -> bool"], | ||
849 | ); | ||
850 | |||
851 | assert_eq!(hover_on, "bar"); | ||
852 | } | ||
853 | |||
854 | #[test] | ||
836 | fn test_hover_through_literal_string_in_builtin_macro() { | 855 | fn test_hover_through_literal_string_in_builtin_macro() { |
837 | check_hover_no_result( | 856 | check_hover_no_result( |
838 | r#" | 857 | r#" |
839 | //- /lib.rs | 858 | //- /lib.rs |
840 | #[rustc_builtin_macro] | 859 | #[rustc_builtin_macro] |
841 | macro_rules! assert { | 860 | macro_rules! format {} |
842 | ($cond:expr) => {{ /* compiler built-in */ }}; | ||
843 | ($cond:expr,) => {{ /* compiler built-in */ }}; | ||
844 | ($cond:expr, $($arg:tt)+) => {{ /* compiler built-in */ }}; | ||
845 | } | ||
846 | 861 | ||
847 | fn foo() { | 862 | fn foo() { |
848 | assert!("hel<|>lo"); | 863 | format!("hel<|>lo {}", 0); |
849 | } | 864 | } |
850 | "#, | 865 | "#, |
851 | ); | 866 | ); |