File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -128,7 +128,7 @@ fn hover_text_from_name_kind(db: &RootDatabase, name_kind: NameKind) -> Option<S
128
128
hir:: ModuleDef :: TypeAlias ( it) => from_def_source ( db, it) ,
129
129
hir:: ModuleDef :: BuiltinType ( it) => Some ( it. to_string ( ) ) ,
130
130
} ,
131
- Local ( _ ) => None ,
131
+ Local ( it ) => Some ( rust_code_markup ( it . ty ( db ) . display_truncated ( db , None ) . to_string ( ) ) ) ,
132
132
TypeParam ( _) | SelfType ( _) => {
133
133
// FIXME: Hover for generic param
134
134
None
@@ -174,6 +174,8 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn
174
174
. value
175
175
. ancestors ( )
176
176
. find ( |n| ast:: Expr :: cast ( n. clone ( ) ) . is_some ( ) || ast:: Pat :: cast ( n. clone ( ) ) . is_some ( ) ) ?;
177
+
178
+ // The following logic will not work if token is coming from a macro
177
179
let frange = FileRange { file_id : position. file_id , range : node. text_range ( ) } ;
178
180
res. extend ( type_of ( db, frange) . map ( rust_code_markup) ) ;
179
181
if res. is_empty ( ) {
@@ -729,4 +731,20 @@ fn func(foo: i32) { if true { <|>foo; }; }
729
731
& [ "fn foo()" ] ,
730
732
) ;
731
733
}
734
+
735
+ #[ test]
736
+ fn test_hover_through_expr_in_macro ( ) {
737
+ check_hover_result (
738
+ "
739
+ //- /lib.rs
740
+ macro_rules! id {
741
+ ($($tt:tt)*) => { $($tt)* }
742
+ }
743
+ fn foo(bar:u32) {
744
+ let a = id!(ba<|>r);
745
+ }
746
+ " ,
747
+ & [ "u32" ] ,
748
+ ) ;
749
+ }
732
750
}
You can’t perform that action at this time.
0 commit comments