From 184a0d7c1eb110571dc773c44a87206261fcf9ce Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Thu, 29 Apr 2021 20:00:21 +0200 Subject: Add test for #8686 --- crates/hir_ty/src/tests/regression.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'crates/hir_ty/src/tests') diff --git a/crates/hir_ty/src/tests/regression.rs b/crates/hir_ty/src/tests/regression.rs index 9cd9f473d..add12c6db 100644 --- a/crates/hir_ty/src/tests/regression.rs +++ b/crates/hir_ty/src/tests/regression.rs @@ -1012,3 +1012,33 @@ fn lifetime_from_chalk_during_deref() { "#, ) } + +#[test] +fn issue_8686() { + check_infer( + r#" +pub trait Try: FromResidual { + type Output; + type Residual; +} +pub trait FromResidual::Residual> { + fn from_residual(residual: R) -> Self; +} + +struct ControlFlow; +impl Try for ControlFlow { + type Output = C; + type Residual = ControlFlow; +} +impl FromResidual for ControlFlow { + fn from_residual(r: ControlFlow) -> Self { ControlFlow } +} + +fn test() { + ControlFlow::from_residual(ControlFlow::); +} + "#, + expect![[r#" + "#]], + ); +} -- cgit v1.2.3 From c2aefd5b95adb9e07919a11cdfcca45de79b5324 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Thu, 29 Apr 2021 20:21:50 +0200 Subject: Don't look in super traits for ::Assoc This isn't actually how it works, you have to specify the exact trait that has the associated type. Fixes #8686. --- crates/hir_ty/src/tests/regression.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'crates/hir_ty/src/tests') diff --git a/crates/hir_ty/src/tests/regression.rs b/crates/hir_ty/src/tests/regression.rs index add12c6db..d14f5c9bb 100644 --- a/crates/hir_ty/src/tests/regression.rs +++ b/crates/hir_ty/src/tests/regression.rs @@ -1039,6 +1039,14 @@ fn test() { } "#, expect![[r#" + 144..152 'residual': R + 365..366 'r': ControlFlow + 395..410 '{ ControlFlow }': ControlFlow + 397..408 'ControlFlow': ControlFlow + 424..482 '{ ...!>); }': () + 430..456 'Contro...sidual': fn from_residual, ControlFlow>(ControlFlow) -> ControlFlow + 430..479 'Contro...2, !>)': ControlFlow + 457..478 'Contro...32, !>': ControlFlow "#]], ); } -- cgit v1.2.3