@@ -62,11 +62,11 @@ then the candidate types would be `&SmartPtr<Foo>`, `SmartPtr<Foo>` and `Foo`.
62
62
This list of candidate types is then converted to a list of candidate methods.
63
63
For each step, the candidate type is used to determine what searches to perform:
64
64
65
- * For a trait object, there is first a search for inherent candidates for
66
- the object, then inherent impl candidates for the type.
67
65
* For a struct, enum, or foreign type, there is a search for inherent
68
66
impl candidates for the type.
69
67
* For a type param, there's a search for inherent candidates on the param.
68
+ * For a trait object, there is first a search for inherent candidates for
69
+ the object, then inherent impl candidates for the type.
70
70
* For various simpler types (listed below) there's a search for inherent
71
71
candidates for the incoherent type.
72
72
@@ -76,10 +76,14 @@ traits in scope.
76
76
"Various simpler types" currently means bool, char, all numbers, str, array,
77
77
slices, raw pointers, references, never and tuple.
78
78
79
+ "Inherent" means a candidate method that can be identified just from
80
+ the signature. For example, the ` impl ` blocks corresponding to a struct
81
+ or a trait. "Extension" means a candidate gathered by considering the
82
+ traits in scope.
83
+
79
84
These searches contribute to list of all the candidate methods found;
80
- separate lists are maintained for inherent and extension candidates
81
- (that is, applicable candidates from traits). Only [ visible] candidates
82
- are included.
85
+ separate lists are maintained for the inherent and extension candidates.
86
+ Only [ visible] candidates are included.
83
87
84
88
## Picking a method from the candidates
85
89
@@ -95,21 +99,21 @@ For each step, picking is attempted in this order:
95
99
96
100
* First, a by-value method, where the ` self ` type precisely matches
97
101
* First for inherent methods
98
- * Then for extension (trait) methods
102
+ * Then for extension methods
99
103
* Then, a method where ` self ` is received by immutable reference (` &T ` )
100
104
* First for inherent methods
101
- * Then for extension (trait) methods
105
+ * Then for extension methods
102
106
* Then, a method where ` self ` is received by mutable reference (` &mut T ` )
103
107
* First for inherent methods
104
- * Then for extension (trait) methods
108
+ * Then for extension methods
105
109
* Then, a method where the ` self ` type is a ` *const T ` - this is only considered
106
110
if the self type is ` *mut T `
107
111
* First for inherent methods
108
- * Then for extension (trait) methods
112
+ * Then for extension methods
109
113
* And finally, a method with a ` Pin ` that's reborrowed, if the ` pin_ergonomics `
110
114
feature is enabled.
111
115
* First for inherent methods
112
- * Then for extension (trait) methods
116
+ * Then for extension methods
113
117
114
118
For each of those searches, if exactly one candidate is identified,
115
119
it's picked, and the search stops. If this results in multiple possible candidates,
0 commit comments