Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/tests/traits.rs')
| -rw-r--r-- | crates/hir-ty/src/tests/traits.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/crates/hir-ty/src/tests/traits.rs b/crates/hir-ty/src/tests/traits.rs index 857891a214..829a6ab189 100644 --- a/crates/hir-ty/src/tests/traits.rs +++ b/crates/hir-ty/src/tests/traits.rs @@ -4375,3 +4375,38 @@ fn derive_macro_bounds() { "#, ); } + +#[test] +fn trait_obligations_should_be_registered_during_path_inference() { + check_types( + r#" +//- minicore: fn, from +struct S<T>(T); +fn map<T, U, F: FnOnce(T) -> S<U>>(_: T, _: F) -> U { loop {} } + +fn test(v: S<i32>) { + let res = map(v, Into::into); + //^^^ i32 +} +"#, + ); +} + +#[test] +fn fn_obligation_should_be_registered_during_path_inference() { + check_types( + r#" +//- minicore: fn, from +struct S<T>(T); +impl<T> S<T> { + fn foo<U: Into<S<T>>>(_: U) -> Self { loop {} } +} +fn map<T, U, F: FnOnce(T) -> U>(_: T, _: F) -> U { loop {} } + +fn test(v: S<i32>) { + let res = map(v, S::foo); + //^^^ S<i32> +} +"#, + ); +} |