From 82fe1c77b592d7b42b38ae9ebea76489cdfd7a2b Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Thu, 3 Mar 2022 18:32:40 +0100 Subject: [PATCH] Add a (currently failing) test for #11242 --- crates/hir_ty/src/infer/coerce.rs | 2 ++ crates/hir_ty/src/tests/regression.rs | 31 +++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/crates/hir_ty/src/infer/coerce.rs b/crates/hir_ty/src/infer/coerce.rs index c24772f29b4..528e3ba8827 100644 --- a/crates/hir_ty/src/infer/coerce.rs +++ b/crates/hir_ty/src/infer/coerce.rs @@ -555,8 +555,10 @@ impl<'a> InferenceContext<'a> { ); } Solution::Ambig(Guidance::Definite(subst)) => { + // FIXME need to record an obligation here canonicalized.apply_solution(&mut self.table, subst) } + // FIXME actually we maybe should also accept unknown guidance here _ => return Err(TypeError), }; let unsize = diff --git a/crates/hir_ty/src/tests/regression.rs b/crates/hir_ty/src/tests/regression.rs index 812f12acede..b17e517ccb0 100644 --- a/crates/hir_ty/src/tests/regression.rs +++ b/crates/hir_ty/src/tests/regression.rs @@ -1267,3 +1267,34 @@ fn test() { "#]], ); } + +#[test] +fn bug_11242() { + // FIXME: wrong, should be u32 + check_types( + r#" +fn foo() +where + A: IntoIterator, + B: IntoIterator, +{ + let _x: ::Item; + // ^^ {unknown} +} + +pub trait Iterator { + type Item; +} + +pub trait IntoIterator { + type Item; + type IntoIter: Iterator; +} + +impl IntoIterator for I { + type Item = I::Item; + type IntoIter = I; +} +"#, + ); +}