From c2aefd5b95adb9e07919a11cdfcca45de79b5324 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Thu, 29 Apr 2021 20:21:50 +0200 Subject: [PATCH] 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/lower.rs | 13 ++++++------- crates/hir_ty/src/tests/regression.rs | 8 ++++++++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs index d01933e6bae..c99dd8d0a46 100644 --- a/crates/hir_ty/src/lower.rs +++ b/crates/hir_ty/src/lower.rs @@ -414,17 +414,16 @@ pub(crate) fn lower_partly_resolved_path( self.lower_trait_ref_from_resolved_path(trait_, resolved_segment, self_ty); let ty = if remaining_segments.len() == 1 { let segment = remaining_segments.first().unwrap(); - let found = associated_type_by_name_including_super_traits( - self.db, - trait_ref, - &segment.name, - ); + let found = self + .db + .trait_data(trait_ref.hir_trait_id()) + .associated_type_by_name(&segment.name); match found { - Some((super_trait_ref, associated_ty)) => { + Some(associated_ty) => { // FIXME handle type parameters on the segment TyKind::Alias(AliasTy::Projection(ProjectionTy { associated_ty_id: to_assoc_type_id(associated_ty), - substitution: super_trait_ref.substitution, + substitution: trait_ref.substitution, })) .intern(&Interner) } diff --git a/crates/hir_ty/src/tests/regression.rs b/crates/hir_ty/src/tests/regression.rs index add12c6dbe9..d14f5c9bb11 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 "#]], ); } -- 2.44.0