Skip to content

Commit c2aefd5

Browse files
committed
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.
1 parent 2d20ab7 commit c2aefd5

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

crates/hir_ty/src/lower.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -414,17 +414,16 @@ impl<'a> TyLoweringContext<'a> {
414414
self.lower_trait_ref_from_resolved_path(trait_, resolved_segment, self_ty);
415415
let ty = if remaining_segments.len() == 1 {
416416
let segment = remaining_segments.first().unwrap();
417-
let found = associated_type_by_name_including_super_traits(
418-
self.db,
419-
trait_ref,
420-
&segment.name,
421-
);
417+
let found = self
418+
.db
419+
.trait_data(trait_ref.hir_trait_id())
420+
.associated_type_by_name(&segment.name);
422421
match found {
423-
Some((super_trait_ref, associated_ty)) => {
422+
Some(associated_ty) => {
424423
// FIXME handle type parameters on the segment
425424
TyKind::Alias(AliasTy::Projection(ProjectionTy {
426425
associated_ty_id: to_assoc_type_id(associated_ty),
427-
substitution: super_trait_ref.substitution,
426+
substitution: trait_ref.substitution,
428427
}))
429428
.intern(&Interner)
430429
}

crates/hir_ty/src/tests/regression.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,14 @@ fn test() {
10391039
}
10401040
"#,
10411041
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, !>
10421050
"#]],
10431051
);
10441052
}

0 commit comments

Comments
 (0)