From b828a41a1a6f6d3834a311eb1fe9634825a45382 Mon Sep 17 00:00:00 2001 From: Adrian Taylor Date: Fri, 7 Feb 2025 11:52:44 +0000 Subject: [PATCH] Document incoherence. --- src/expressions/method-call-expr.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/expressions/method-call-expr.md b/src/expressions/method-call-expr.md index 95a92d1e0..521a89a8c 100644 --- a/src/expressions/method-call-expr.md +++ b/src/expressions/method-call-expr.md @@ -62,15 +62,13 @@ then the candidate types would be `&SmartPtr`, `SmartPtr` 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. @@ -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. @@ -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