Skip to content

Commit

Permalink
Add inlay hints lifetime arg tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Veykril committed Apr 25, 2024
1 parent 31304ad commit ec941e5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
2 changes: 1 addition & 1 deletion crates/ide-assists/src/handlers/extract_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5623,7 +5623,7 @@ fn func<T: Debug>(i: Struct<'_, T>) {
fun_name(i);
}
fn $0fun_name(i: Struct<'_, T>) {
fn $0fun_name(i: Struct<T>) {
foo(i);
}
"#,
Expand Down
4 changes: 2 additions & 2 deletions crates/ide-completion/src/tests/predicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct Foo<'lt, T, const C: usize> where $0 {}
en Enum Enum
ma makro!(…) macro_rules! makro
md module
st Foo<…> Foo<'{error}, {unknown}, _>
st Foo<…> Foo<{unknown}, _>
st Record Record
st Tuple Tuple
st Unit Unit
Expand Down Expand Up @@ -92,7 +92,7 @@ struct Foo<'lt, T, const C: usize> where for<'a> $0 {}
en Enum Enum
ma makro!(…) macro_rules! makro
md module
st Foo<…> Foo<'{error}, {unknown}, _>
st Foo<…> Foo<{unknown}, _>
st Record Record
st Tuple Tuple
st Unit Unit
Expand Down
8 changes: 4 additions & 4 deletions crates/ide-completion/src/tests/type_pos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ struct Foo<'lt, T, const C: usize> {
en Enum Enum
ma makro!(…) macro_rules! makro
md module
sp Self Foo<'{error}, {unknown}, _>
st Foo<…> Foo<'{error}, {unknown}, _>
sp Self Foo<{unknown}, _>
st Foo<…> Foo<{unknown}, _>
st Record Record
st Tuple Tuple
st Unit Unit
Expand All @@ -45,8 +45,8 @@ struct Foo<'lt, T, const C: usize>(f$0);
en Enum Enum
ma makro!(…) macro_rules! makro
md module
sp Self Foo<'{error}, {unknown}, _>
st Foo<…> Foo<'{error}, {unknown}, _>
sp Self Foo<{unknown}, _>
st Foo<…> Foo<{unknown}, _>
st Record Record
st Tuple Tuple
st Unit Unit
Expand Down
21 changes: 20 additions & 1 deletion crates/ide/src/inlay_hints/bind_pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,25 @@ fn main(a: SliceIter<'_, Container>) {
);
}

#[test]
fn lt_hints() {
check_types(
r#"
struct S<'lt>;
fn f<'a>() {
let x = S::<'static>;
//^ S<'static>
let y = S::<'_>;
//^ S
let z = S::<'a>;
//^ S<'a>
}
"#,
);
}

#[test]
fn fn_hints() {
check_types(
Expand All @@ -341,7 +360,7 @@ fn foo1() -> impl Fn(f64) { loop {} }
fn foo2() -> impl Fn(f64, f64) { loop {} }
fn foo3() -> impl Fn(f64, f64) -> u32 { loop {} }
fn foo4() -> &'static dyn Fn(f64, f64) -> u32 { loop {} }
fn foo5() -> &'static dyn Fn(&'static dyn Fn(f64, f64) -> u32, f64) -> u32 { loop {} }
fn foo5() -> &'static for<'a> dyn Fn(&'a dyn Fn(f64, f64) -> u32, f64) -> u32 { loop {} }
fn foo6() -> impl Fn(f64, f64) -> u32 + Sized { loop {} }
fn foo7() -> *const (impl Fn(f64, f64) -> u32 + Sized) { loop {} }
Expand Down

0 comments on commit ec941e5

Please sign in to comment.