Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide/src/inlay_hints/bind_pat.rs')
-rw-r--r--crates/ide/src/inlay_hints/bind_pat.rs92
1 files changed, 91 insertions, 1 deletions
diff --git a/crates/ide/src/inlay_hints/bind_pat.rs b/crates/ide/src/inlay_hints/bind_pat.rs
index 79cc2bdf8f..c74e3104c1 100644
--- a/crates/ide/src/inlay_hints/bind_pat.rs
+++ b/crates/ide/src/inlay_hints/bind_pat.rs
@@ -1258,7 +1258,7 @@ where
}
#[test]
- fn generic_param_inlay_hint_has_location_link() {
+ fn type_param_inlay_hint_has_location_link() {
check_expect(
InlayHintsConfig { type_hints: true, ..DISABLED_CONFIG },
r#"
@@ -1292,4 +1292,94 @@ fn identity<T>(t: T) -> T {
"#]],
);
}
+
+ #[test]
+ fn const_param_inlay_hint_has_location_link() {
+ check_expect(
+ InlayHintsConfig { type_hints: true, ..DISABLED_CONFIG },
+ r#"
+fn f<const N: usize>() {
+ let x = [0; N];
+}
+"#,
+ expect![[r#"
+ [
+ (
+ 33..34,
+ [
+ "[i32; ",
+ InlayHintLabelPart {
+ text: "N",
+ linked_location: Some(
+ Computed(
+ FileRangeWrapper {
+ file_id: FileId(
+ 0,
+ ),
+ range: 11..12,
+ },
+ ),
+ ),
+ tooltip: "",
+ },
+ "]",
+ ],
+ ),
+ ]
+ "#]],
+ );
+ }
+
+ #[test]
+ fn lifetime_param_inlay_hint_has_location_link() {
+ check_expect(
+ InlayHintsConfig { type_hints: true, ..DISABLED_CONFIG },
+ r#"
+struct S<'lt>(*mut &'lt ());
+
+fn f<'a>() {
+ let x = S::<'a>(loop {});
+}
+"#,
+ expect![[r#"
+ [
+ (
+ 51..52,
+ [
+ InlayHintLabelPart {
+ text: "S",
+ linked_location: Some(
+ Computed(
+ FileRangeWrapper {
+ file_id: FileId(
+ 0,
+ ),
+ range: 7..8,
+ },
+ ),
+ ),
+ tooltip: "",
+ },
+ "<",
+ InlayHintLabelPart {
+ text: "'a",
+ linked_location: Some(
+ Computed(
+ FileRangeWrapper {
+ file_id: FileId(
+ 0,
+ ),
+ range: 35..37,
+ },
+ ),
+ ),
+ tooltip: "",
+ },
+ ">",
+ ],
+ ),
+ ]
+ "#]],
+ );
+ }
}