Skip to content

Commit 07a9739

Browse files
committed
Allow expr = expr to be an expression.
1 parent 65c2106 commit 07a9739

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

active/0000-stabilize-std-fmt.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ formatting language syntax. As a high-level summary:
1010
* Leave the format syntax as-is.
1111
* Remove a number of superfluous formatting traits (renaming a few in the
1212
process).
13-
* Disallow `expr = expr` and `expr op= expr` as expressions, make them
14-
statements instead.
1513

1614
# Motivation
1715

@@ -95,9 +93,21 @@ RFC](https://github.com/rust-lang/rfcs/pull/257) used `:` for the invocation
9593
syntax rather than `=` as formatting does today. Additionally, today `foo = bar`
9694
is a valid expression, having a value of type `()`.
9795

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.
101111

102112
## Formatting Traits
103113

@@ -454,18 +464,8 @@ the `std::fmt` module for stabilization.
454464

455465
# Drawbacks
456466

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.
469469

470470
# Alternatives
471471

0 commit comments

Comments
 (0)