Skip to content

Commit

Permalink
Document incoherence.
Browse files Browse the repository at this point in the history
  • Loading branch information
adetaylor committed Feb 7, 2025
1 parent fb49894 commit b828a41
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/expressions/method-call-expr.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,13 @@ then the candidate types would be `&SmartPtr<Foo>`, `SmartPtr<Foo>` and `Foo`.
This list of candidate types is then converted to a list of candidate methods.
For each step, the candidate type is used to determine what searches to perform:

* For a struct, enum, or foreign type, there is a search for inherent
impl candidates for the type.
* For a struct, enum, foreign type, or various simpler types (listed below)
there is a search for inherent impl candidates for the type.
* For a type param, there's a search for inherent candidates on the param.
* For a trait object, there is first a search for inherent candidates for
the trait (for example in `impl Trait` blocks), then inherent impl
candidates for the trait object itself (for example found in `impl dyn Trait`
blocks)
* For various simpler types (listed below) there's a search for inherent
candidates for the incoherent type.
blocks).

After these occur, there's a further search for extension candidates for
traits in scope.
Expand Down Expand Up @@ -147,8 +145,9 @@ only the `Receiver` chain.
There are a few details not considered in this overview:

* The search for candidate methods will also consider searches for
incoherent types if `rustc_has_incoherent_inherent_impls` is active for
a `dyn`, struct, enum, or foreign type.
[incoherent] types if `rustc_has_incoherent_inherent_impls` is active for
a `dyn`, struct, enum, or foreign type. (The search for candidates for
"various simpler types" also considers incoherent implementations.)
* If there are multiple candidates from traits, they may in fact be
identical, and the picking operation collapses them to a single pick to avoid
reporting conflicts.
Expand Down Expand Up @@ -228,3 +227,4 @@ There are a few details not considered in this overview:
[`IntoIterator`]: std::iter::IntoIterator
[inherent]: ../items/implementations.md#inherent-implementations
[methods on traits]: ../items/implementations.md#trait-implementations
[incoherent]: ../items/implementations.md#trait-implementation-coherence

0 comments on commit b828a41

Please sign in to comment.