@@ -6,18 +6,11 @@ file provides an overview of the process. More detailed notes are in
6
6
the code itself, naturally.
7
7
8
8
One way to think of method lookup is that we convert an expression of
9
- the form:
9
+ the form ` receiver.method(...) ` into a more explicit [ fully-qualified syntax] [ ]
10
+ (formerly called [ UFCS] [ ] ):
10
11
11
- ``` rust,ignore
12
- receiver.method(...)
13
- ```
14
-
15
- into a more explicit [ UFCS] form:
16
-
17
- ``` rust,ignore
18
- Trait::method(ADJ(receiver), ...) // for a trait call
19
- ReceiverType::method(ADJ(receiver), ...) // for an inherent method call
20
- ```
12
+ - ` Trait::method(ADJ(receiver), ...) ` for a trait call
13
+ - ` ReceiverType::method(ADJ(receiver), ...) ` for an inherent method call
21
14
22
15
Here ` ADJ ` is some kind of adjustment, which is typically a series of
23
16
autoderefs and then possibly an autoref (e.g., ` &**receiver ` ). However
@@ -37,6 +30,7 @@ probe phase produces a "pick" (`probe::Pick`), which is designed to be
37
30
cacheable across method-call sites. Therefore, it does not include
38
31
inference variables or other information.
39
32
33
+ [ fully-qualified syntax ] : https://doc.rust-lang.org/nightly/book/ch19-03-advanced-traits.html#fully-qualified-syntax-for-disambiguation-calling-methods-with-the-same-name
40
34
[ UFCS ] : https://github.com/rust-lang/rfcs/blob/master/text/0132-ufcs.md
41
35
[ probe ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_typeck/check/method/probe/
42
36
[ confirm ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_typeck/check/method/confirm/
@@ -51,12 +45,10 @@ until it cannot be deref'd anymore, as well as applying an optional
51
45
"unsize" step. So if the receiver has type ` Rc<Box<[T; 3]>> ` , this
52
46
might yield:
53
47
54
- ``` rust,ignore
55
- Rc<Box<[T; 3]>>
56
- Box<[T; 3]>
57
- [T; 3]
58
- [T]
59
- ```
48
+ 1 . ` Rc<Box<[T; 3]>> `
49
+ 2 . ` Box<[T; 3]> `
50
+ 3 . ` [T; 3] `
51
+ 4 . ` [T] `
60
52
61
53
### Candidate assembly
62
54
@@ -99,10 +91,9 @@ So, let's continue our example. Imagine that we were calling a method
99
91
that defines it with ` &self ` for the type ` Rc<U> ` as well as a method
100
92
on the type ` Box ` that defines ` Foo ` but with ` &mut self ` . Then we
101
93
might have two candidates:
102
- ``` text
103
- &Rc<Box<[T; 3]>> from the impl of `Foo` for `Rc<U>` where `U=Box<[T; 3]>
104
- &mut Box<[T; 3]>> from the inherent impl on `Box<U>` where `U=[T; 3]`
105
- ```
94
+
95
+ - ` &Rc<Box<[T; 3]>> ` from the impl of ` Foo ` for ` Rc<U> ` where ` U=Box<[T; 3]> `
96
+ - ` &mut Box<[T; 3]>> ` from the inherent impl on ` Box<U> ` where ` U=[T; 3] `
106
97
107
98
### Candidate search
108
99
0 commit comments