1 use expect_test::{expect, Expect};
2 use ide_db::base_db::{FileLoader, FileRange};
5 use crate::{fixture, hover::HoverDocFormat, HoverConfig};
7 fn check_hover_no_result(ra_fixture: &str) {
8 let (analysis, position) = fixture::position(ra_fixture);
11 &HoverConfig { links_in_hover: true, documentation: Some(HoverDocFormat::Markdown) },
12 FileRange { file_id: position.file_id, range: TextRange::empty(position.offset) },
15 assert!(hover.is_none(), "hover not expected but found: {:?}", hover.unwrap());
18 fn check(ra_fixture: &str, expect: Expect) {
19 let (analysis, position) = fixture::position(ra_fixture);
22 &HoverConfig { links_in_hover: true, documentation: Some(HoverDocFormat::Markdown) },
23 FileRange { file_id: position.file_id, range: TextRange::empty(position.offset) },
28 let content = analysis.db.file_text(position.file_id);
29 let hovered_element = &content[hover.range];
31 let actual = format!("*{}*\n{}\n", hovered_element, hover.info.markup);
32 expect.assert_eq(&actual)
35 fn check_hover_no_links(ra_fixture: &str, expect: Expect) {
36 let (analysis, position) = fixture::position(ra_fixture);
39 &HoverConfig { links_in_hover: false, documentation: Some(HoverDocFormat::Markdown) },
40 FileRange { file_id: position.file_id, range: TextRange::empty(position.offset) },
45 let content = analysis.db.file_text(position.file_id);
46 let hovered_element = &content[hover.range];
48 let actual = format!("*{}*\n{}\n", hovered_element, hover.info.markup);
49 expect.assert_eq(&actual)
52 fn check_hover_no_markdown(ra_fixture: &str, expect: Expect) {
53 let (analysis, position) = fixture::position(ra_fixture);
56 &HoverConfig { links_in_hover: true, documentation: Some(HoverDocFormat::PlainText) },
57 FileRange { file_id: position.file_id, range: TextRange::empty(position.offset) },
62 let content = analysis.db.file_text(position.file_id);
63 let hovered_element = &content[hover.range];
65 let actual = format!("*{}*\n{}\n", hovered_element, hover.info.markup);
66 expect.assert_eq(&actual)
69 fn check_actions(ra_fixture: &str, expect: Expect) {
70 let (analysis, file_id, position) = fixture::range_or_position(ra_fixture);
73 &HoverConfig { links_in_hover: true, documentation: Some(HoverDocFormat::Markdown) },
74 FileRange { file_id, range: position.range_or_empty() },
78 expect.assert_debug_eq(&hover.info.actions)
81 fn check_hover_range(ra_fixture: &str, expect: Expect) {
82 let (analysis, range) = fixture::range(ra_fixture);
85 &HoverConfig { links_in_hover: false, documentation: Some(HoverDocFormat::Markdown) },
90 expect.assert_eq(hover.info.markup.as_str())
93 fn check_hover_range_no_results(ra_fixture: &str) {
94 let (analysis, range) = fixture::range(ra_fixture);
97 &HoverConfig { links_in_hover: false, documentation: Some(HoverDocFormat::Markdown) },
101 assert!(hover.is_none());
105 fn hover_descend_macros_avoids_duplicates() {
108 macro_rules! dupe_use {
132 fn hover_shows_all_macro_descends() {
181 fn hover_shows_type_of_an_expression() {
184 pub fn foo() -> u32 { 1 }
187 let foo_test = foo()$0;
200 fn hover_remove_markdown_if_configured() {
201 check_hover_no_markdown(
203 pub fn foo() -> u32 { 1 }
206 let foo_test = foo()$0;
217 fn hover_shows_long_type_of_an_expression() {
220 struct Scan<A, B, C> { a: A, b: B, c: C }
221 struct Iter<I> { inner: I }
222 enum Option<T> { Some(T), None }
224 struct OtherStruct<T> { i: T }
226 fn scan<A, B, C>(a: A, b: B, c: C) -> Iter<Scan<OtherStruct<A>, B, C>> {
227 Iter { inner: Scan { a, b, c } }
232 let closure = |memo: &mut u32, value: &u32, _another: &mut u32| -> Option<u32> {
233 Option::Some(*memo + value)
236 let mut iter$0 = scan(OtherStruct { i: num }, closure, number);
243 let mut iter: Iter<Scan<OtherStruct<OtherStruct<i32>>, |&mut u32, &u32, &mut u32| -> Option<u32>, u32>>
250 fn hover_shows_fn_signature() {
251 // Single file with result
254 pub fn foo() -> u32 { 1 }
256 fn main() { let foo_test = fo$0o(); }
271 // Multiple candidates but results are ambiguous.
275 pub fn foo() -> u32 { 1 }
278 pub fn foo() -> &str { "" }
281 pub fn foo(a: u32, b: u32) {}
288 fn main() { let foo_test = fo$0o(); }
298 // Use literal `crate` in path
303 fn foo() -> crate::X { X }
305 fn main() { f$0oo(); }
320 // Check `super` in path
325 mod m { pub fn foo() -> super::X { super::X } }
327 fn main() { m::f$0oo(); }
337 pub fn foo() -> super::X
344 fn hover_shows_fn_signature_with_type_params() {
347 pub fn foo<'a, T: AsRef<str>>(b: &'a T) -> &'a str { }
349 fn main() { let foo_test = fo$0o(); }
359 pub fn foo<'a, T>(b: &'a T) -> &'a str
368 fn hover_shows_fn_signature_on_fn_name() {
371 pub fn foo$0(a: u32, b: u32) -> u32 {}
383 pub fn foo(a: u32, b: u32) -> u32
390 fn hover_shows_fn_doc() {
395 /// # use std::path::Path;
397 /// foo(Path::new("hello, world!"))
399 pub fn foo$0(_: &Path) {}
419 # use std::path::Path;
421 foo(Path::new("hello, world!"))
428 fn hover_shows_fn_doc_attr_raw_string() {
431 #[doc = r#"Raw string doc attr"#]
432 pub fn foo$0(_: &Path) {}
455 fn hover_shows_struct_field_info() {
456 // Hovering over the field when instantiating
459 struct Foo { field_a: u32 }
462 let foo = Foo { field_a$0: 0, };
478 // Hovering over the field in the definition
481 struct Foo { field_a$0: u32 }
484 let foo = Foo { field_a: 0 };
502 fn hover_const_static() {
504 r#"const foo$0: u32 = 123;"#,
518 r#"static foo$0: u32 = 456;"#,
534 fn hover_default_generic_types() {
537 struct Test<K, T = u8> { k: K, t: T }
540 let zz$0 = Test { t: 23u8, k: 33 };
546 let zz: Test<i32, u8>
556 enum Option<T> { Some(T) }
559 fn main() { So$0me(12); }
576 enum Option<T> { Some(T) }
579 fn main() { let b$0ar = Some(12); }
592 fn hover_enum_variant() {
624 let s = Option::Som$0e(12);
646 fn hover_for_local_variable() {
648 r#"fn func(foo: i32) { fo$0o; }"#,
660 fn hover_for_local_variable_pat() {
662 r#"fn func(fo$0o: i32) {}"#,
674 fn hover_local_var_edge() {
676 r#"fn func(foo: i32) { if true { $0foo; }; }"#,
688 fn hover_for_param_edge() {
690 r#"fn func($0foo: i32) {}"#,
702 fn hover_for_param_with_multiple_traits() {
712 fn f(_x$0: impl Deref<Target=u8> + DerefMut<Target=u8>) {}"#,
717 _x: impl Deref<Target = u8> + DerefMut<Target = u8>
724 fn test_hover_infer_associated_method_result() {
727 struct Thing { x: u32 }
730 fn new() -> Thing { Thing { x: 0 } }
733 fn main() { let foo_$0test = Thing::new(); }
746 fn test_hover_infer_associated_method_exact() {
750 struct Thing { x: u32 }
753 fn new() -> Thing { Thing { x: 0 } }
757 fn main() { let foo_test = wrapper::Thing::new$0(); }
774 fn test_hover_infer_associated_const_in_pattern() {
805 fn test_hover_self() {
808 struct Thing { x: u32 }
810 fn new() -> Self { Self$0 { x: 0 } }
827 struct Thing { x: u32 }
829 fn new() -> Self$0 { Self { x: 0 } }
848 pub fn new() -> Self$0 { Thing::A }
867 pub fn thing(a: Self$0) {}
885 fn test_hover_shadowing_pat() {
906 fn test_hover_macro_invocation() {
909 macro_rules! foo { () => {} }
928 fn test_hover_macro2_invocation() {
959 fn test_hover_tuple_field() {
961 r#"struct TS(String, i32$0);"#,
973 fn test_hover_through_macro() {
976 macro_rules! id { ($($tt:tt)*) => { $($tt)* } }
979 fn bar() { fo$0o(); }
997 fn test_hover_through_attr() {
1000 //- proc_macros: identity
1001 #[proc_macros::identity]
1019 fn test_hover_through_expr_in_macro() {
1022 macro_rules! id { ($($tt:tt)*) => { $($tt)* } }
1023 fn foo(bar:u32) { let a = id!(ba$0r); }
1036 fn test_hover_through_expr_in_macro_recursive() {
1039 macro_rules! id_deep { ($($tt:tt)*) => { $($tt)* } }
1040 macro_rules! id { ($($tt:tt)*) => { id_deep!($($tt)*) } }
1041 fn foo(bar:u32) { let a = id!(ba$0r); }
1054 fn test_hover_through_func_in_macro_recursive() {
1057 macro_rules! id_deep { ($($tt:tt)*) => { $($tt)* } }
1058 macro_rules! id { ($($tt:tt)*) => { id_deep!($($tt)*) } }
1059 fn bar() -> u32 { 0 }
1060 fn foo() { let a = id!([0u32, bar($0)] ); }
1072 fn test_hover_through_literal_string_in_macro() {
1075 macro_rules! arr { ($($tt:tt)*) => { [$($tt)*)] } }
1077 let mastered_for_itunes = "";
1078 let _ = arr!("Tr$0acks", &mastered_for_itunes);
1091 fn test_hover_through_assert_macro() {
1094 #[rustc_builtin_macro]
1095 macro_rules! assert {}
1097 fn bar() -> bool { true }
1117 fn test_hover_through_literal_string_in_builtin_macro() {
1118 check_hover_no_result(
1120 #[rustc_builtin_macro]
1121 macro_rules! format {}
1124 format!("hel$0lo {}", 0);
1131 fn test_hover_non_ascii_space_doc() {
1134 /// <- `\u{3000}` here
1137 fn bar() { fo$0o(); }
1158 fn test_hover_function_show_qualifiers() {
1160 r#"async fn foo$0() {}"#,
1174 r#"pub const unsafe fn foo$0() {}"#,
1183 pub const unsafe fn foo()
1187 // Top level `pub(crate)` will be displayed as no visibility.
1189 r#"mod m { pub(crate) async unsafe extern "C" fn foo$0() {} }"#,
1198 pub(crate) async unsafe extern "C" fn foo()
1205 fn test_hover_trait_show_qualifiers() {
1207 r"unsafe trait foo$0() {}",
1224 fn test_hover_extern_crate() {
1227 //- /main.rs crate:main deps:std
1229 //- /std/lib.rs crate:std
1230 //! Standard library for this test
1244 Standard library for this test
1252 //- /main.rs crate:main deps:std
1253 extern crate std as ab$0c;
1254 //- /std/lib.rs crate:std
1255 //! Standard library for this test
1269 Standard library for this test
1278 fn test_hover_mod_with_same_name_as_function() {
1281 use self::m$0y::Bar;
1282 mod my { pub struct Bar; }
1301 fn test_hover_struct_doc_comment() {
1304 /// This is an example
1312 /// assert_eq!(6, my_crate::add_one(5));
1316 fn foo() { let bar = Ba$0r; }
1339 assert_eq!(6, my_crate::add_one(5));
1346 fn test_hover_struct_doc_attr() {
1352 fn foo() { let bar = Ba$0r; }
1373 fn test_hover_struct_doc_attr_multiple_and_mixed() {
1377 #[doc = "bar docs 1"]
1378 #[doc = "bar docs 2"]
1381 fn foo() { let bar = Ba$0r; }
1404 fn test_hover_external_url() {
1408 /// [external](https://www.google.com)
1424 [external](https://www.google.com)
1429 // Check that we don't rewrite links which we can't identify
1431 fn test_hover_unknown_target() {
1457 fn test_hover_no_links() {
1458 check_hover_no_links(
1461 /// case 1. bare URL: https://www.example.com/
1462 /// case 2. inline URL with title: [example](https://www.example.com/)
1463 /// case 3. code reference: [`Result`]
1464 /// case 4. code reference but miss footnote: [`String`]
1465 /// case 5. autolink: <http://www.example.com/>
1466 /// case 6. email address: <test@example.com>
1467 /// case 7. reference: [example][example]
1468 /// case 8. collapsed link: [example][]
1469 /// case 9. shortcut link: [example]
1470 /// case 10. inline without URL: [example]()
1471 /// case 11. reference: [foo][foo]
1472 /// case 12. reference: [foo][bar]
1473 /// case 13. collapsed link: [foo][]
1474 /// case 14. shortcut link: [foo]
1475 /// case 15. inline without URL: [foo]()
1476 /// case 16. just escaped text: \[foo]
1477 /// case 17. inline link: [Foo](foo::Foo)
1479 /// [`Result`]: ../../std/result/enum.Result.html
1480 /// [^example]: https://www.example.com/
1497 case 1. bare URL: https://www.example.com/
1498 case 2. inline URL with title: [example](https://www.example.com/)
1499 case 3. code reference: `Result`
1500 case 4. code reference but miss footnote: `String`
1501 case 5. autolink: http://www.example.com/
1502 case 6. email address: test@example.com
1503 case 7. reference: example
1504 case 8. collapsed link: example
1505 case 9. shortcut link: example
1506 case 10. inline without URL: example
1507 case 11. reference: foo
1508 case 12. reference: foo
1509 case 13. collapsed link: foo
1510 case 14. shortcut link: foo
1511 case 15. inline without URL: foo
1512 case 16. just escaped text: \[foo\]
1513 case 17. inline link: Foo
1515 [^example]: https://www.example.com/
1521 fn test_hover_macro_generated_struct_fn_doc_comment() {
1522 cov_mark::check!(hover_macro_generated_struct_fn_doc_comment);
1538 fn foo() { let bar = Bar; bar.fo$0o(); }
1559 fn test_hover_macro_generated_struct_fn_doc_attr() {
1560 cov_mark::check!(hover_macro_generated_struct_fn_doc_attr);
1568 #[doc = "Do the foo"]
1576 fn foo() { let bar = Bar; bar.fo$0o(); }
1597 fn test_hover_trait_has_impl_action() {
1599 r#"trait foo$0() {}"#,
1616 fn test_hover_struct_has_impl_action() {
1618 r"struct foo$0() {}",
1635 fn test_hover_union_has_impl_action() {
1637 r#"union foo$0() {}"#,
1654 fn test_hover_enum_has_impl_action() {
1656 r"enum foo$0() { A, B }",
1673 fn test_hover_self_has_impl_action() {
1675 r#"struct foo where Self$0:;"#,
1692 fn test_hover_test_has_action() {
1710 use_name_in_title: false,
1711 nav: NavigationTarget {
1716 focus_range: 11..19,
1737 fn test_hover_test_mod_has_action() {
1749 use_name_in_title: false,
1750 nav: NavigationTarget {
1758 description: "mod tests",
1772 fn test_hover_struct_has_goto_type_action() {
1777 fn main() { let s$0t = S{ f1:0 }; }
1784 mod_path: "test::S",
1785 nav: NavigationTarget {
1793 description: "struct S",
1804 fn test_hover_generic_struct_has_goto_type_actions() {
1808 struct S<T>{ f1: T }
1810 fn main() { let s$0t = S{ f1:Arg(0) }; }
1817 mod_path: "test::S",
1818 nav: NavigationTarget {
1823 focus_range: 24..25,
1826 description: "struct S<T>",
1830 mod_path: "test::Arg",
1831 nav: NavigationTarget {
1839 description: "struct Arg",
1850 fn test_hover_generic_struct_has_flattened_goto_type_actions() {
1854 struct S<T>{ f1: T }
1856 fn main() { let s$0t = S{ f1: S{ f1: Arg(0) } }; }
1863 mod_path: "test::S",
1864 nav: NavigationTarget {
1869 focus_range: 24..25,
1872 description: "struct S<T>",
1876 mod_path: "test::Arg",
1877 nav: NavigationTarget {
1885 description: "struct Arg",
1896 fn test_hover_tuple_has_goto_type_actions() {
1905 fn main() { let s$0t = (A(1), B(2), M::C(3) ); }
1912 mod_path: "test::A",
1913 nav: NavigationTarget {
1921 description: "struct A",
1925 mod_path: "test::B",
1926 nav: NavigationTarget {
1931 focus_range: 22..23,
1934 description: "struct B",
1938 mod_path: "test::M::C",
1939 nav: NavigationTarget {
1944 focus_range: 53..54,
1947 description: "pub struct C",
1958 fn test_hover_return_impl_trait_has_goto_type_action() {
1962 fn foo() -> impl Foo {}
1964 fn main() { let s$0t = foo(); }
1971 mod_path: "test::Foo",
1972 nav: NavigationTarget {
1980 description: "trait Foo",
1991 fn test_hover_generic_return_impl_trait_has_goto_type_action() {
1996 fn foo() -> impl Foo<S> {}
1998 fn main() { let s$0t = foo(); }
2005 mod_path: "test::Foo",
2006 nav: NavigationTarget {
2014 description: "trait Foo<T>",
2018 mod_path: "test::S",
2019 nav: NavigationTarget {
2024 focus_range: 23..24,
2027 description: "struct S",
2038 fn test_hover_return_impl_traits_has_goto_type_action() {
2043 fn foo() -> impl Foo + Bar {}
2045 fn main() { let s$0t = foo(); }
2052 mod_path: "test::Foo",
2053 nav: NavigationTarget {
2061 description: "trait Foo",
2065 mod_path: "test::Bar",
2066 nav: NavigationTarget {
2071 focus_range: 19..22,
2074 description: "trait Bar",
2085 fn test_hover_generic_return_impl_traits_has_goto_type_action() {
2093 fn foo() -> impl Foo<S1> + Bar<S2> {}
2095 fn main() { let s$0t = foo(); }
2102 mod_path: "test::Foo",
2103 nav: NavigationTarget {
2111 description: "trait Foo<T>",
2115 mod_path: "test::Bar",
2116 nav: NavigationTarget {
2121 focus_range: 22..25,
2124 description: "trait Bar<T>",
2128 mod_path: "test::S1",
2129 nav: NavigationTarget {
2134 focus_range: 39..41,
2137 description: "struct S1",
2141 mod_path: "test::S2",
2142 nav: NavigationTarget {
2147 focus_range: 52..54,
2150 description: "struct S2",
2161 fn test_hover_arg_impl_trait_has_goto_type_action() {
2165 fn foo(ar$0g: &impl Foo) {}
2172 mod_path: "test::Foo",
2173 nav: NavigationTarget {
2181 description: "trait Foo",
2192 fn test_hover_arg_impl_traits_has_goto_type_action() {
2199 fn foo(ar$0g: &impl Foo + Bar<S>) {}
2206 mod_path: "test::Foo",
2207 nav: NavigationTarget {
2215 description: "trait Foo",
2219 mod_path: "test::Bar",
2220 nav: NavigationTarget {
2225 focus_range: 19..22,
2228 description: "trait Bar<T>",
2232 mod_path: "test::S",
2233 nav: NavigationTarget {
2238 focus_range: 36..37,
2241 description: "struct S",
2252 fn test_hover_async_block_impl_trait_has_goto_type_action() {
2255 //- minicore: future
2258 let fo$0o = async { S };
2266 mod_path: "core::future::Future",
2267 nav: NavigationTarget {
2271 full_range: 276..458,
2272 focus_range: 315..321,
2275 description: "pub trait Future",
2279 mod_path: "test::S",
2280 nav: NavigationTarget {
2288 description: "struct S",
2299 fn test_hover_arg_generic_impl_trait_has_goto_type_action() {
2304 fn foo(ar$0g: &impl Foo<S>) {}
2311 mod_path: "test::Foo",
2312 nav: NavigationTarget {
2320 description: "trait Foo<T>",
2324 mod_path: "test::S",
2325 nav: NavigationTarget {
2330 focus_range: 23..24,
2333 description: "struct S",
2344 fn test_hover_dyn_return_has_goto_type_action() {
2352 fn foo() -> B<dyn Foo> {}
2354 fn main() { let s$0t = foo(); }
2361 mod_path: "test::B",
2362 nav: NavigationTarget {
2367 focus_range: 49..50,
2370 description: "struct B<T>",
2374 mod_path: "test::Foo",
2375 nav: NavigationTarget {
2383 description: "trait Foo",
2394 fn test_hover_dyn_arg_has_goto_type_action() {
2398 fn foo(ar$0g: &dyn Foo) {}
2405 mod_path: "test::Foo",
2406 nav: NavigationTarget {
2414 description: "trait Foo",
2425 fn test_hover_generic_dyn_arg_has_goto_type_action() {
2430 fn foo(ar$0g: &dyn Foo<S>) {}
2437 mod_path: "test::Foo",
2438 nav: NavigationTarget {
2446 description: "trait Foo<T>",
2450 mod_path: "test::S",
2451 nav: NavigationTarget {
2456 focus_range: 23..24,
2459 description: "struct S",
2470 fn test_hover_goto_type_action_links_order() {
2473 trait ImplTrait<T> {}
2474 trait DynTrait<T> {}
2478 fn foo(a$0rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {}
2485 mod_path: "test::ImplTrait",
2486 nav: NavigationTarget {
2494 description: "trait ImplTrait<T>",
2498 mod_path: "test::B",
2499 nav: NavigationTarget {
2504 focus_range: 50..51,
2507 description: "struct B<T>",
2511 mod_path: "test::DynTrait",
2512 nav: NavigationTarget {
2517 focus_range: 28..36,
2520 description: "trait DynTrait<T>",
2524 mod_path: "test::S",
2525 nav: NavigationTarget {
2530 focus_range: 65..66,
2533 description: "struct S",
2544 fn test_hover_associated_type_has_goto_type_action() {
2549 fn get(self) -> Self::Item {}
2555 impl Foo for S { type Item = Bar; }
2557 fn test() -> impl Foo { S {} }
2559 fn main() { let s$0t = test().get(); }
2566 mod_path: "test::Foo",
2567 nav: NavigationTarget {
2575 description: "trait Foo",
2586 fn test_hover_const_param_has_goto_type_action() {
2590 struct Foo<const BAR: Bar>;
2592 impl<const BAR: Bar> Foo<BAR$0> {}
2599 mod_path: "test::Bar",
2600 nav: NavigationTarget {
2608 description: "struct Bar",
2619 fn test_hover_type_param_has_goto_type_action() {
2624 fn foo<T: Foo>(t: T$0){}
2631 mod_path: "test::Foo",
2632 nav: NavigationTarget {
2640 description: "trait Foo",
2651 fn test_hover_self_has_go_to_type() {
2664 mod_path: "test::Foo",
2665 nav: NavigationTarget {
2673 description: "struct Foo",
2684 fn hover_displays_normalized_crate_names() {
2687 //- /lib.rs crate:name-with-dashes
2689 pub struct Thing { x: u32 }
2692 pub fn new() -> Thing { Thing { x: 0 } }
2696 //- /main.rs crate:main deps:name-with-dashes
2697 fn main() { let foo_test = name_with_dashes::wrapper::Thing::new$0(); }
2703 name_with_dashes::wrapper::Thing
2707 pub fn new() -> Thing
2714 fn hover_field_pat_shorthand_ref_match_ergonomics() {
2746 fn hover_self_param_shows_type() {
2765 fn hover_self_param_shows_type_for_arbitrary_self_type() {
2771 fn bar(sel$0f: Arc<Foo>) {}
2785 fn hover_doc_outer_inner() {
2792 /// This comment belongs to the function
2816 fn hover_doc_outer_inner_attribue() {
2819 #[doc = "Be quick;"]
2821 #![doc = "time is mana"]
2823 #[doc = "This comment belongs to the function"]
2847 fn hover_doc_block_style_indentend() {
2881 fn hover_comments_dont_highlight_parent() {
2882 cov_mark::check!(no_highlight_on_comment_hover);
2883 check_hover_no_result(
2911 fn hover_lifetime() {
2913 r#"fn foo<'lifetime>(_: &'lifetime$0 ()) {}"#,
2925 fn hover_type_param() {
2932 impl<T: TraitA + TraitB> Foo<T$0> where T: Sized {}
2956 // lifetimes bounds arent being tracked yet
2961 impl<T: 'static> Foo<T$0> {}
2974 fn hover_type_param_sized_bounds() {
2975 // implicit `: Sized` bound
2981 impl<T: Trait> Foo<T$0> {}
2996 impl<T: Trait + ?Sized> Foo<T$0> {}
3008 mod type_param_sized_bounds {
3012 fn single_implicit() {
3029 fn single_explicit() {
3033 fn foo<T$0: Sized>() {}
3046 fn single_relaxed() {
3050 fn foo<T$0: ?Sized>() {}
3063 fn multiple_implicit() {
3068 fn foo<T$0: Trait>() {}
3081 fn multiple_explicit() {
3086 fn foo<T$0: Trait + Sized>() {}
3099 fn multiple_relaxed() {
3104 fn foo<T$0: Trait + ?Sized>() {}
3121 fn foo<T$0: ?Sized + Sized + Sized>() {}
3135 fn foo<T$0: Sized + ?Sized + Sized + Trait>() {}
3149 fn hover_const_param() {
3152 struct Foo<const LEN: usize>;
3153 impl<const LEN: usize> Foo<LEN$0> {}
3166 fn hover_const_pat() {
3170 const FOO: usize = 3;
3197 fn hover_mod_def() {
3224 fn hover_self_in_use() {
3227 //! This should not appear
3229 /// But this should appear
3232 use foo::bar::{self$0};
3247 But this should appear
3253 fn hover_keyword() {
3256 //- /main.rs crate:main deps:std
3257 fn f() { retur$0n; }
3258 //- /libstd.rs crate:std
3259 /// Docs for return_keyword
3260 mod return_keyword {}
3271 Docs for return_keyword
3277 fn hover_builtin() {
3280 //- /main.rs crate:main deps:std
3281 cosnt _: &str$0 = ""; }
3283 //- /libstd.rs crate:std
3284 /// Docs for prim_str
3302 fn hover_macro_expanded_function() {
3305 struct S<'a, T>(&'a T);
3309 fn bar<'t, T: Clone + 't>(s: &mut S<'t, T>, t: u32) -> *mut u32 where
3311 for<'a> T: Clone + 'a
3330 fn bar<'t, T>(s: &mut S<'t, T>, t: u32) -> *mut u32
3334 for<'a> T: Clone + 'a,
3341 fn hover_intra_doc_links() {
3346 /// This is the item. Cool!
3350 /// Gives you a [`TheItem$0`].
3352 /// [`TheItem`]: theitem::TheItem
3353 pub fn gimme() -> theitem::TheItem {
3370 This is the item. Cool!
3376 fn hover_generic_assoc() {
3379 fn foo<T: A>() where T::Assoc$0: {}
3399 let _: <T>::Assoc$0;
3439 fn string_shadowed_with_inner_items() {
3442 //- /main.rs crate:main deps:alloc
3444 /// Custom `String` type.
3453 //- /alloc.rs crate:alloc
3458 /// This is `alloc::String`.
3475 Custom `String` type.
3481 fn function_doesnt_shadow_crate_in_use_tree() {
3484 //- /main.rs crate:main deps:foo
3487 //- /foo.rs crate:foo
3501 fn hover_feature() {
3503 r#"#![feature(box_syntax$0)]"#,
3513 The tracking issue for this feature is: [#49733]
3515 [#49733]: https://github.com/rust-lang/rust/issues/49733
3517 See also [`box_patterns`](box-patterns.md)
3519 ------------------------
3521 Currently the only stable way to create a `Box` is via the `Box::new` method.
3522 Also it is not possible in stable Rust to destructure a `Box` in a match
3523 pattern. The unstable `box` keyword can be used to create a `Box`. An example
3527 #![feature(box_syntax)]
3541 r#"#![allow(arithmetic_overflow$0)]"#,
3543 *arithmetic_overflow*
3549 arithmetic operation overflows
3555 fn hover_clippy_lint() {
3557 r#"#![allow(clippy::almost_swapped$0)]"#,
3561 clippy::almost_swapped
3565 Checks for `foo = bar; bar = foo` sequences.
3571 fn hover_attr_path_qualifier() {
3572 cov_mark::check!(name_ref_classify_attr_path_qualifier);
3575 //- /foo.rs crate:foo
3577 //- /lib.rs crate:main.rs deps:foo
3608 use bar::{self as foo$0};
3651 fn hover_attribute_in_macro() {
3655 macro_rules! identity {
3660 #[rustc_builtin_macro]
3682 fn hover_derive_input() {
3686 #[rustc_builtin_macro]
3707 #[rustc_builtin_macro]
3710 #[derive(foo::Copy$0)]
3728 fn hover_range_math() {
3731 fn f() { let expr = $01 + 2 * 3$0 }
3741 fn f() { let expr = 1 $0+ 2 * $03 }
3751 fn f() { let expr = 1 + $02 * 3$0 }
3761 fn hover_range_arrays() {
3764 fn f() { let expr = $0[1, 2, 3, 4]$0 }
3774 fn f() { let expr = [1, 2, $03, 4]$0 }
3784 fn f() { let expr = [1, 2, $03$0, 4] }
3794 fn hover_range_functions() {
3797 fn f<T>(a: &[T]) { }
3798 fn b() { $0f$0(&[1, 2, 3, 4, 5]); }
3808 fn f<T>(a: &[T]) { }
3809 fn b() { f($0&[1, 2, 3, 4, 5]$0); }
3819 fn hover_range_shows_nothing_when_invalid() {
3820 check_hover_range_no_results(
3822 fn f<T>(a: &[T]) { }
3823 fn b()$0 { f(&[1, 2, 3, 4, 5]); }$0
3827 check_hover_range_no_results(
3829 fn f<T>$0(a: &[T]) { }
3830 fn b() { f(&[1, 2, 3,$0 4, 5]); }
3834 check_hover_range_no_results(
3836 fn $0f() { let expr = [1, 2, 3, 4]$0 }
3842 fn hover_range_shows_unit_for_statements() {
3845 fn f<T>(a: &[T]) { }
3846 fn b() { $0f(&[1, 2, 3, 4, 5]); }$0
3856 fn f() { let expr$0 = $0[1, 2, 3, 4] }
3866 fn hover_range_for_pat() {
3893 fn hover_range_shows_coercions_if_applicable_expr() {
3897 let x: &u32 = $0&&&&&0$0;
3910 let x: *const u32 = $0&0$0;
3916 Coerced to: *const u32
3923 fn hover_range_shows_type_actions() {
3928 let x: &Foo = $0&&&&&Foo$0;
3936 mod_path: "test::Foo",
3937 nav: NavigationTarget {
3945 description: "struct Foo",
3956 fn hover_try_expr_res() {
3962 fn foo() -> Result<(), FooError> {
3963 Ok($0Result::<(), FooError>::Ok(())?$0)
3977 fn foo() -> Result<(), FooError> {
3978 Ok($0Result::<(), BarError>::Ok(())?$0)
3983 Try Error Type: BarError
3984 Propagated as: FooError
3991 fn hover_try_expr() {
3994 struct NotResult<T, U>(T, U);
3998 fn foo() -> NotResult<(), Looooong> {
3999 $0NotResult((), Short)?$0;
4004 Try Target Type: NotResult<(), Short>
4005 Propagated as: NotResult<(), Looooong>
4011 struct NotResult<T, U>(T, U);
4015 fn foo() -> NotResult<(), Short> {
4016 $0NotResult((), Looooong)?$0;
4021 Try Target Type: NotResult<(), Looooong>
4022 Propagated as: NotResult<(), Short>
4029 fn hover_try_expr_option() {
4030 cov_mark::check!(hover_try_expr_opt_opt);
4033 //- minicore: option, try
4035 fn foo() -> Option<()> {
4042 <Option<i32> as Try>::Output
4048 fn hover_deref_expr() {
4052 use core::ops::Deref;
4054 struct DerefExample<T> {
4058 impl<T> Deref for DerefExample<T> {
4061 fn deref(&self) -> &Self::Target {
4067 let x = DerefExample { value: 0 };
4068 let y: i32 = $0*x$0;
4073 Dereferenced from: DerefExample<i32>
4081 fn hover_deref_expr_with_coercion() {
4085 use core::ops::Deref;
4087 struct DerefExample<T> {
4091 impl<T> Deref for DerefExample<T> {
4094 fn deref(&self) -> &Self::Target {
4100 let x = DerefExample { value: &&&&&0 };
4101 let y: &i32 = $0*x$0;
4106 Dereferenced from: DerefExample<&&&&&i32>
4115 fn hover_intra_in_macro() {
4118 macro_rules! foo_macro {
4119 ($(#[$attr:meta])* $name:ident) => {
4126 /// Doc comment for [`Foo$0`]
4143 Doc comment for [`Foo`](https://doc.rust-lang.org/nightly/test/struct.Foo.html)
4149 fn hover_intra_in_attr() {
4152 #[doc = "Doc comment for [`Foo$0`]"]
4168 Doc comment for [`Foo`](https://doc.rust-lang.org/nightly/test/struct.Foo.html)