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.rs47
1 files changed, 47 insertions, 0 deletions
diff --git a/crates/hir-ty/src/tests/traits.rs b/crates/hir-ty/src/tests/traits.rs
index 39c5547b8d..b80cfe18e4 100644
--- a/crates/hir-ty/src/tests/traits.rs
+++ b/crates/hir-ty/src/tests/traits.rs
@@ -1232,6 +1232,53 @@ fn test(x: impl Trait<u64>, y: &impl Trait<u64>) {
}
#[test]
+fn argument_impl_trait_with_projection() {
+ check_infer(
+ r#"
+trait X {
+ type Item;
+}
+
+impl<T> X for [T; 2] {
+ type Item = T;
+}
+
+trait Y {}
+
+impl<T> Y for T {}
+
+enum R<T, U> {
+ A(T),
+ B(U),
+}
+
+fn foo<T>(x: impl X<Item = R<impl Y, T>>) -> T { loop {} }
+
+fn bar() {
+ let a = foo([R::A(()), R::B(7)]);
+}
+"#,
+ expect![[r#"
+ 153..154 'x': impl X<Item = R<impl Y + ?Sized, T>> + ?Sized
+ 190..201 '{ loop {} }': T
+ 192..199 'loop {}': !
+ 197..199 '{}': ()
+ 212..253 '{ ...)]); }': ()
+ 222..223 'a': i32
+ 226..229 'foo': fn foo<i32>([R<(), i32>; 2]) -> i32
+ 226..250 'foo([R...B(7)])': i32
+ 230..249 '[R::A(...:B(7)]': [R<(), i32>; 2]
+ 231..235 'R::A': extern "rust-call" A<(), i32>(()) -> R<(), i32>
+ 231..239 'R::A(())': R<(), i32>
+ 236..238 '()': ()
+ 241..245 'R::B': extern "rust-call" B<(), i32>(i32) -> R<(), i32>
+ 241..248 'R::B(7)': R<(), i32>
+ 246..247 '7': i32
+ "#]],
+ );
+}
+
+#[test]
fn simple_return_pos_impl_trait() {
cov_mark::check!(lower_rpit);
check_infer(