diff options
Diffstat (limited to 'crates/ide/src/hover.rs')
-rw-r--r-- | crates/ide/src/hover.rs | 313 |
1 files changed, 171 insertions, 142 deletions
diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index a12a2475e..2024acd94 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use hir::{ | 1 | use hir::{ |
2 | Adt, AsAssocItem, AssocItemContainer, FieldSource, HasAttrs, HasSource, HirDisplay, Module, | 2 | Adt, AsAssocItem, AssocItemContainer, FieldSource, GenericParam, HasAttrs, HasSource, |
3 | ModuleDef, ModuleSource, Semantics, | 3 | HirDisplay, Module, ModuleDef, ModuleSource, Semantics, |
4 | }; | 4 | }; |
5 | use ide_db::base_db::SourceDatabase; | 5 | use ide_db::base_db::SourceDatabase; |
6 | use ide_db::{ | 6 | use ide_db::{ |
@@ -17,7 +17,7 @@ use crate::{ | |||
17 | doc_links::{remove_links, rewrite_links}, | 17 | doc_links::{remove_links, rewrite_links}, |
18 | markdown_remove::remove_markdown, | 18 | markdown_remove::remove_markdown, |
19 | markup::Markup, | 19 | markup::Markup, |
20 | runnables::{runnable, runnable_fn}, | 20 | runnables::{runnable_fn, runnable_mod}, |
21 | FileId, FilePosition, NavigationTarget, RangeInfo, Runnable, | 21 | FileId, FilePosition, NavigationTarget, RangeInfo, Runnable, |
22 | }; | 22 | }; |
23 | 23 | ||
@@ -134,17 +134,14 @@ pub(crate) fn hover( | |||
134 | return None; | 134 | return None; |
135 | } | 135 | } |
136 | 136 | ||
137 | let node = token.ancestors().find(|n| { | 137 | let node = token |
138 | ast::Expr::can_cast(n.kind()) | 138 | .ancestors() |
139 | || ast::Pat::can_cast(n.kind()) | 139 | .find(|n| ast::Expr::can_cast(n.kind()) || ast::Pat::can_cast(n.kind()))?; |
140 | || ast::SelfParam::can_cast(n.kind()) | ||
141 | })?; | ||
142 | 140 | ||
143 | let ty = match_ast! { | 141 | let ty = match_ast! { |
144 | match node { | 142 | match node { |
145 | ast::Expr(it) => sema.type_of_expr(&it)?, | 143 | ast::Expr(it) => sema.type_of_expr(&it)?, |
146 | ast::Pat(it) => sema.type_of_pat(&it)?, | 144 | ast::Pat(it) => sema.type_of_pat(&it)?, |
147 | ast::SelfParam(self_param) => sema.type_of_self(&self_param)?, | ||
148 | // If this node is a MACRO_CALL, it means that `descend_into_macros` failed to resolve. | 145 | // If this node is a MACRO_CALL, it means that `descend_into_macros` failed to resolve. |
149 | // (e.g expanding a builtin macro). So we give up here. | 146 | // (e.g expanding a builtin macro). So we give up here. |
150 | ast::MacroCall(_it) => return None, | 147 | ast::MacroCall(_it) => return None, |
@@ -175,12 +172,7 @@ fn show_implementations_action(db: &RootDatabase, def: Definition) -> Option<Hov | |||
175 | Definition::SelfType(it) => it.target_ty(db).as_adt(), | 172 | Definition::SelfType(it) => it.target_ty(db).as_adt(), |
176 | _ => None, | 173 | _ => None, |
177 | }?; | 174 | }?; |
178 | match adt { | 175 | adt.try_to_nav(db).map(to_action) |
179 | Adt::Struct(it) => it.try_to_nav(db), | ||
180 | Adt::Union(it) => it.try_to_nav(db), | ||
181 | Adt::Enum(it) => it.try_to_nav(db), | ||
182 | } | ||
183 | .map(to_action) | ||
184 | } | 176 | } |
185 | 177 | ||
186 | fn runnable_action( | 178 | fn runnable_action( |
@@ -192,7 +184,7 @@ fn runnable_action( | |||
192 | Definition::ModuleDef(it) => match it { | 184 | Definition::ModuleDef(it) => match it { |
193 | ModuleDef::Module(it) => match it.definition_source(sema.db).value { | 185 | ModuleDef::Module(it) => match it.definition_source(sema.db).value { |
194 | ModuleSource::Module(it) => { | 186 | ModuleSource::Module(it) => { |
195 | runnable(&sema, it.syntax().clone()).map(|it| HoverAction::Runnable(it)) | 187 | runnable_mod(&sema, it).map(|it| HoverAction::Runnable(it)) |
196 | } | 188 | } |
197 | _ => None, | 189 | _ => None, |
198 | }, | 190 | }, |
@@ -220,12 +212,12 @@ fn goto_type_action(db: &RootDatabase, def: Definition) -> Option<HoverAction> { | |||
220 | } | 212 | } |
221 | }; | 213 | }; |
222 | 214 | ||
223 | if let Definition::TypeParam(it) = def { | 215 | if let Definition::GenericParam(GenericParam::TypeParam(it)) = def { |
224 | it.trait_bounds(db).into_iter().for_each(|it| push_new_def(it.into())); | 216 | it.trait_bounds(db).into_iter().for_each(|it| push_new_def(it.into())); |
225 | } else { | 217 | } else { |
226 | let ty = match def { | 218 | let ty = match def { |
227 | Definition::Local(it) => it.ty(db), | 219 | Definition::Local(it) => it.ty(db), |
228 | Definition::ConstParam(it) => it.ty(db), | 220 | Definition::GenericParam(GenericParam::ConstParam(it)) => it.ty(db), |
229 | _ => return None, | 221 | _ => return None, |
230 | }; | 222 | }; |
231 | 223 | ||
@@ -357,9 +349,11 @@ fn hover_for_definition(db: &RootDatabase, def: Definition) -> Option<Markup> { | |||
357 | }) | 349 | }) |
358 | } | 350 | } |
359 | Definition::Label(it) => Some(Markup::fenced_block(&it.name(db))), | 351 | Definition::Label(it) => Some(Markup::fenced_block(&it.name(db))), |
360 | Definition::LifetimeParam(it) => Some(Markup::fenced_block(&it.name(db))), | 352 | Definition::GenericParam(it) => match it { |
361 | Definition::TypeParam(type_param) => Some(Markup::fenced_block(&type_param.display(db))), | 353 | GenericParam::TypeParam(it) => Some(Markup::fenced_block(&it.display(db))), |
362 | Definition::ConstParam(it) => from_def_source(db, it, None), | 354 | GenericParam::LifetimeParam(it) => Some(Markup::fenced_block(&it.name(db))), |
355 | GenericParam::ConstParam(it) => from_def_source(db, it, None), | ||
356 | }, | ||
363 | }; | 357 | }; |
364 | 358 | ||
365 | fn from_def_source<A, D>(db: &RootDatabase, def: D, mod_path: Option<String>) -> Option<Markup> | 359 | fn from_def_source<A, D>(db: &RootDatabase, def: D, mod_path: Option<String>) -> Option<Markup> |
@@ -389,7 +383,7 @@ fn pick_best(tokens: TokenAtOffset<SyntaxToken>) -> Option<SyntaxToken> { | |||
389 | return tokens.max_by_key(priority); | 383 | return tokens.max_by_key(priority); |
390 | fn priority(n: &SyntaxToken) -> usize { | 384 | fn priority(n: &SyntaxToken) -> usize { |
391 | match n.kind() { | 385 | match n.kind() { |
392 | IDENT | INT_NUMBER | LIFETIME_IDENT => 3, | 386 | IDENT | INT_NUMBER | LIFETIME_IDENT | T![self] => 3, |
393 | T!['('] | T![')'] => 2, | 387 | T!['('] | T![')'] => 2, |
394 | kind if kind.is_trivia() => 0, | 388 | kind if kind.is_trivia() => 0, |
395 | _ => 1, | 389 | _ => 1, |
@@ -457,7 +451,7 @@ mod tests { | |||
457 | pub fn foo() -> u32 { 1 } | 451 | pub fn foo() -> u32 { 1 } |
458 | 452 | ||
459 | fn main() { | 453 | fn main() { |
460 | let foo_test = foo()<|>; | 454 | let foo_test = foo()$0; |
461 | } | 455 | } |
462 | "#, | 456 | "#, |
463 | expect![[r#" | 457 | expect![[r#" |
@@ -476,7 +470,7 @@ fn main() { | |||
476 | pub fn foo() -> u32 { 1 } | 470 | pub fn foo() -> u32 { 1 } |
477 | 471 | ||
478 | fn main() { | 472 | fn main() { |
479 | let foo_test = foo()<|>; | 473 | let foo_test = foo()$0; |
480 | } | 474 | } |
481 | "#, | 475 | "#, |
482 | expect![[r#" | 476 | expect![[r#" |
@@ -506,7 +500,7 @@ fn main() { | |||
506 | Option::Some(*memo + value) | 500 | Option::Some(*memo + value) |
507 | }; | 501 | }; |
508 | let number = 5u32; | 502 | let number = 5u32; |
509 | let mut iter<|> = scan(OtherStruct { i: num }, closure, number); | 503 | let mut iter$0 = scan(OtherStruct { i: num }, closure, number); |
510 | } | 504 | } |
511 | "#, | 505 | "#, |
512 | expect![[r#" | 506 | expect![[r#" |
@@ -526,7 +520,7 @@ fn main() { | |||
526 | r#" | 520 | r#" |
527 | pub fn foo() -> u32 { 1 } | 521 | pub fn foo() -> u32 { 1 } |
528 | 522 | ||
529 | fn main() { let foo_test = fo<|>o(); } | 523 | fn main() { let foo_test = fo$0o(); } |
530 | "#, | 524 | "#, |
531 | expect![[r#" | 525 | expect![[r#" |
532 | *foo* | 526 | *foo* |
@@ -558,7 +552,7 @@ mod a; | |||
558 | mod b; | 552 | mod b; |
559 | mod c; | 553 | mod c; |
560 | 554 | ||
561 | fn main() { let foo_test = fo<|>o(); } | 555 | fn main() { let foo_test = fo$0o(); } |
562 | "#, | 556 | "#, |
563 | expect![[r#" | 557 | expect![[r#" |
564 | *foo* | 558 | *foo* |
@@ -575,7 +569,7 @@ fn main() { let foo_test = fo<|>o(); } | |||
575 | r#" | 569 | r#" |
576 | pub fn foo<'a, T: AsRef<str>>(b: &'a T) -> &'a str { } | 570 | pub fn foo<'a, T: AsRef<str>>(b: &'a T) -> &'a str { } |
577 | 571 | ||
578 | fn main() { let foo_test = fo<|>o(); } | 572 | fn main() { let foo_test = fo$0o(); } |
579 | "#, | 573 | "#, |
580 | expect![[r#" | 574 | expect![[r#" |
581 | *foo* | 575 | *foo* |
@@ -595,7 +589,7 @@ fn main() { let foo_test = fo<|>o(); } | |||
595 | fn hover_shows_fn_signature_on_fn_name() { | 589 | fn hover_shows_fn_signature_on_fn_name() { |
596 | check( | 590 | check( |
597 | r#" | 591 | r#" |
598 | pub fn foo<|>(a: u32, b: u32) -> u32 {} | 592 | pub fn foo$0(a: u32, b: u32) -> u32 {} |
599 | 593 | ||
600 | fn main() { } | 594 | fn main() { } |
601 | "#, | 595 | "#, |
@@ -623,7 +617,7 @@ fn main() { } | |||
623 | /// # | 617 | /// # |
624 | /// foo(Path::new("hello, world!")) | 618 | /// foo(Path::new("hello, world!")) |
625 | /// ``` | 619 | /// ``` |
626 | pub fn foo<|>(_: &Path) {} | 620 | pub fn foo$0(_: &Path) {} |
627 | 621 | ||
628 | fn main() { } | 622 | fn main() { } |
629 | "#, | 623 | "#, |
@@ -656,7 +650,7 @@ fn main() { } | |||
656 | check( | 650 | check( |
657 | r##" | 651 | r##" |
658 | #[doc = r#"Raw string doc attr"#] | 652 | #[doc = r#"Raw string doc attr"#] |
659 | pub fn foo<|>(_: &Path) {} | 653 | pub fn foo$0(_: &Path) {} |
660 | 654 | ||
661 | fn main() { } | 655 | fn main() { } |
662 | "##, | 656 | "##, |
@@ -686,7 +680,7 @@ fn main() { } | |||
686 | struct Foo { field_a: u32 } | 680 | struct Foo { field_a: u32 } |
687 | 681 | ||
688 | fn main() { | 682 | fn main() { |
689 | let foo = Foo { field_a<|>: 0, }; | 683 | let foo = Foo { field_a$0: 0, }; |
690 | } | 684 | } |
691 | "#, | 685 | "#, |
692 | expect![[r#" | 686 | expect![[r#" |
@@ -705,7 +699,7 @@ fn main() { | |||
705 | // Hovering over the field in the definition | 699 | // Hovering over the field in the definition |
706 | check( | 700 | check( |
707 | r#" | 701 | r#" |
708 | struct Foo { field_a<|>: u32 } | 702 | struct Foo { field_a$0: u32 } |
709 | 703 | ||
710 | fn main() { | 704 | fn main() { |
711 | let foo = Foo { field_a: 0 }; | 705 | let foo = Foo { field_a: 0 }; |
@@ -728,7 +722,7 @@ fn main() { | |||
728 | #[test] | 722 | #[test] |
729 | fn hover_const_static() { | 723 | fn hover_const_static() { |
730 | check( | 724 | check( |
731 | r#"const foo<|>: u32 = 123;"#, | 725 | r#"const foo$0: u32 = 123;"#, |
732 | expect![[r#" | 726 | expect![[r#" |
733 | *foo* | 727 | *foo* |
734 | 728 | ||
@@ -742,7 +736,7 @@ fn main() { | |||
742 | "#]], | 736 | "#]], |
743 | ); | 737 | ); |
744 | check( | 738 | check( |
745 | r#"static foo<|>: u32 = 456;"#, | 739 | r#"static foo$0: u32 = 456;"#, |
746 | expect![[r#" | 740 | expect![[r#" |
747 | *foo* | 741 | *foo* |
748 | 742 | ||
@@ -764,7 +758,7 @@ fn main() { | |||
764 | struct Test<K, T = u8> { k: K, t: T } | 758 | struct Test<K, T = u8> { k: K, t: T } |
765 | 759 | ||
766 | fn main() { | 760 | fn main() { |
767 | let zz<|> = Test { t: 23u8, k: 33 }; | 761 | let zz$0 = Test { t: 23u8, k: 33 }; |
768 | }"#, | 762 | }"#, |
769 | expect![[r#" | 763 | expect![[r#" |
770 | *zz* | 764 | *zz* |
@@ -783,7 +777,7 @@ fn main() { | |||
783 | enum Option<T> { Some(T) } | 777 | enum Option<T> { Some(T) } |
784 | use Option::Some; | 778 | use Option::Some; |
785 | 779 | ||
786 | fn main() { So<|>me(12); } | 780 | fn main() { So$0me(12); } |
787 | "#, | 781 | "#, |
788 | expect![[r#" | 782 | expect![[r#" |
789 | *Some* | 783 | *Some* |
@@ -803,7 +797,7 @@ fn main() { So<|>me(12); } | |||
803 | enum Option<T> { Some(T) } | 797 | enum Option<T> { Some(T) } |
804 | use Option::Some; | 798 | use Option::Some; |
805 | 799 | ||
806 | fn main() { let b<|>ar = Some(12); } | 800 | fn main() { let b$0ar = Some(12); } |
807 | "#, | 801 | "#, |
808 | expect![[r#" | 802 | expect![[r#" |
809 | *bar* | 803 | *bar* |
@@ -821,7 +815,7 @@ fn main() { let b<|>ar = Some(12); } | |||
821 | r#" | 815 | r#" |
822 | enum Option<T> { | 816 | enum Option<T> { |
823 | /// The None variant | 817 | /// The None variant |
824 | Non<|>e | 818 | Non$0e |
825 | } | 819 | } |
826 | "#, | 820 | "#, |
827 | expect![[r#" | 821 | expect![[r#" |
@@ -848,7 +842,7 @@ enum Option<T> { | |||
848 | Some(T) | 842 | Some(T) |
849 | } | 843 | } |
850 | fn main() { | 844 | fn main() { |
851 | let s = Option::Som<|>e(12); | 845 | let s = Option::Som$0e(12); |
852 | } | 846 | } |
853 | "#, | 847 | "#, |
854 | expect![[r#" | 848 | expect![[r#" |
@@ -872,7 +866,7 @@ fn main() { | |||
872 | #[test] | 866 | #[test] |
873 | fn hover_for_local_variable() { | 867 | fn hover_for_local_variable() { |
874 | check( | 868 | check( |
875 | r#"fn func(foo: i32) { fo<|>o; }"#, | 869 | r#"fn func(foo: i32) { fo$0o; }"#, |
876 | expect![[r#" | 870 | expect![[r#" |
877 | *foo* | 871 | *foo* |
878 | 872 | ||
@@ -886,7 +880,7 @@ fn main() { | |||
886 | #[test] | 880 | #[test] |
887 | fn hover_for_local_variable_pat() { | 881 | fn hover_for_local_variable_pat() { |
888 | check( | 882 | check( |
889 | r#"fn func(fo<|>o: i32) {}"#, | 883 | r#"fn func(fo$0o: i32) {}"#, |
890 | expect![[r#" | 884 | expect![[r#" |
891 | *foo* | 885 | *foo* |
892 | 886 | ||
@@ -900,7 +894,7 @@ fn main() { | |||
900 | #[test] | 894 | #[test] |
901 | fn hover_local_var_edge() { | 895 | fn hover_local_var_edge() { |
902 | check( | 896 | check( |
903 | r#"fn func(foo: i32) { if true { <|>foo; }; }"#, | 897 | r#"fn func(foo: i32) { if true { $0foo; }; }"#, |
904 | expect![[r#" | 898 | expect![[r#" |
905 | *foo* | 899 | *foo* |
906 | 900 | ||
@@ -914,7 +908,7 @@ fn main() { | |||
914 | #[test] | 908 | #[test] |
915 | fn hover_for_param_edge() { | 909 | fn hover_for_param_edge() { |
916 | check( | 910 | check( |
917 | r#"fn func(<|>foo: i32) {}"#, | 911 | r#"fn func($0foo: i32) {}"#, |
918 | expect![[r#" | 912 | expect![[r#" |
919 | *foo* | 913 | *foo* |
920 | 914 | ||
@@ -934,7 +928,7 @@ fn main() { | |||
934 | trait DerefMut { | 928 | trait DerefMut { |
935 | type Target: ?Sized; | 929 | type Target: ?Sized; |
936 | } | 930 | } |
937 | fn f(_x<|>: impl Deref<Target=u8> + DerefMut<Target=u8>) {}"#, | 931 | fn f(_x$0: impl Deref<Target=u8> + DerefMut<Target=u8>) {}"#, |
938 | expect![[r#" | 932 | expect![[r#" |
939 | *_x* | 933 | *_x* |
940 | 934 | ||
@@ -955,7 +949,7 @@ impl Thing { | |||
955 | fn new() -> Thing { Thing { x: 0 } } | 949 | fn new() -> Thing { Thing { x: 0 } } |
956 | } | 950 | } |
957 | 951 | ||
958 | fn main() { let foo_<|>test = Thing::new(); } | 952 | fn main() { let foo_$0test = Thing::new(); } |
959 | "#, | 953 | "#, |
960 | expect![[r#" | 954 | expect![[r#" |
961 | *foo_test* | 955 | *foo_test* |
@@ -979,7 +973,7 @@ mod wrapper { | |||
979 | } | 973 | } |
980 | } | 974 | } |
981 | 975 | ||
982 | fn main() { let foo_test = wrapper::Thing::new<|>(); } | 976 | fn main() { let foo_test = wrapper::Thing::new$0(); } |
983 | "#, | 977 | "#, |
984 | expect![[r#" | 978 | expect![[r#" |
985 | *new* | 979 | *new* |
@@ -1006,7 +1000,7 @@ impl X { | |||
1006 | 1000 | ||
1007 | fn main() { | 1001 | fn main() { |
1008 | match 1 { | 1002 | match 1 { |
1009 | X::C<|> => {}, | 1003 | X::C$0 => {}, |
1010 | 2 => {}, | 1004 | 2 => {}, |
1011 | _ => {} | 1005 | _ => {} |
1012 | }; | 1006 | }; |
@@ -1032,7 +1026,7 @@ fn main() { | |||
1032 | r#" | 1026 | r#" |
1033 | struct Thing { x: u32 } | 1027 | struct Thing { x: u32 } |
1034 | impl Thing { | 1028 | impl Thing { |
1035 | fn new() -> Self { Self<|> { x: 0 } } | 1029 | fn new() -> Self { Self$0 { x: 0 } } |
1036 | } | 1030 | } |
1037 | "#, | 1031 | "#, |
1038 | expect![[r#" | 1032 | expect![[r#" |
@@ -1051,7 +1045,7 @@ impl Thing { | |||
1051 | r#" | 1045 | r#" |
1052 | struct Thing { x: u32 } | 1046 | struct Thing { x: u32 } |
1053 | impl Thing { | 1047 | impl Thing { |
1054 | fn new() -> Self<|> { Self { x: 0 } } | 1048 | fn new() -> Self$0 { Self { x: 0 } } |
1055 | } | 1049 | } |
1056 | "#, | 1050 | "#, |
1057 | expect![[r#" | 1051 | expect![[r#" |
@@ -1070,7 +1064,7 @@ impl Thing { | |||
1070 | r#" | 1064 | r#" |
1071 | enum Thing { A } | 1065 | enum Thing { A } |
1072 | impl Thing { | 1066 | impl Thing { |
1073 | pub fn new() -> Self<|> { Thing::A } | 1067 | pub fn new() -> Self$0 { Thing::A } |
1074 | } | 1068 | } |
1075 | "#, | 1069 | "#, |
1076 | expect![[r#" | 1070 | expect![[r#" |
@@ -1089,7 +1083,7 @@ impl Thing { | |||
1089 | r#" | 1083 | r#" |
1090 | enum Thing { A } | 1084 | enum Thing { A } |
1091 | impl Thing { | 1085 | impl Thing { |
1092 | pub fn thing(a: Self<|>) {} | 1086 | pub fn thing(a: Self$0) {} |
1093 | } | 1087 | } |
1094 | "#, | 1088 | "#, |
1095 | expect![[r#" | 1089 | expect![[r#" |
@@ -1114,7 +1108,7 @@ fn x() {} | |||
1114 | 1108 | ||
1115 | fn y() { | 1109 | fn y() { |
1116 | let x = 0i32; | 1110 | let x = 0i32; |
1117 | x<|>; | 1111 | x$0; |
1118 | } | 1112 | } |
1119 | "#, | 1113 | "#, |
1120 | expect![[r#" | 1114 | expect![[r#" |
@@ -1133,7 +1127,7 @@ fn y() { | |||
1133 | r#" | 1127 | r#" |
1134 | macro_rules! foo { () => {} } | 1128 | macro_rules! foo { () => {} } |
1135 | 1129 | ||
1136 | fn f() { fo<|>o!(); } | 1130 | fn f() { fo$0o!(); } |
1137 | "#, | 1131 | "#, |
1138 | expect![[r#" | 1132 | expect![[r#" |
1139 | *foo* | 1133 | *foo* |
@@ -1152,7 +1146,7 @@ fn f() { fo<|>o!(); } | |||
1152 | #[test] | 1146 | #[test] |
1153 | fn test_hover_tuple_field() { | 1147 | fn test_hover_tuple_field() { |
1154 | check( | 1148 | check( |
1155 | r#"struct TS(String, i32<|>);"#, | 1149 | r#"struct TS(String, i32$0);"#, |
1156 | expect![[r#" | 1150 | expect![[r#" |
1157 | *i32* | 1151 | *i32* |
1158 | 1152 | ||
@@ -1170,7 +1164,7 @@ fn f() { fo<|>o!(); } | |||
1170 | macro_rules! id { ($($tt:tt)*) => { $($tt)* } } | 1164 | macro_rules! id { ($($tt:tt)*) => { $($tt)* } } |
1171 | fn foo() {} | 1165 | fn foo() {} |
1172 | id! { | 1166 | id! { |
1173 | fn bar() { fo<|>o(); } | 1167 | fn bar() { fo$0o(); } |
1174 | } | 1168 | } |
1175 | "#, | 1169 | "#, |
1176 | expect![[r#" | 1170 | expect![[r#" |
@@ -1192,7 +1186,7 @@ id! { | |||
1192 | check( | 1186 | check( |
1193 | r#" | 1187 | r#" |
1194 | macro_rules! id { ($($tt:tt)*) => { $($tt)* } } | 1188 | macro_rules! id { ($($tt:tt)*) => { $($tt)* } } |
1195 | fn foo(bar:u32) { let a = id!(ba<|>r); } | 1189 | fn foo(bar:u32) { let a = id!(ba$0r); } |
1196 | "#, | 1190 | "#, |
1197 | expect![[r#" | 1191 | expect![[r#" |
1198 | *bar* | 1192 | *bar* |
@@ -1210,7 +1204,7 @@ fn foo(bar:u32) { let a = id!(ba<|>r); } | |||
1210 | r#" | 1204 | r#" |
1211 | macro_rules! id_deep { ($($tt:tt)*) => { $($tt)* } } | 1205 | macro_rules! id_deep { ($($tt:tt)*) => { $($tt)* } } |
1212 | macro_rules! id { ($($tt:tt)*) => { id_deep!($($tt)*) } } | 1206 | macro_rules! id { ($($tt:tt)*) => { id_deep!($($tt)*) } } |
1213 | fn foo(bar:u32) { let a = id!(ba<|>r); } | 1207 | fn foo(bar:u32) { let a = id!(ba$0r); } |
1214 | "#, | 1208 | "#, |
1215 | expect![[r#" | 1209 | expect![[r#" |
1216 | *bar* | 1210 | *bar* |
@@ -1229,7 +1223,7 @@ fn foo(bar:u32) { let a = id!(ba<|>r); } | |||
1229 | macro_rules! id_deep { ($($tt:tt)*) => { $($tt)* } } | 1223 | macro_rules! id_deep { ($($tt:tt)*) => { $($tt)* } } |
1230 | macro_rules! id { ($($tt:tt)*) => { id_deep!($($tt)*) } } | 1224 | macro_rules! id { ($($tt:tt)*) => { id_deep!($($tt)*) } } |
1231 | fn bar() -> u32 { 0 } | 1225 | fn bar() -> u32 { 0 } |
1232 | fn foo() { let a = id!([0u32, bar(<|>)] ); } | 1226 | fn foo() { let a = id!([0u32, bar($0)] ); } |
1233 | "#, | 1227 | "#, |
1234 | expect![[r#" | 1228 | expect![[r#" |
1235 | *bar()* | 1229 | *bar()* |
@@ -1247,7 +1241,7 @@ fn foo() { let a = id!([0u32, bar(<|>)] ); } | |||
1247 | macro_rules! arr { ($($tt:tt)*) => { [$($tt)*)] } } | 1241 | macro_rules! arr { ($($tt:tt)*) => { [$($tt)*)] } } |
1248 | fn foo() { | 1242 | fn foo() { |
1249 | let mastered_for_itunes = ""; | 1243 | let mastered_for_itunes = ""; |
1250 | let _ = arr!("Tr<|>acks", &mastered_for_itunes); | 1244 | let _ = arr!("Tr$0acks", &mastered_for_itunes); |
1251 | } | 1245 | } |
1252 | "#, | 1246 | "#, |
1253 | expect![[r#" | 1247 | expect![[r#" |
@@ -1268,7 +1262,7 @@ macro_rules! assert {} | |||
1268 | 1262 | ||
1269 | fn bar() -> bool { true } | 1263 | fn bar() -> bool { true } |
1270 | fn foo() { | 1264 | fn foo() { |
1271 | assert!(ba<|>r()); | 1265 | assert!(ba$0r()); |
1272 | } | 1266 | } |
1273 | "#, | 1267 | "#, |
1274 | expect![[r#" | 1268 | expect![[r#" |
@@ -1293,7 +1287,7 @@ fn foo() { | |||
1293 | macro_rules! format {} | 1287 | macro_rules! format {} |
1294 | 1288 | ||
1295 | fn foo() { | 1289 | fn foo() { |
1296 | format!("hel<|>lo {}", 0); | 1290 | format!("hel$0lo {}", 0); |
1297 | } | 1291 | } |
1298 | "#, | 1292 | "#, |
1299 | ); | 1293 | ); |
@@ -1306,7 +1300,7 @@ fn foo() { | |||
1306 | /// <- `\u{3000}` here | 1300 | /// <- `\u{3000}` here |
1307 | fn foo() { } | 1301 | fn foo() { } |
1308 | 1302 | ||
1309 | fn bar() { fo<|>o(); } | 1303 | fn bar() { fo$0o(); } |
1310 | ", | 1304 | ", |
1311 | expect![[r#" | 1305 | expect![[r#" |
1312 | *foo* | 1306 | *foo* |
@@ -1329,7 +1323,7 @@ fn bar() { fo<|>o(); } | |||
1329 | #[test] | 1323 | #[test] |
1330 | fn test_hover_function_show_qualifiers() { | 1324 | fn test_hover_function_show_qualifiers() { |
1331 | check( | 1325 | check( |
1332 | r#"async fn foo<|>() {}"#, | 1326 | r#"async fn foo$0() {}"#, |
1333 | expect![[r#" | 1327 | expect![[r#" |
1334 | *foo* | 1328 | *foo* |
1335 | 1329 | ||
@@ -1343,7 +1337,7 @@ fn bar() { fo<|>o(); } | |||
1343 | "#]], | 1337 | "#]], |
1344 | ); | 1338 | ); |
1345 | check( | 1339 | check( |
1346 | r#"pub const unsafe fn foo<|>() {}"#, | 1340 | r#"pub const unsafe fn foo$0() {}"#, |
1347 | expect![[r#" | 1341 | expect![[r#" |
1348 | *foo* | 1342 | *foo* |
1349 | 1343 | ||
@@ -1357,7 +1351,7 @@ fn bar() { fo<|>o(); } | |||
1357 | "#]], | 1351 | "#]], |
1358 | ); | 1352 | ); |
1359 | check( | 1353 | check( |
1360 | r#"pub(crate) async unsafe extern "C" fn foo<|>() {}"#, | 1354 | r#"pub(crate) async unsafe extern "C" fn foo$0() {}"#, |
1361 | expect![[r#" | 1355 | expect![[r#" |
1362 | *foo* | 1356 | *foo* |
1363 | 1357 | ||
@@ -1375,7 +1369,7 @@ fn bar() { fo<|>o(); } | |||
1375 | #[test] | 1369 | #[test] |
1376 | fn test_hover_trait_show_qualifiers() { | 1370 | fn test_hover_trait_show_qualifiers() { |
1377 | check_actions( | 1371 | check_actions( |
1378 | r"unsafe trait foo<|>() {}", | 1372 | r"unsafe trait foo$0() {}", |
1379 | expect![[r#" | 1373 | expect![[r#" |
1380 | [ | 1374 | [ |
1381 | Implementation( | 1375 | Implementation( |
@@ -1396,7 +1390,7 @@ fn bar() { fo<|>o(); } | |||
1396 | check( | 1390 | check( |
1397 | r#" | 1391 | r#" |
1398 | //- /main.rs crate:main deps:std | 1392 | //- /main.rs crate:main deps:std |
1399 | extern crate st<|>d; | 1393 | extern crate st$0d; |
1400 | //- /std/lib.rs crate:std | 1394 | //- /std/lib.rs crate:std |
1401 | //! Standard library for this test | 1395 | //! Standard library for this test |
1402 | //! | 1396 | //! |
@@ -1414,7 +1408,7 @@ extern crate st<|>d; | |||
1414 | check( | 1408 | check( |
1415 | r#" | 1409 | r#" |
1416 | //- /main.rs crate:main deps:std | 1410 | //- /main.rs crate:main deps:std |
1417 | extern crate std as ab<|>c; | 1411 | extern crate std as ab$0c; |
1418 | //- /std/lib.rs crate:std | 1412 | //- /std/lib.rs crate:std |
1419 | //! Standard library for this test | 1413 | //! Standard library for this test |
1420 | //! | 1414 | //! |
@@ -1435,7 +1429,7 @@ extern crate std as ab<|>c; | |||
1435 | fn test_hover_mod_with_same_name_as_function() { | 1429 | fn test_hover_mod_with_same_name_as_function() { |
1436 | check( | 1430 | check( |
1437 | r#" | 1431 | r#" |
1438 | use self::m<|>y::Bar; | 1432 | use self::m$0y::Bar; |
1439 | mod my { pub struct Bar; } | 1433 | mod my { pub struct Bar; } |
1440 | 1434 | ||
1441 | fn my() {} | 1435 | fn my() {} |
@@ -1461,7 +1455,7 @@ fn my() {} | |||
1461 | /// bar docs | 1455 | /// bar docs |
1462 | struct Bar; | 1456 | struct Bar; |
1463 | 1457 | ||
1464 | fn foo() { let bar = Ba<|>r; } | 1458 | fn foo() { let bar = Ba$0r; } |
1465 | "#, | 1459 | "#, |
1466 | expect![[r#" | 1460 | expect![[r#" |
1467 | *Bar* | 1461 | *Bar* |
@@ -1488,7 +1482,7 @@ fn foo() { let bar = Ba<|>r; } | |||
1488 | #[doc = "bar docs"] | 1482 | #[doc = "bar docs"] |
1489 | struct Bar; | 1483 | struct Bar; |
1490 | 1484 | ||
1491 | fn foo() { let bar = Ba<|>r; } | 1485 | fn foo() { let bar = Ba$0r; } |
1492 | "#, | 1486 | "#, |
1493 | expect![[r#" | 1487 | expect![[r#" |
1494 | *Bar* | 1488 | *Bar* |
@@ -1517,7 +1511,7 @@ fn foo() { let bar = Ba<|>r; } | |||
1517 | #[doc = "bar docs 2"] | 1511 | #[doc = "bar docs 2"] |
1518 | struct Bar; | 1512 | struct Bar; |
1519 | 1513 | ||
1520 | fn foo() { let bar = Ba<|>r; } | 1514 | fn foo() { let bar = Ba$0r; } |
1521 | "#, | 1515 | "#, |
1522 | expect | 1541 | /// [Foo](struct.Foo.html) |
1548 | pub struct B<|>ar | 1542 | pub struct B$0ar |
1549 | "#, | 1543 | "#, |
1550 | expect | 1567 | /// [struct Foo](struct.Foo.html) |
1574 | pub struct B<|>ar | 1568 | pub struct B$0ar |
1575 | "#, | 1569 | "#, |
1576 | expect | 1595 | /// [Foo](struct.Foo.html) |
1602 | fie<|>ld: () | 1596 | fie$0ld: () |
1603 | } | 1597 | } |
1604 | "#, | 1598 | "#, |
1605 | expect | 1624 | /// [Foo](foo::Foo) |
1631 | pub struct B<|>ar | 1625 | pub struct B$0ar |
1632 | "#, | 1626 | "#, |
1633 | expect | 1654 | /// [Foo](foo::Foo) |
1661 | pub struct B<|>ar | 1655 | pub struct B$0ar |
1662 | "#, | 1656 | "#, |
1663 | expect![[r#" | 1657 | expect![[r#" |
1664 | *Bar* | 1658 | *Bar* |
@@ -1684,7 +1678,7 @@ pub struct B<|>ar | |||
1684 | r#" | 1678 | r#" |
1685 | pub struct Foo; | 1679 | pub struct Foo; |
1686 | /// [Foo] | 1680 | /// [Foo] |
1687 | pub struct B<|>ar | 1681 | pub struct B$0ar |
1688 | "#, | 1682 | "#, |
1689 | expect![[r#" | 1683 | expect![[r#" |
1690 | *Bar* | 1684 | *Bar* |
@@ -1710,7 +1704,7 @@ pub struct B<|>ar | |||
1710 | r#" | 1704 | r#" |
1711 | pub struct Foo; | 1705 | pub struct Foo; |
1712 | /// [`Foo`] | 1706 | /// [`Foo`] |
1713 | pub struct B<|>ar | 1707 | pub struct B$0ar |
1714 | "#, | 1708 | "#, |
1715 | expect![[r#" | 1709 | expect![[r#" |
1716 | *Bar* | 1710 | *Bar* |
@@ -1737,7 +1731,7 @@ pub struct B<|>ar | |||
1737 | pub struct Foo; | 1731 | pub struct Foo; |
1738 | fn Foo() {} | 1732 | fn Foo() {} |
1739 | /// [Foo()] | 1733 | /// [Foo()] |
1740 | pub struct B<|>ar | 1734 | pub struct B$0ar |
1741 | "#, | 1735 | "#, |
1742 | expect![[r#" | 1736 | expect![[r#" |
1743 | *Bar* | 1737 | *Bar* |
@@ -1763,7 +1757,7 @@ pub struct B<|>ar | |||
1763 | r#" | 1757 | r#" |
1764 | pub struct Foo; | 1758 | pub struct Foo; |
1765 | /// [`struct Foo`] | 1759 | /// [`struct Foo`] |
1766 | pub struct B<|>ar | 1760 | pub struct B$0ar |
1767 | "#, | 1761 | "#, |
1768 | expect![[r#" | 1762 | expect![[r#" |
1769 | *Bar* | 1763 | *Bar* |
@@ -1789,7 +1783,7 @@ pub struct B<|>ar | |||
1789 | r#" | 1783 | r#" |
1790 | pub struct Foo; | 1784 | pub struct Foo; |
1791 | /// [`struct@Foo`] | 1785 | /// [`struct@Foo`] |
1792 | pub struct B<|>ar | 1786 | pub struct B$0ar |
1793 | "#, | 1787 | "#, |
1794 | expect![[r#" | 1788 | expect![[r#" |
1795 | *Bar* | 1789 | *Bar* |
@@ -1817,7 +1811,7 @@ pub struct Foo; | |||
1817 | /// [my Foo][foo] | 1811 | /// [my Foo][foo] |
1818 | /// | 1812 | /// |
1819 | /// [foo]: Foo | 1813 | /// [foo]: Foo |
1820 | pub struct B<|>ar | 1814 | pub struct B$0ar |
1821 | "#, | 1815 | "#, |
1822 | expect | 1839 | /// [external](https://www.google.com) |
1846 | pub struct B<|>ar | 1840 | pub struct B$0ar |
1847 | "#, | 1841 | "#, |
1848 | expect | 1866 | /// [baz](Baz) |
1873 | pub struct B<|>ar | 1867 | pub struct B$0ar |
1874 | "#, | 1868 | "#, |
1875 | expect![[r#" | 1869 | expect![[r#" |
1876 | *Bar* | 1870 | *Bar* |
@@ -1896,7 +1890,7 @@ pub struct B<|>ar | |||
1896 | r#" | 1890 | r#" |
1897 | enum E { | 1891 | enum E { |
1898 | /// [E] | 1892 | /// [E] |
1899 | V<|> { field: i32 } | 1893 | V$0 { field: i32 } |
1900 | } | 1894 | } |
1901 | "#, | 1895 | "#, |
1902 | expect![[r#" | 1896 | expect![[r#" |
@@ -1923,7 +1917,7 @@ enum E { | |||
1923 | r#" | 1917 | r#" |
1924 | struct S { | 1918 | struct S { |
1925 | /// [`S`] | 1919 | /// [`S`] |
1926 | field<|>: i32 | 1920 | field$0: i32 |
1927 | } | 1921 | } |
1928 | "#, | 1922 | "#, |
1929 | expect | 1947 | /// case 2. inline URL with title: [example](https://www.example.com/) |
1954 | /// case 3. code refrence: [`Result`] | 1948 | /// case 3. code reference: [`Result`] |
1955 | /// case 4. code refrence but miss footnote: [`String`] | 1949 | /// case 4. code reference but miss footnote: [`String`] |
1956 | /// case 5. autolink: <http://www.example.com/> | 1950 | /// case 5. autolink: <http://www.example.com/> |
1957 | /// case 6. email address: <[email protected]> | 1951 | /// case 6. email address: <[email protected]> |
1958 | /// case 7. refrence: [example][example] | 1952 | /// case 7. reference: [example][example] |
1959 | /// case 8. collapsed link: [example][] | 1953 | /// case 8. collapsed link: [example][] |
1960 | /// case 9. shortcut link: [example] | 1954 | /// case 9. shortcut link: [example] |
1961 | /// case 10. inline without URL: [example]() | 1955 | /// case 10. inline without URL: [example]() |
1962 | /// case 11. refrence: [foo][foo] | 1956 | /// case 11. reference: [foo][foo] |
1963 | /// case 12. refrence: [foo][bar] | 1957 | /// case 12. reference: [foo][bar] |
1964 | /// case 13. collapsed link: [foo][] | 1958 | /// case 13. collapsed link: [foo][] |
1965 | /// case 14. shortcut link: [foo] | 1959 | /// case 14. shortcut link: [foo] |
1966 | /// case 15. inline without URL: [foo]() | 1960 | /// case 15. inline without URL: [foo]() |
@@ -1969,7 +1963,7 @@ struct S { | |||
1969 | /// | 1963 | /// |
1970 | /// [`Result`]: ../../std/result/enum.Result.html | 1964 | /// [`Result`]: ../../std/result/enum.Result.html |
1971 | /// [^example]: https://www.example.com/ | 1965 | /// [^example]: https://www.example.com/ |
1972 | pub fn fo<|>o() {} | 1966 | pub fn fo$0o() {} |
1973 | "#, | 1967 | "#, |
1974 | expect | 1983 | case 2. inline URL with title: [example](https://www.example.com/) |
1990 | case 3. code refrence: `Result` | 1984 | case 3. code reference: `Result` |
1991 | case 4. code refrence but miss footnote: `String` | 1985 | case 4. code reference but miss footnote: `String` |
1992 | case 5. autolink: http://www.example.com/ | 1986 | case 5. autolink: http://www.example.com/ |
1993 | case 6. email address: [email protected] | 1987 | case 6. email address: [email protected] |
1994 | case 7. refrence: example | 1988 | case 7. reference: example |
1995 | case 8. collapsed link: example | 1989 | case 8. collapsed link: example |
1996 | case 9. shortcut link: example | 1990 | case 9. shortcut link: example |
1997 | case 10. inline without URL: example | 1991 | case 10. inline without URL: example |
1998 | case 11. refrence: foo | 1992 | case 11. reference: foo |
1999 | case 12. refrence: foo | 1993 | case 12. reference: foo |
2000 | case 13. collapsed link: foo | 1994 | case 13. collapsed link: foo |
2001 | case 14. shortcut link: foo | 1995 | case 14. shortcut link: foo |
2002 | case 15. inline without URL: foo | 1996 | case 15. inline without URL: foo |
@@ -2026,7 +2020,7 @@ macro_rules! bar { | |||
2026 | 2020 | ||
2027 | bar!(); | 2021 | bar!(); |
2028 | 2022 | ||
2029 | fn foo() { let bar = Bar; bar.fo<|>o(); } | 2023 | fn foo() { let bar = Bar; bar.fo$0o(); } |
2030 | "#, | 2024 | "#, |
2031 | expect![[r#" | 2025 | expect![[r#" |
2032 | *foo* | 2026 | *foo* |
@@ -2064,7 +2058,7 @@ macro_rules! bar { | |||
2064 | 2058 | ||
2065 | bar!(); | 2059 | bar!(); |
2066 | 2060 | ||
2067 | fn foo() { let bar = Bar; bar.fo<|>o(); } | 2061 | fn foo() { let bar = Bar; bar.fo$0o(); } |
2068 | "#, | 2062 | "#, |
2069 | expect![[r#" | 2063 | expect![[r#" |
2070 | *foo* | 2064 | *foo* |
@@ -2087,7 +2081,7 @@ fn foo() { let bar = Bar; bar.fo<|>o(); } | |||
2087 | #[test] | 2081 | #[test] |
2088 | fn test_hover_trait_has_impl_action() { | 2082 | fn test_hover_trait_has_impl_action() { |
2089 | check_actions( | 2083 | check_actions( |
2090 | r#"trait foo<|>() {}"#, | 2084 | r#"trait foo$0() {}"#, |
2091 | expect![[r#" | 2085 | expect![[r#" |
2092 | [ | 2086 | [ |
2093 | Implementation( | 2087 | Implementation( |
@@ -2106,7 +2100,7 @@ fn foo() { let bar = Bar; bar.fo<|>o(); } | |||
2106 | #[test] | 2100 | #[test] |
2107 | fn test_hover_struct_has_impl_action() { | 2101 | fn test_hover_struct_has_impl_action() { |
2108 | check_actions( | 2102 | check_actions( |
2109 | r"struct foo<|>() {}", | 2103 | r"struct foo$0() {}", |
2110 | expect![[r#" | 2104 | expect![[r#" |
2111 | [ | 2105 | [ |
2112 | Implementation( | 2106 | Implementation( |
@@ -2125,7 +2119,7 @@ fn foo() { let bar = Bar; bar.fo<|>o(); } | |||
2125 | #[test] | 2119 | #[test] |
2126 | fn test_hover_union_has_impl_action() { | 2120 | fn test_hover_union_has_impl_action() { |
2127 | check_actions( | 2121 | check_actions( |
2128 | r#"union foo<|>() {}"#, | 2122 | r#"union foo$0() {}"#, |
2129 | expect![[r#" | 2123 | expect![[r#" |
2130 | [ | 2124 | [ |
2131 | Implementation( | 2125 | Implementation( |
@@ -2144,7 +2138,7 @@ fn foo() { let bar = Bar; bar.fo<|>o(); } | |||
2144 | #[test] | 2138 | #[test] |
2145 | fn test_hover_enum_has_impl_action() { | 2139 | fn test_hover_enum_has_impl_action() { |
2146 | check_actions( | 2140 | check_actions( |
2147 | r"enum foo<|>() { A, B }", | 2141 | r"enum foo$0() { A, B }", |
2148 | expect![[r#" | 2142 | expect![[r#" |
2149 | [ | 2143 | [ |
2150 | Implementation( | 2144 | Implementation( |
@@ -2163,7 +2157,7 @@ fn foo() { let bar = Bar; bar.fo<|>o(); } | |||
2163 | #[test] | 2157 | #[test] |
2164 | fn test_hover_self_has_impl_action() { | 2158 | fn test_hover_self_has_impl_action() { |
2165 | check_actions( | 2159 | check_actions( |
2166 | r#"struct foo where Self<|>:;"#, | 2160 | r#"struct foo where Self$0:;"#, |
2167 | expect![[r#" | 2161 | expect![[r#" |
2168 | [ | 2162 | [ |
2169 | Implementation( | 2163 | Implementation( |
@@ -2184,7 +2178,7 @@ fn foo() { let bar = Bar; bar.fo<|>o(); } | |||
2184 | check_actions( | 2178 | check_actions( |
2185 | r#" | 2179 | r#" |
2186 | #[test] | 2180 | #[test] |
2187 | fn foo_<|>test() {} | 2181 | fn foo_$0test() {} |
2188 | "#, | 2182 | "#, |
2189 | expect![[r#" | 2183 | expect![[r#" |
2190 | [ | 2184 | [ |
@@ -2219,7 +2213,7 @@ fn foo_<|>test() {} | |||
2219 | fn test_hover_test_mod_has_action() { | 2213 | fn test_hover_test_mod_has_action() { |
2220 | check_actions( | 2214 | check_actions( |
2221 | r#" | 2215 | r#" |
2222 | mod tests<|> { | 2216 | mod tests$0 { |
2223 | #[test] | 2217 | #[test] |
2224 | fn foo_test() {} | 2218 | fn foo_test() {} |
2225 | } | 2219 | } |
@@ -2254,7 +2248,7 @@ mod tests<|> { | |||
2254 | r#" | 2248 | r#" |
2255 | struct S{ f1: u32 } | 2249 | struct S{ f1: u32 } |
2256 | 2250 | ||
2257 | fn main() { let s<|>t = S{ f1:0 }; } | 2251 | fn main() { let s$0t = S{ f1:0 }; } |
2258 | "#, | 2252 | "#, |
2259 | expect![[r#" | 2253 | expect![[r#" |
2260 | [ | 2254 | [ |
@@ -2287,7 +2281,7 @@ fn main() { let s<|>t = S{ f1:0 }; } | |||
2287 | struct Arg(u32); | 2281 | struct Arg(u32); |
2288 | struct S<T>{ f1: T } | 2282 | struct S<T>{ f1: T } |
2289 | 2283 | ||
2290 | fn main() { let s<|>t = S{ f1:Arg(0) }; } | 2284 | fn main() { let s$0t = S{ f1:Arg(0) }; } |
2291 | "#, | 2285 | "#, |
2292 | expect![[r#" | 2286 | expect![[r#" |
2293 | [ | 2287 | [ |
@@ -2333,7 +2327,7 @@ fn main() { let s<|>t = S{ f1:Arg(0) }; } | |||
2333 | struct Arg(u32); | 2327 | struct Arg(u32); |
2334 | struct S<T>{ f1: T } | 2328 | struct S<T>{ f1: T } |
2335 | 2329 | ||
2336 | fn main() { let s<|>t = S{ f1: S{ f1: Arg(0) } }; } | 2330 | fn main() { let s$0t = S{ f1: S{ f1: Arg(0) } }; } |
2337 | "#, | 2331 | "#, |
2338 | expect![[r#" | 2332 | expect![[r#" |
2339 | [ | 2333 | [ |
@@ -2382,7 +2376,7 @@ mod M { | |||
2382 | pub struct C(u32); | 2376 | pub struct C(u32); |
2383 | } | 2377 | } |
2384 | 2378 | ||
2385 | fn main() { let s<|>t = (A(1), B(2), M::C(3) ); } | 2379 | fn main() { let s$0t = (A(1), B(2), M::C(3) ); } |
2386 | "#, | 2380 | "#, |
2387 | expect![[r#" | 2381 | expect![[r#" |
2388 | [ | 2382 | [ |
@@ -2441,7 +2435,7 @@ fn main() { let s<|>t = (A(1), B(2), M::C(3) ); } | |||
2441 | trait Foo {} | 2435 | trait Foo {} |
2442 | fn foo() -> impl Foo {} | 2436 | fn foo() -> impl Foo {} |
2443 | 2437 | ||
2444 | fn main() { let s<|>t = foo(); } | 2438 | fn main() { let s$0t = foo(); } |
2445 | "#, | 2439 | "#, |
2446 | expect![[r#" | 2440 | expect![[r#" |
2447 | [ | 2441 | [ |
@@ -2475,7 +2469,7 @@ trait Foo<T> {} | |||
2475 | struct S; | 2469 | struct S; |
2476 | fn foo() -> impl Foo<S> {} | 2470 | fn foo() -> impl Foo<S> {} |
2477 | 2471 | ||
2478 | fn main() { let s<|>t = foo(); } | 2472 | fn main() { let s$0t = foo(); } |
2479 | "#, | 2473 | "#, |
2480 | expect![[r#" | 2474 | expect![[r#" |
2481 | [ | 2475 | [ |
@@ -2522,7 +2516,7 @@ trait Foo {} | |||
2522 | trait Bar {} | 2516 | trait Bar {} |
2523 | fn foo() -> impl Foo + Bar {} | 2517 | fn foo() -> impl Foo + Bar {} |
2524 | 2518 | ||
2525 | fn main() { let s<|>t = foo(); } | 2519 | fn main() { let s$0t = foo(); } |
2526 | "#, | 2520 | "#, |
2527 | expect![[r#" | 2521 | expect![[r#" |
2528 | [ | 2522 | [ |
@@ -2572,7 +2566,7 @@ struct S2 {} | |||
2572 | 2566 | ||
2573 | fn foo() -> impl Foo<S1> + Bar<S2> {} | 2567 | fn foo() -> impl Foo<S1> + Bar<S2> {} |
2574 | 2568 | ||
2575 | fn main() { let s<|>t = foo(); } | 2569 | fn main() { let s$0t = foo(); } |
2576 | "#, | 2570 | "#, |
2577 | expect![[r#" | 2571 | expect![[r#" |
2578 | [ | 2572 | [ |
@@ -2642,7 +2636,7 @@ fn main() { let s<|>t = foo(); } | |||
2642 | check_actions( | 2636 | check_actions( |
2643 | r#" | 2637 | r#" |
2644 | trait Foo {} | 2638 | trait Foo {} |
2645 | fn foo(ar<|>g: &impl Foo) {} | 2639 | fn foo(ar$0g: &impl Foo) {} |
2646 | "#, | 2640 | "#, |
2647 | expect![[r#" | 2641 | expect![[r#" |
2648 | [ | 2642 | [ |
@@ -2676,7 +2670,7 @@ trait Foo {} | |||
2676 | trait Bar<T> {} | 2670 | trait Bar<T> {} |
2677 | struct S{} | 2671 | struct S{} |
2678 | 2672 | ||
2679 | fn foo(ar<|>g: &impl Foo + Bar<S>) {} | 2673 | fn foo(ar$0g: &impl Foo + Bar<S>) {} |
2680 | "#, | 2674 | "#, |
2681 | expect![[r#" | 2675 | expect![[r#" |
2682 | [ | 2676 | [ |
@@ -2734,7 +2728,7 @@ fn foo(ar<|>g: &impl Foo + Bar<S>) {} | |||
2734 | r#" | 2728 | r#" |
2735 | struct S; | 2729 | struct S; |
2736 | fn foo() { | 2730 | fn foo() { |
2737 | let fo<|>o = async { S }; | 2731 | let fo$0o = async { S }; |
2738 | } | 2732 | } |
2739 | 2733 | ||
2740 | #[prelude_import] use future::*; | 2734 | #[prelude_import] use future::*; |
@@ -2786,7 +2780,7 @@ mod future { | |||
2786 | r#" | 2780 | r#" |
2787 | trait Foo<T> {} | 2781 | trait Foo<T> {} |
2788 | struct S {} | 2782 | struct S {} |
2789 | fn foo(ar<|>g: &impl Foo<S>) {} | 2783 | fn foo(ar$0g: &impl Foo<S>) {} |
2790 | "#, | 2784 | "#, |
2791 | expect![[r#" | 2785 | expect![[r#" |
2792 | [ | 2786 | [ |
@@ -2836,7 +2830,7 @@ impl Foo for S {} | |||
2836 | struct B<T>{} | 2830 | struct B<T>{} |
2837 | fn foo() -> B<dyn Foo> {} | 2831 | fn foo() -> B<dyn Foo> {} |
2838 | 2832 | ||
2839 | fn main() { let s<|>t = foo(); } | 2833 | fn main() { let s$0t = foo(); } |
2840 | "#, | 2834 | "#, |
2841 | expect![[r#" | 2835 | expect![[r#" |
2842 | [ | 2836 | [ |
@@ -2880,7 +2874,7 @@ fn main() { let s<|>t = foo(); } | |||
2880 | check_actions( | 2874 | check_actions( |
2881 | r#" | 2875 | r#" |
2882 | trait Foo {} | 2876 | trait Foo {} |
2883 | fn foo(ar<|>g: &dyn Foo) {} | 2877 | fn foo(ar$0g: &dyn Foo) {} |
2884 | "#, | 2878 | "#, |
2885 | expect![[r#" | 2879 | expect![[r#" |
2886 | [ | 2880 | [ |
@@ -2912,7 +2906,7 @@ fn foo(ar<|>g: &dyn Foo) {} | |||
2912 | r#" | 2906 | r#" |
2913 | trait Foo<T> {} | 2907 | trait Foo<T> {} |
2914 | struct S {} | 2908 | struct S {} |
2915 | fn foo(ar<|>g: &dyn Foo<S>) {} | 2909 | fn foo(ar$0g: &dyn Foo<S>) {} |
2916 | "#, | 2910 | "#, |
2917 | expect![[r#" | 2911 | expect![[r#" |
2918 | [ | 2912 | [ |
@@ -2960,7 +2954,7 @@ trait DynTrait<T> {} | |||
2960 | struct B<T> {} | 2954 | struct B<T> {} |
2961 | struct S {} | 2955 | struct S {} |
2962 | 2956 | ||
2963 | fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {} | 2957 | fn foo(a$0rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {} |
2964 | "#, | 2958 | "#, |
2965 | expect![[r#" | 2959 | expect![[r#" |
2966 | [ | 2960 | [ |
@@ -3041,7 +3035,7 @@ impl Foo for S { type Item = Bar; } | |||
3041 | 3035 | ||
3042 | fn test() -> impl Foo { S {} } | 3036 | fn test() -> impl Foo { S {} } |
3043 | 3037 | ||
3044 | fn main() { let s<|>t = test().get(); } | 3038 | fn main() { let s$0t = test().get(); } |
3045 | "#, | 3039 | "#, |
3046 | expect![[r#" | 3040 | expect![[r#" |
3047 | [ | 3041 | [ |
@@ -3074,7 +3068,7 @@ fn main() { let s<|>t = test().get(); } | |||
3074 | struct Bar; | 3068 | struct Bar; |
3075 | struct Foo<const BAR: Bar>; | 3069 | struct Foo<const BAR: Bar>; |
3076 | 3070 | ||
3077 | impl<const BAR: Bar> Foo<BAR<|>> {} | 3071 | impl<const BAR: Bar> Foo<BAR$0> {} |
3078 | "#, | 3072 | "#, |
3079 | expect![[r#" | 3073 | expect![[r#" |
3080 | [ | 3074 | [ |
@@ -3106,7 +3100,7 @@ impl<const BAR: Bar> Foo<BAR<|>> {} | |||
3106 | r#" | 3100 | r#" |
3107 | trait Foo {} | 3101 | trait Foo {} |
3108 | 3102 | ||
3109 | fn foo<T: Foo>(t: T<|>){} | 3103 | fn foo<T: Foo>(t: T$0){} |
3110 | "#, | 3104 | "#, |
3111 | expect![[r#" | 3105 | expect![[r#" |
3112 | [ | 3106 | [ |
@@ -3133,6 +3127,39 @@ fn foo<T: Foo>(t: T<|>){} | |||
3133 | } | 3127 | } |
3134 | 3128 | ||
3135 | #[test] | 3129 | #[test] |
3130 | fn test_hover_self_has_go_to_type() { | ||
3131 | check_actions( | ||
3132 | r#" | ||
3133 | struct Foo; | ||
3134 | impl Foo { | ||
3135 | fn foo(&self$0) {} | ||
3136 | } | ||
3137 | "#, | ||
3138 | expect![[r#" | ||
3139 | [ | ||
3140 | GoToType( | ||
3141 | [ | ||
3142 | HoverGotoTypeData { | ||
3143 | mod_path: "test::Foo", | ||
3144 | nav: NavigationTarget { | ||
3145 | file_id: FileId( | ||
3146 | 0, | ||
3147 | ), | ||
3148 | full_range: 0..11, | ||
3149 | focus_range: 7..10, | ||
3150 | name: "Foo", | ||
3151 | kind: Struct, | ||
3152 | description: "struct Foo", | ||
3153 | }, | ||
3154 | }, | ||
3155 | ], | ||
3156 | ), | ||
3157 | ] | ||
3158 | "#]], | ||
3159 | ); | ||
3160 | } | ||
3161 | |||
3162 | #[test] | ||
3136 | fn hover_displays_normalized_crate_names() { | 3163 | fn hover_displays_normalized_crate_names() { |
3137 | check( | 3164 | check( |
3138 | r#" | 3165 | r#" |
@@ -3146,7 +3173,7 @@ pub mod wrapper { | |||
3146 | } | 3173 | } |
3147 | 3174 | ||
3148 | //- /main.rs crate:main deps:name-with-dashes | 3175 | //- /main.rs crate:main deps:name-with-dashes |
3149 | fn main() { let foo_test = name_with_dashes::wrapper::Thing::new<|>(); } | 3176 | fn main() { let foo_test = name_with_dashes::wrapper::Thing::new$0(); } |
3150 | "#, | 3177 | "#, |
3151 | expect![[r#" | 3178 | expect![[r#" |
3152 | *new* | 3179 | *new* |
@@ -3172,7 +3199,7 @@ struct S { | |||
3172 | 3199 | ||
3173 | fn main() { | 3200 | fn main() { |
3174 | let s = S { f: 0 }; | 3201 | let s = S { f: 0 }; |
3175 | let S { f<|> } = &s; | 3202 | let S { f$0 } = &s; |
3176 | } | 3203 | } |
3177 | "#, | 3204 | "#, |
3178 | expect![[r#" | 3205 | expect![[r#" |
@@ -3191,11 +3218,12 @@ fn main() { | |||
3191 | r#" | 3218 | r#" |
3192 | struct Foo {} | 3219 | struct Foo {} |
3193 | impl Foo { | 3220 | impl Foo { |
3194 | fn bar(&sel<|>f) {} | 3221 | fn bar(&sel$0f) {} |
3195 | } | 3222 | } |
3196 | "#, | 3223 | "#, |
3197 | expect![[r#" | 3224 | expect![[r#" |
3198 | *&self* | 3225 | *self* |
3226 | |||
3199 | ```rust | 3227 | ```rust |
3200 | &Foo | 3228 | &Foo |
3201 | ``` | 3229 | ``` |
@@ -3210,11 +3238,12 @@ impl Foo { | |||
3210 | struct Arc<T>(T); | 3238 | struct Arc<T>(T); |
3211 | struct Foo {} | 3239 | struct Foo {} |
3212 | impl Foo { | 3240 | impl Foo { |
3213 | fn bar(sel<|>f: Arc<Foo>) {} | 3241 | fn bar(sel$0f: Arc<Foo>) {} |
3214 | } | 3242 | } |
3215 | "#, | 3243 | "#, |
3216 | expect![[r#" | 3244 | expect![[r#" |
3217 | *self: Arc<Foo>* | 3245 | *self* |
3246 | |||
3218 | ```rust | 3247 | ```rust |
3219 | Arc<Foo> | 3248 | Arc<Foo> |
3220 | ``` | 3249 | ``` |
@@ -3227,7 +3256,7 @@ impl Foo { | |||
3227 | check( | 3256 | check( |
3228 | r#" | 3257 | r#" |
3229 | /// Be quick; | 3258 | /// Be quick; |
3230 | mod Foo<|> { | 3259 | mod Foo$0 { |
3231 | //! time is mana | 3260 | //! time is mana |
3232 | 3261 | ||
3233 | /// This comment belongs to the function | 3262 | /// This comment belongs to the function |
@@ -3258,7 +3287,7 @@ mod Foo<|> { | |||
3258 | check( | 3287 | check( |
3259 | r#" | 3288 | r#" |
3260 | #[doc = "Be quick;"] | 3289 | #[doc = "Be quick;"] |
3261 | mod Foo<|> { | 3290 | mod Foo$0 { |
3262 | #![doc = "time is mana"] | 3291 | #![doc = "time is mana"] |
3263 | 3292 | ||
3264 | #[doc = "This comment belongs to the function"] | 3293 | #[doc = "This comment belongs to the function"] |
@@ -3289,7 +3318,7 @@ mod Foo<|> { | |||
3289 | check_hover_no_result( | 3318 | check_hover_no_result( |
3290 | r#" | 3319 | r#" |
3291 | fn no_hover() { | 3320 | fn no_hover() { |
3292 | // no<|>hover | 3321 | // no$0hover |
3293 | } | 3322 | } |
3294 | "#, | 3323 | "#, |
3295 | ); | 3324 | ); |
@@ -3300,7 +3329,7 @@ fn no_hover() { | |||
3300 | check( | 3329 | check( |
3301 | r#" | 3330 | r#" |
3302 | fn foo() { | 3331 | fn foo() { |
3303 | 'label<|>: loop {} | 3332 | 'label$0: loop {} |
3304 | } | 3333 | } |
3305 | "#, | 3334 | "#, |
3306 | expect![[r#" | 3335 | expect![[r#" |
@@ -3316,7 +3345,7 @@ fn foo() { | |||
3316 | #[test] | 3345 | #[test] |
3317 | fn hover_lifetime() { | 3346 | fn hover_lifetime() { |
3318 | check( | 3347 | check( |
3319 | r#"fn foo<'lifetime>(_: &'lifetime<|> ()) {}"#, | 3348 | r#"fn foo<'lifetime>(_: &'lifetime$0 ()) {}"#, |
3320 | expect![[r#" | 3349 | expect![[r#" |
3321 | *'lifetime* | 3350 | *'lifetime* |
3322 | 3351 | ||
@@ -3335,7 +3364,7 @@ struct Foo<T>(T); | |||
3335 | trait Copy {} | 3364 | trait Copy {} |
3336 | trait Clone {} | 3365 | trait Clone {} |
3337 | trait Sized {} | 3366 | trait Sized {} |
3338 | impl<T: Copy + Clone> Foo<T<|>> where T: Sized {} | 3367 | impl<T: Copy + Clone> Foo<T$0> where T: Sized {} |
3339 | "#, | 3368 | "#, |
3340 | expect![[r#" | 3369 | expect![[r#" |
3341 | *T* | 3370 | *T* |
@@ -3348,7 +3377,7 @@ impl<T: Copy + Clone> Foo<T<|>> where T: Sized {} | |||
3348 | check( | 3377 | check( |
3349 | r#" | 3378 | r#" |
3350 | struct Foo<T>(T); | 3379 | struct Foo<T>(T); |
3351 | impl<T> Foo<T<|>> {} | 3380 | impl<T> Foo<T$0> {} |
3352 | "#, | 3381 | "#, |
3353 | expect![[r#" | 3382 | expect![[r#" |
3354 | *T* | 3383 | *T* |
@@ -3362,7 +3391,7 @@ impl<T> Foo<T<|>> {} | |||
3362 | check( | 3391 | check( |
3363 | r#" | 3392 | r#" |
3364 | struct Foo<T>(T); | 3393 | struct Foo<T>(T); |
3365 | impl<T: 'static> Foo<T<|>> {} | 3394 | impl<T: 'static> Foo<T$0> {} |
3366 | "#, | 3395 | "#, |
3367 | expect![[r#" | 3396 | expect![[r#" |
3368 | *T* | 3397 | *T* |
@@ -3379,7 +3408,7 @@ impl<T: 'static> Foo<T<|>> {} | |||
3379 | check( | 3408 | check( |
3380 | r#" | 3409 | r#" |
3381 | struct Foo<const LEN: usize>; | 3410 | struct Foo<const LEN: usize>; |
3382 | impl<const LEN: usize> Foo<LEN<|>> {} | 3411 | impl<const LEN: usize> Foo<LEN$0> {} |
3383 | "#, | 3412 | "#, |
3384 | expect![[r#" | 3413 | expect![[r#" |
3385 | *LEN* | 3414 | *LEN* |