aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/hover.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide/src/hover.rs')
-rw-r--r--crates/ide/src/hover.rs313
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 @@
1use hir::{ 1use 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};
5use ide_db::base_db::SourceDatabase; 5use ide_db::base_db::SourceDatabase;
6use ide_db::{ 6use 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
186fn runnable_action( 178fn 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 {
457pub fn foo() -> u32 { 1 } 451pub fn foo() -> u32 { 1 }
458 452
459fn main() { 453fn 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() {
476pub fn foo() -> u32 { 1 } 470pub fn foo() -> u32 { 1 }
477 471
478fn main() { 472fn 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#"
527pub fn foo() -> u32 { 1 } 521pub fn foo() -> u32 { 1 }
528 522
529fn main() { let foo_test = fo<|>o(); } 523fn main() { let foo_test = fo$0o(); }
530"#, 524"#,
531 expect![[r#" 525 expect![[r#"
532 *foo* 526 *foo*
@@ -558,7 +552,7 @@ mod a;
558mod b; 552mod b;
559mod c; 553mod c;
560 554
561fn main() { let foo_test = fo<|>o(); } 555fn 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#"
576pub fn foo<'a, T: AsRef<str>>(b: &'a T) -> &'a str { } 570pub fn foo<'a, T: AsRef<str>>(b: &'a T) -> &'a str { }
577 571
578fn main() { let foo_test = fo<|>o(); } 572fn 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#"
598pub fn foo<|>(a: u32, b: u32) -> u32 {} 592pub fn foo$0(a: u32, b: u32) -> u32 {}
599 593
600fn main() { } 594fn 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/// ```
626pub fn foo<|>(_: &Path) {} 620pub fn foo$0(_: &Path) {}
627 621
628fn main() { } 622fn 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"#]
659pub fn foo<|>(_: &Path) {} 653pub fn foo$0(_: &Path) {}
660 654
661fn main() { } 655fn main() { }
662"##, 656"##,
@@ -686,7 +680,7 @@ fn main() { }
686struct Foo { field_a: u32 } 680struct Foo { field_a: u32 }
687 681
688fn main() { 682fn 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#"
708struct Foo { field_a<|>: u32 } 702struct Foo { field_a$0: u32 }
709 703
710fn main() { 704fn 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() {
764struct Test<K, T = u8> { k: K, t: T } 758struct Test<K, T = u8> { k: K, t: T }
765 759
766fn main() { 760fn 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() {
783enum Option<T> { Some(T) } 777enum Option<T> { Some(T) }
784use Option::Some; 778use Option::Some;
785 779
786fn main() { So<|>me(12); } 780fn 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); }
803enum Option<T> { Some(T) } 797enum Option<T> { Some(T) }
804use Option::Some; 798use Option::Some;
805 799
806fn main() { let b<|>ar = Some(12); } 800fn 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#"
822enum Option<T> { 816enum 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}
850fn main() { 844fn 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
958fn main() { let foo_<|>test = Thing::new(); } 952fn 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
982fn main() { let foo_test = wrapper::Thing::new<|>(); } 976fn 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
1007fn main() { 1001fn 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#"
1033struct Thing { x: u32 } 1027struct Thing { x: u32 }
1034impl Thing { 1028impl 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#"
1052struct Thing { x: u32 } 1046struct Thing { x: u32 }
1053impl Thing { 1047impl 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#"
1071enum Thing { A } 1065enum Thing { A }
1072impl Thing { 1066impl 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
1115fn y() { 1109fn 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#"
1134macro_rules! foo { () => {} } 1128macro_rules! foo { () => {} }
1135 1129
1136fn f() { fo<|>o!(); } 1130fn 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!(); }
1170macro_rules! id { ($($tt:tt)*) => { $($tt)* } } 1164macro_rules! id { ($($tt:tt)*) => { $($tt)* } }
1171fn foo() {} 1165fn foo() {}
1172id! { 1166id! {
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#"
1194macro_rules! id { ($($tt:tt)*) => { $($tt)* } } 1188macro_rules! id { ($($tt:tt)*) => { $($tt)* } }
1195fn foo(bar:u32) { let a = id!(ba<|>r); } 1189fn 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#"
1211macro_rules! id_deep { ($($tt:tt)*) => { $($tt)* } } 1205macro_rules! id_deep { ($($tt:tt)*) => { $($tt)* } }
1212macro_rules! id { ($($tt:tt)*) => { id_deep!($($tt)*) } } 1206macro_rules! id { ($($tt:tt)*) => { id_deep!($($tt)*) } }
1213fn foo(bar:u32) { let a = id!(ba<|>r); } 1207fn 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); }
1229macro_rules! id_deep { ($($tt:tt)*) => { $($tt)* } } 1223macro_rules! id_deep { ($($tt:tt)*) => { $($tt)* } }
1230macro_rules! id { ($($tt:tt)*) => { id_deep!($($tt)*) } } 1224macro_rules! id { ($($tt:tt)*) => { id_deep!($($tt)*) } }
1231fn bar() -> u32 { 0 } 1225fn bar() -> u32 { 0 }
1232fn foo() { let a = id!([0u32, bar(<|>)] ); } 1226fn 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(<|>)] ); }
1247macro_rules! arr { ($($tt:tt)*) => { [$($tt)*)] } } 1241macro_rules! arr { ($($tt:tt)*) => { [$($tt)*)] } }
1248fn foo() { 1242fn 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
1269fn bar() -> bool { true } 1263fn bar() -> bool { true }
1270fn foo() { 1264fn 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
1307fn foo() { } 1301fn foo() { }
1308 1302
1309fn bar() { fo<|>o(); } 1303fn 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
1399extern crate st<|>d; 1393extern 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
1417extern crate std as ab<|>c; 1411extern 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#"
1438use self::m<|>y::Bar; 1432use self::m$0y::Bar;
1439mod my { pub struct Bar; } 1433mod my { pub struct Bar; }
1440 1434
1441fn my() {} 1435fn my() {}
@@ -1461,7 +1455,7 @@ fn my() {}
1461/// bar docs 1455/// bar docs
1462struct Bar; 1456struct Bar;
1463 1457
1464fn foo() { let bar = Ba<|>r; } 1458fn 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"]
1489struct Bar; 1483struct Bar;
1490 1484
1491fn foo() { let bar = Ba<|>r; } 1485fn 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"]
1518struct Bar; 1512struct Bar;
1519 1513
1520fn foo() { let bar = Ba<|>r; } 1514fn foo() { let bar = Ba$0r; }
1521"#, 1515"#,
1522 expect![[r#" 1516 expect![[r#"
1523 *Bar* 1517 *Bar*
@@ -1545,7 +1539,7 @@ fn foo() { let bar = Ba<|>r; }
1545 r#" 1539 r#"
1546pub struct Foo; 1540pub struct Foo;
1547/// [Foo](struct.Foo.html) 1541/// [Foo](struct.Foo.html)
1548pub struct B<|>ar 1542pub struct B$0ar
1549"#, 1543"#,
1550 expect![[r#" 1544 expect![[r#"
1551 *Bar* 1545 *Bar*
@@ -1571,7 +1565,7 @@ pub struct B<|>ar
1571 r#" 1565 r#"
1572pub struct Foo; 1566pub struct Foo;
1573/// [struct Foo](struct.Foo.html) 1567/// [struct Foo](struct.Foo.html)
1574pub struct B<|>ar 1568pub struct B$0ar
1575"#, 1569"#,
1576 expect![[r#" 1570 expect![[r#"
1577 *Bar* 1571 *Bar*
@@ -1599,7 +1593,7 @@ pub struct B<|>ar
1599pub struct Foo; 1593pub struct Foo;
1600pub struct Bar { 1594pub struct Bar {
1601 /// [Foo](struct.Foo.html) 1595 /// [Foo](struct.Foo.html)
1602 fie<|>ld: () 1596 fie$0ld: ()
1603} 1597}
1604"#, 1598"#,
1605 expect![[r#" 1599 expect![[r#"
@@ -1628,7 +1622,7 @@ pub mod foo {
1628 pub struct Foo; 1622 pub struct Foo;
1629} 1623}
1630/// [Foo](foo::Foo) 1624/// [Foo](foo::Foo)
1631pub struct B<|>ar 1625pub struct B$0ar
1632"#, 1626"#,
1633 expect![[r#" 1627 expect![[r#"
1634 *Bar* 1628 *Bar*
@@ -1658,7 +1652,7 @@ pub mod foo {
1658 pub struct Foo; 1652 pub struct Foo;
1659} 1653}
1660/// [Foo](foo::Foo) 1654/// [Foo](foo::Foo)
1661pub struct B<|>ar 1655pub 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#"
1685pub struct Foo; 1679pub struct Foo;
1686/// [Foo] 1680/// [Foo]
1687pub struct B<|>ar 1681pub 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#"
1711pub struct Foo; 1705pub struct Foo;
1712/// [`Foo`] 1706/// [`Foo`]
1713pub struct B<|>ar 1707pub struct B$0ar
1714"#, 1708"#,
1715 expect![[r#" 1709 expect![[r#"
1716 *Bar* 1710 *Bar*
@@ -1737,7 +1731,7 @@ pub struct B<|>ar
1737pub struct Foo; 1731pub struct Foo;
1738fn Foo() {} 1732fn Foo() {}
1739/// [Foo()] 1733/// [Foo()]
1740pub struct B<|>ar 1734pub 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#"
1764pub struct Foo; 1758pub struct Foo;
1765/// [`struct Foo`] 1759/// [`struct Foo`]
1766pub struct B<|>ar 1760pub 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#"
1790pub struct Foo; 1784pub struct Foo;
1791/// [`struct@Foo`] 1785/// [`struct@Foo`]
1792pub struct B<|>ar 1786pub 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
1820pub struct B<|>ar 1814pub struct B$0ar
1821"#, 1815"#,
1822 expect![[r#" 1816 expect![[r#"
1823 *Bar* 1817 *Bar*
@@ -1843,7 +1837,7 @@ pub struct B<|>ar
1843 r#" 1837 r#"
1844pub struct Foo; 1838pub struct Foo;
1845/// [external](https://www.google.com) 1839/// [external](https://www.google.com)
1846pub struct B<|>ar 1840pub struct B$0ar
1847"#, 1841"#,
1848 expect![[r#" 1842 expect![[r#"
1849 *Bar* 1843 *Bar*
@@ -1870,7 +1864,7 @@ pub struct B<|>ar
1870 r#" 1864 r#"
1871pub struct Foo; 1865pub struct Foo;
1872/// [baz](Baz) 1866/// [baz](Baz)
1873pub struct B<|>ar 1867pub 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#"
1897enum E { 1891enum 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#"
1924struct S { 1918struct S {
1925 /// [`S`] 1919 /// [`S`]
1926 field<|>: i32 1920 field$0: i32
1927} 1921}
1928"#, 1922"#,
1929 expect![[r#" 1923 expect![[r#"
@@ -1951,16 +1945,16 @@ struct S {
1951/// Test cases: 1945/// Test cases:
1952/// case 1. bare URL: https://www.example.com/ 1946/// case 1. bare URL: https://www.example.com/
1953/// case 2. inline URL with title: [example](https://www.example.com/) 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/
1972pub fn fo<|>o() {} 1966pub fn fo$0o() {}
1973"#, 1967"#,
1974 expect![[r#" 1968 expect![[r#"
1975 *foo* 1969 *foo*
@@ -1987,16 +1981,16 @@ pub fn fo<|>o() {}
1987 Test cases: 1981 Test cases:
1988 case 1. bare URL: https://www.example.com/ 1982 case 1. bare URL: https://www.example.com/
1989 case 2. inline URL with title: [example](https://www.example.com/) 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
2027bar!(); 2021bar!();
2028 2022
2029fn foo() { let bar = Bar; bar.fo<|>o(); } 2023fn 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
2065bar!(); 2059bar!();
2066 2060
2067fn foo() { let bar = Bar; bar.fo<|>o(); } 2061fn 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]
2187fn foo_<|>test() {} 2181fn 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#"
2222mod tests<|> { 2216mod 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#"
2255struct S{ f1: u32 } 2249struct S{ f1: u32 }
2256 2250
2257fn main() { let s<|>t = S{ f1:0 }; } 2251fn 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 }; }
2287struct Arg(u32); 2281struct Arg(u32);
2288struct S<T>{ f1: T } 2282struct S<T>{ f1: T }
2289 2283
2290fn main() { let s<|>t = S{ f1:Arg(0) }; } 2284fn 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) }; }
2333struct Arg(u32); 2327struct Arg(u32);
2334struct S<T>{ f1: T } 2328struct S<T>{ f1: T }
2335 2329
2336fn main() { let s<|>t = S{ f1: S{ f1: Arg(0) } }; } 2330fn 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
2385fn main() { let s<|>t = (A(1), B(2), M::C(3) ); } 2379fn 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) ); }
2441trait Foo {} 2435trait Foo {}
2442fn foo() -> impl Foo {} 2436fn foo() -> impl Foo {}
2443 2437
2444fn main() { let s<|>t = foo(); } 2438fn main() { let s$0t = foo(); }
2445"#, 2439"#,
2446 expect![[r#" 2440 expect![[r#"
2447 [ 2441 [
@@ -2475,7 +2469,7 @@ trait Foo<T> {}
2475struct S; 2469struct S;
2476fn foo() -> impl Foo<S> {} 2470fn foo() -> impl Foo<S> {}
2477 2471
2478fn main() { let s<|>t = foo(); } 2472fn main() { let s$0t = foo(); }
2479"#, 2473"#,
2480 expect![[r#" 2474 expect![[r#"
2481 [ 2475 [
@@ -2522,7 +2516,7 @@ trait Foo {}
2522trait Bar {} 2516trait Bar {}
2523fn foo() -> impl Foo + Bar {} 2517fn foo() -> impl Foo + Bar {}
2524 2518
2525fn main() { let s<|>t = foo(); } 2519fn main() { let s$0t = foo(); }
2526 "#, 2520 "#,
2527 expect![[r#" 2521 expect![[r#"
2528 [ 2522 [
@@ -2572,7 +2566,7 @@ struct S2 {}
2572 2566
2573fn foo() -> impl Foo<S1> + Bar<S2> {} 2567fn foo() -> impl Foo<S1> + Bar<S2> {}
2574 2568
2575fn main() { let s<|>t = foo(); } 2569fn 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#"
2644trait Foo {} 2638trait Foo {}
2645fn foo(ar<|>g: &impl Foo) {} 2639fn foo(ar$0g: &impl Foo) {}
2646"#, 2640"#,
2647 expect![[r#" 2641 expect![[r#"
2648 [ 2642 [
@@ -2676,7 +2670,7 @@ trait Foo {}
2676trait Bar<T> {} 2670trait Bar<T> {}
2677struct S{} 2671struct S{}
2678 2672
2679fn foo(ar<|>g: &impl Foo + Bar<S>) {} 2673fn 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#"
2735struct S; 2729struct S;
2736fn foo() { 2730fn 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#"
2787trait Foo<T> {} 2781trait Foo<T> {}
2788struct S {} 2782struct S {}
2789fn foo(ar<|>g: &impl Foo<S>) {} 2783fn foo(ar$0g: &impl Foo<S>) {}
2790"#, 2784"#,
2791 expect![[r#" 2785 expect![[r#"
2792 [ 2786 [
@@ -2836,7 +2830,7 @@ impl Foo for S {}
2836struct B<T>{} 2830struct B<T>{}
2837fn foo() -> B<dyn Foo> {} 2831fn foo() -> B<dyn Foo> {}
2838 2832
2839fn main() { let s<|>t = foo(); } 2833fn 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#"
2882trait Foo {} 2876trait Foo {}
2883fn foo(ar<|>g: &dyn Foo) {} 2877fn 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#"
2913trait Foo<T> {} 2907trait Foo<T> {}
2914struct S {} 2908struct S {}
2915fn foo(ar<|>g: &dyn Foo<S>) {} 2909fn foo(ar$0g: &dyn Foo<S>) {}
2916"#, 2910"#,
2917 expect![[r#" 2911 expect![[r#"
2918 [ 2912 [
@@ -2960,7 +2954,7 @@ trait DynTrait<T> {}
2960struct B<T> {} 2954struct B<T> {}
2961struct S {} 2955struct S {}
2962 2956
2963fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {} 2957fn 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
3042fn test() -> impl Foo { S {} } 3036fn test() -> impl Foo { S {} }
3043 3037
3044fn main() { let s<|>t = test().get(); } 3038fn 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(); }
3074struct Bar; 3068struct Bar;
3075struct Foo<const BAR: Bar>; 3069struct Foo<const BAR: Bar>;
3076 3070
3077impl<const BAR: Bar> Foo<BAR<|>> {} 3071impl<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#"
3107trait Foo {} 3101trait Foo {}
3108 3102
3109fn foo<T: Foo>(t: T<|>){} 3103fn 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#"
3133struct Foo;
3134impl 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
3149fn main() { let foo_test = name_with_dashes::wrapper::Thing::new<|>(); } 3176fn 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
3173fn main() { 3200fn 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#"
3192struct Foo {} 3219struct Foo {}
3193impl Foo { 3220impl 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 {
3210struct Arc<T>(T); 3238struct Arc<T>(T);
3211struct Foo {} 3239struct Foo {}
3212impl Foo { 3240impl 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;
3230mod Foo<|> { 3259mod 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;"]
3261mod Foo<|> { 3290mod 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#"
3291fn no_hover() { 3320fn 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#"
3302fn foo() { 3331fn 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);
3335trait Copy {} 3364trait Copy {}
3336trait Clone {} 3365trait Clone {}
3337trait Sized {} 3366trait Sized {}
3338impl<T: Copy + Clone> Foo<T<|>> where T: Sized {} 3367impl<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#"
3350struct Foo<T>(T); 3379struct Foo<T>(T);
3351impl<T> Foo<T<|>> {} 3380impl<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#"
3364struct Foo<T>(T); 3393struct Foo<T>(T);
3365impl<T: 'static> Foo<T<|>> {} 3394impl<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#"
3381struct Foo<const LEN: usize>; 3410struct Foo<const LEN: usize>;
3382impl<const LEN: usize> Foo<LEN<|>> {} 3411impl<const LEN: usize> Foo<LEN$0> {}
3383"#, 3412"#,
3384 expect![[r#" 3413 expect![[r#"
3385 *LEN* 3414 *LEN*