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.rs141
1 files changed, 134 insertions, 7 deletions
diff --git a/crates/ide/src/inlay_hints/bind_pat.rs b/crates/ide/src/inlay_hints/bind_pat.rs
index de207c7821..c74e3104c1 100644
--- a/crates/ide/src/inlay_hints/bind_pat.rs
+++ b/crates/ide/src/inlay_hints/bind_pat.rs
@@ -183,7 +183,8 @@ mod tests {
use crate::{ClosureReturnTypeHints, fixture, inlay_hints::InlayHintsConfig};
use crate::inlay_hints::tests::{
- DISABLED_CONFIG, TEST_CONFIG, check, check_edit, check_no_edit, check_with_config,
+ DISABLED_CONFIG, TEST_CONFIG, check, check_edit, check_expect, check_no_edit,
+ check_with_config,
};
#[track_caller]
@@ -339,14 +340,14 @@ fn main(a: SliceIter<'_, Container>) {
fn lt_hints() {
check_types(
r#"
-struct S<'lt>;
+struct S<'lt>(*mut &'lt ());
fn f<'a>() {
- let x = S::<'static>;
+ let x = S::<'static>(loop {});
//^ S<'static>
- let y = S::<'_>;
+ let y = S::<'_>(loop {});
//^ S<'_>
- let z = S::<'a>;
+ let z = S::<'a>(loop {});
//^ S<'a>
}
@@ -632,10 +633,10 @@ fn main() {
fn multi_dyn_trait_bounds() {
check_types(
r#"
-pub struct Vec<T> {}
+pub struct Vec<T>(*mut T);
impl<T> Vec<T> {
- pub fn new() -> Self { Vec {} }
+ pub fn new() -> Self { Vec(0 as *mut T) }
}
pub struct Box<T> {}
@@ -1255,4 +1256,130 @@ where
"#,
);
}
+
+ #[test]
+ fn type_param_inlay_hint_has_location_link() {
+ check_expect(
+ InlayHintsConfig { type_hints: true, ..DISABLED_CONFIG },
+ r#"
+fn identity<T>(t: T) -> T {
+ let x = t;
+ x
+}
+"#,
+ expect![[r#"
+ [
+ (
+ 36..37,
+ [
+ InlayHintLabelPart {
+ text: "T",
+ linked_location: Some(
+ Computed(
+ FileRangeWrapper {
+ file_id: FileId(
+ 0,
+ ),
+ range: 12..13,
+ },
+ ),
+ ),
+ tooltip: "",
+ },
+ ],
+ ),
+ ]
+ "#]],
+ );
+ }
+
+ #[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: "",
+ },
+ ">",
+ ],
+ ),
+ ]
+ "#]],
+ );
+ }
}