Description
rust/compiler/rustc_middle/src/ty/trait_def.rs
Lines 153 to 158 in 9b60e6c
This function iterates over all impls which may apply to self_ty
and returns the first Some
. Note that just because an impl is given to f
it may not actually apply to the whole trait_ref
(or deeply matches self_ty
). Because of this it ends up being very easy to misuse. Let's go through a few incorrect uses of this function:
rust/src/librustdoc/passes/collect_intra_doc_links.rs
Lines 738 to 763 in 9b60e6c
only looks at the first maybe applicable impl even if there are multiple, idk how exactly that function is used, but it should be wrong 😅
rust/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
Lines 2195 to 2197 in 9b60e6c
Checks whether another trait with the same path has an impl for self_ty
. Note that this emits the error message if 2 versions of a crate are used, but the substs implement neither of the traits.
whatever this is doing 😅 but this should be usable to point to an impl which doesn't actually apply.
I would like to change all the uses of find_map_relevant_impl
to instead use for_each_relevant_impl
.