@@ -10,8 +10,6 @@ formatting language syntax. As a high-level summary:
10
10
* Leave the format syntax as-is.
11
11
* Remove a number of superfluous formatting traits (renaming a few in the
12
12
process).
13
- * Disallow ` expr = expr ` and ` expr op= expr ` as expressions, make them
14
- statements instead.
15
13
16
14
# Motivation
17
15
@@ -95,9 +93,21 @@ RFC](https://github.com/rust-lang/rfcs/pull/257) used `:` for the invocation
95
93
syntax rather than ` = ` as formatting does today. Additionally, today ` foo = bar `
96
94
is a valid expression, having a value of type ` () ` .
97
95
98
- Due to the possible use of ` : ` for type ascription in the future, this RFC
99
- proposes disallowing ` expr = expr ` and ` expr op= expr ` in the expression syntax,
100
- and rather adding them to the statement syntax.
96
+ With these worries, there are one of two routes that could be pursued:
97
+
98
+ 1 . The ` expr = expr ` syntax could be disallowed on the language level. This
99
+ could happen both in a total fashion or just allowing the expression
100
+ appearing as a function argument. For both cases, this will probably be
101
+ considered a "wart" of Rust's grammar.
102
+ 2 . The ` foo = bar ` syntax could be allowed in the macro with prior knowledge
103
+ that the default argument syntax for Rust, if one is ever developed, will
104
+ likely be different. This would mean that the ` foo = bar ` syntax in
105
+ formatting macros will likely be considered a wart in the future.
106
+
107
+ Given these two cases, the clear choice seems to be accepting a wart in the
108
+ formatting macros themselves. It will likely be possible to extend the macro in
109
+ the future to support whatever named argument syntax is developed as well, and
110
+ the old syntax could be accepted for some time.
101
111
102
112
## Formatting Traits
103
113
@@ -454,18 +464,8 @@ the `std::fmt` module for stabilization.
454
464
455
465
# Drawbacks
456
466
457
- For backwards compatibility, this RFC proposes removing ` a = b ` and ` a op= b ` as
458
- expressions, which makes this code (valid today) fail to compile:
459
-
460
- ``` rust
461
- match foo {
462
- _ => a = b ,
463
- }
464
- foo (| value | a = value );
465
- ```
466
-
467
- Both of these cases may be somewhat common, and this RFC would require that they
468
- be surrounded with braces and a semicolon.
467
+ Today's macro system necessitates exporting many implementation details of the
468
+ formatting system, which is unfortunate.
469
469
470
470
# Alternatives
471
471
0 commit comments