Skip to content

Commit 66308ef

Browse files
ehusstraviscross
authored andcommitted
Rename question mark operator
This renames the "question mark operator" section to the "try propagation expression", and also drops the grammar name "error propagation expression". The "error propagation expression" isn't really accurate, since `?` isn't just for errors. The intent is to describe the expression by what it does (as most other expressions do) instead of how it looks. It also felt a little awkward to call it the "question mark expression".
1 parent 2f408f9 commit 66308ef

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/expressions/operator-expr.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ r[expr.operator.syntax]
66
OperatorExpression ->
77
BorrowExpression
88
| DereferenceExpression
9-
| ErrorPropagationExpression
9+
| TryPropagationExpression
1010
| NegationExpression
1111
| ArithmeticOrLogicalExpression
1212
| ComparisonExpression
@@ -190,15 +190,18 @@ assert_eq!(*y, 11);
190190
```
191191

192192
r[expr.try]
193-
## The question mark operator
193+
## The try propagation expression
194194

195195
r[expr.try.syntax]
196196
```grammar,expressions
197-
ErrorPropagationExpression -> Expression `?`
197+
TryPropagationExpression -> Expression `?`
198198
```
199199

200200
r[expr.try.intro]
201-
The question mark operator (`?`) unwraps valid values or returns erroneous values, propagating them to the calling function.
201+
The try propagation operator (`?`) unwraps valid values or returns erroneous values, propagating them to the calling function.
202+
203+
> [!NOTE]
204+
> The try propagation operator is sometimes called *the question mark operator*, *the `?` operator*, or *the try operator*.
202205
203206
r[expr.try.restricted-types]
204207
It is a unary postfix operator that can only be applied to the types `Result<T, E>` and `Option<T>`.
@@ -913,6 +916,7 @@ Like assignment expressions, compound assignment expressions always produce [the
913916
(function() {
914917
var fragments = {
915918
"#slice-dst-pointer-to-pointer-cast": "operator-expr.html#pointer-to-pointer-cast",
919+
"#the-question-mark-operator": "operator-expr.html#the-try-propagation-expression",
916920
};
917921
var target = fragments[window.location.hash];
918922
if (target) {

src/tokens.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ usages and meanings are defined in the linked pages.
907907
| `<-` | LArrow | The left arrow symbol has been unused since before Rust 1.0, but it is still treated as a single token
908908
| `#` | Pound | [Attributes]
909909
| `$` | Dollar | [Macros]
910-
| `?` | Question | [Question mark operator][question], [Questionably sized][sized], [Macro Kleene Matcher][macros]
910+
| `?` | Question | [Try propagation expressions][question], [Questionably sized][sized], [Macro Kleene Matcher][macros]
911911
| `~` | Tilde | The tilde operator has been unused since before Rust 1.0, but its token may still be used
912912

913913
r[lex.token.delim]
@@ -1064,7 +1064,7 @@ r[lex.token.reserved-guards.edition2024]
10641064
[paths]: paths.md
10651065
[patterns]: patterns.md
10661066
[placeholder lifetime]: lifetime-elision.md
1067-
[question]: expressions/operator-expr.md#the-question-mark-operator
1067+
[question]: expressions/operator-expr.md#the-try-propagation-expression
10681068
[range]: expressions/range-expr.md
10691069
[rangepat]: patterns.md#range-patterns
10701070
[raw pointers]: types/pointer.md#raw-pointers-const-and-mut

0 commit comments

Comments
 (0)