diff options
author | Florian Diebold <[email protected]> | 2021-04-29 19:21:50 +0100 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2021-04-29 19:23:02 +0100 |
commit | c2aefd5b95adb9e07919a11cdfcca45de79b5324 (patch) | |
tree | e16281e3b3f694775a88b6ed39e5a37db7125183 /crates/hir_ty | |
parent | 2d20ab7eaf928dfaf3e1823707a3b6b84e918d07 (diff) |
Don't look in super traits for <T as Trait>::Assoc
This isn't actually how it works, you have to specify the exact trait
that has the associated type.
Fixes #8686.
Diffstat (limited to 'crates/hir_ty')
-rw-r--r-- | crates/hir_ty/src/lower.rs | 13 | ||||
-rw-r--r-- | 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 d01933e6b..c99dd8d0a 100644 --- a/crates/hir_ty/src/lower.rs +++ b/crates/hir_ty/src/lower.rs | |||
@@ -414,17 +414,16 @@ impl<'a> TyLoweringContext<'a> { | |||
414 | self.lower_trait_ref_from_resolved_path(trait_, resolved_segment, self_ty); | 414 | self.lower_trait_ref_from_resolved_path(trait_, resolved_segment, self_ty); |
415 | let ty = if remaining_segments.len() == 1 { | 415 | let ty = if remaining_segments.len() == 1 { |
416 | let segment = remaining_segments.first().unwrap(); | 416 | let segment = remaining_segments.first().unwrap(); |
417 | let found = associated_type_by_name_including_super_traits( | 417 | let found = self |
418 | self.db, | 418 | .db |
419 | trait_ref, | 419 | .trait_data(trait_ref.hir_trait_id()) |
420 | &segment.name, | 420 | .associated_type_by_name(&segment.name); |
421 | ); | ||
422 | match found { | 421 | match found { |
423 | Some((super_trait_ref, associated_ty)) => { | 422 | Some(associated_ty) => { |
424 | // FIXME handle type parameters on the segment | 423 | // FIXME handle type parameters on the segment |
425 | TyKind::Alias(AliasTy::Projection(ProjectionTy { | 424 | TyKind::Alias(AliasTy::Projection(ProjectionTy { |
426 | associated_ty_id: to_assoc_type_id(associated_ty), | 425 | associated_ty_id: to_assoc_type_id(associated_ty), |
427 | substitution: super_trait_ref.substitution, | 426 | substitution: trait_ref.substitution, |
428 | })) | 427 | })) |
429 | .intern(&Interner) | 428 | .intern(&Interner) |
430 | } | 429 | } |
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() { | |||
1039 | } | 1039 | } |
1040 | "#, | 1040 | "#, |
1041 | expect![[r#" | 1041 | expect![[r#" |
1042 | 144..152 'residual': R | ||
1043 | 365..366 'r': ControlFlow<B, !> | ||
1044 | 395..410 '{ ControlFlow }': ControlFlow<B, C> | ||
1045 | 397..408 'ControlFlow': ControlFlow<B, C> | ||
1046 | 424..482 '{ ...!>); }': () | ||
1047 | 430..456 'Contro...sidual': fn from_residual<ControlFlow<u32, {unknown}>, ControlFlow<u32, !>>(ControlFlow<u32, !>) -> ControlFlow<u32, {unknown}> | ||
1048 | 430..479 'Contro...2, !>)': ControlFlow<u32, {unknown}> | ||
1049 | 457..478 'Contro...32, !>': ControlFlow<u32, !> | ||
1042 | "#]], | 1050 | "#]], |
1043 | ); | 1051 | ); |
1044 | } | 1052 | } |