Skip to content

Commit 60b1720

Browse files
chorman0773ehuss
authored andcommitted
Add identifier syntax to call-expr
1 parent 9446598 commit 60b1720

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/expressions/call-expr.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
11
# Call expressions
22

3+
r[expr.call]
4+
5+
r[expr.call.syntax]
36
> **<sup>Syntax</sup>**\
47
> _CallExpression_ :\
58
> &nbsp;&nbsp; [_Expression_] `(` _CallParams_<sup>?</sup> `)`
69
>
710
> _CallParams_ :\
811
> &nbsp;&nbsp; [_Expression_]&nbsp;( `,` [_Expression_] )<sup>\*</sup> `,`<sup>?</sup>
912
13+
r[expr.call.intro]
1014
A *call expression* calls a function.
1115
The syntax of a call expression is an expression, called the *function operand*, followed by a parenthesized comma-separated list of expression, called the *argument operands*.
16+
17+
r[expr.call.convergence]
1218
If the function eventually returns, then the expression completes.
1319

20+
r[expr.call.trait]
1421
For [non-function types], the expression `f(...)` uses the method on one of the following traits based on the function operand:
1522

1623
- [`Fn`] or [`AsyncFn`] --- shared reference.
1724
- [`FnMut`] or [`AsyncFnMut`] --- mutable reference.
1825
- [`FnOnce`] or [`AsyncFnOnce`] --- value.
1926

27+
r[expr.call.autoref-deref]
2028
An automatic borrow will be taken if needed.
2129
The function operand will also be [automatically dereferenced] as required.
2230

@@ -30,20 +38,27 @@ let name: &'static str = (|| "Rust")();
3038

3139
## Disambiguating Function Calls
3240

41+
r[expr.call.desugar]
42+
43+
r[expr.call.desugar.fully-qualified]
3344
All function calls are sugar for a more explicit [fully-qualified syntax].
45+
46+
r[expr.call.desugar.ambiguity]
3447
Function calls may need to be fully qualified, depending on the ambiguity of a call in light of in-scope items.
3548

3649
> **Note**: In the past, the terms "Unambiguous Function Call Syntax", "Universal Function Call Syntax", or "UFCS", have been used in documentation, issues, RFCs, and other community writings.
3750
> However, these terms lack descriptive power and potentially confuse the issue at hand.
3851
> We mention them here for searchability's sake.
3952
53+
r[expr.call.desugar.limits]
4054
Several situations often occur which result in ambiguities about the receiver or referent of method or associated function calls.
4155
These situations may include:
4256

4357
* Multiple in-scope traits define methods with the same name for the same types
4458
* Auto-`deref` is undesirable; for example, distinguishing between methods on a smart pointer itself and the pointer's referent
4559
* Methods which take no arguments, like [`default()`], and return properties of a type, like [`size_of()`]
4660

61+
r[expr.call.desugar.explicit-path]
4762
To resolve the ambiguity, the programmer may refer to their desired method or function using more specific paths, types, or traits.
4863

4964
For example,

0 commit comments

Comments
 (0)