Record method call substs and use them in call info

This commit is contained in:
Florian Diebold 2021-05-23 16:59:23 +02:00
parent 96e5412f88
commit 4a6cdd776d
9 changed files with 125 additions and 45 deletions

View file

@ -784,6 +784,19 @@ fn foo() {
)
}
#[test]
fn expected_type_generic_struct_field() {
check_expected_type_and_name(
r#"
struct Foo<T> { a: T }
fn foo() -> Foo<u32> {
Foo { a: $0 }
}
"#,
expect![[r#"ty: u32, name: a"#]],
)
}
#[test]
fn expected_type_struct_field_with_leading_char() {
cov_mark::check!(expected_type_struct_field_with_leading_char);
@ -895,4 +908,51 @@ fn foo() -> u32 {
expect![[r#"ty: u32, name: ?"#]],
)
}
#[test]
fn expected_type_closure_param() {
check_expected_type_and_name(
r#"
fn foo() {
bar(|| $0);
}
fn bar(f: impl FnOnce() -> u32) {}
#[lang = "fn_once"]
trait FnOnce { type Output; }
"#,
expect![[r#"ty: u32, name: ?"#]],
);
}
#[test]
fn expected_type_generic_function() {
check_expected_type_and_name(
r#"
fn foo() {
bar::<u32>($0);
}
fn bar<T>(t: T) {}
"#,
expect![[r#"ty: u32, name: t"#]],
);
}
#[test]
fn expected_type_generic_method() {
check_expected_type_and_name(
r#"
fn foo() {
S(1u32).bar($0);
}
struct S<T>(T);
impl<T> S<T> {
fn bar(self, t: T) {}
}
"#,
expect![[r#"ty: u32, name: t"#]],
);
}
}