Skip to content

Commit 6702df1

Browse files
committed
For E0223, suggest associated functions that are similar to the path, even if there are multiple inherent impls to check.
1 parent b2728d5 commit 6702df1

File tree

1 file changed

+6
-4
lines changed
  • compiler/rustc_hir_analysis/src/hir_ty_lowering

1 file changed

+6
-4
lines changed

compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -999,11 +999,13 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
999999
..
10001000
}) = node
10011001
&& let Some(adt_def) = qself_ty.ty_adt_def()
1002-
&& let [inherent_impl] = tcx.inherent_impls(adt_def.did())
1003-
&& let name = format!("{ident2}_{ident3}")
1002+
&& let name = Symbol::intern(&format!("{ident2}_{ident3}"))
10041003
&& let Some(ty::AssocItem { kind: ty::AssocKind::Fn, .. }) = tcx
1005-
.associated_items(inherent_impl)
1006-
.filter_by_name_unhygienic(Symbol::intern(&name))
1004+
.inherent_impls(adt_def.did())
1005+
.iter()
1006+
.flat_map(|inherent_impl| {
1007+
tcx.associated_items(inherent_impl).filter_by_name_unhygienic(name)
1008+
})
10071009
.next()
10081010
{
10091011
Err(struct_span_code_err!(self.dcx(), span, E0223, "ambiguous associated type")

0 commit comments

Comments
 (0)