rust/compiler/rustc_ast/src
Jonas Schievink f66af28641
Rollup merge of #79016 - fanzier:underscore-expressions, r=petrochenkov
Make `_` an expression, to discard values in destructuring assignments

This is the third and final step towards implementing destructuring assignment (RFC: rust-lang/rfcs#2909, tracking issue: #71126). This PR is the third and final part of #71156, which was split up to allow for easier review.

With this PR, an underscore `_` is parsed as an expression but is allowed *only* on the left-hand side of a destructuring assignment. There it simply discards a value, similarly to the wildcard `_` in patterns. For instance,
```rust
(a, _) = (1, 2)
```
will simply assign 1 to `a` and discard the 2. Note that for consistency,
```
_ = foo
```
is also allowed and equivalent to just `foo`.

Thanks to ````@varkor```` who helped with the implementation, particularly around pre-expansion gating.

r? ````@petrochenkov````
2020-11-15 13:39:48 +01:00
..
ast
attr Auto merge of #78782 - petrochenkov:nodoctok, r=Aaron1011 2020-11-12 00:33:55 +00:00
expand
util Auto merge of #78066 - bugadani:wat, r=jonas-schievink 2020-10-18 13:50:31 +00:00
ast.rs Add underscore expressions for destructuring assignments 2020-11-14 13:53:12 +00:00
crate_disambiguator.rs
entry.rs
lib.rs tidy 2020-09-23 22:08:30 +02:00
mut_visit.rs Add underscore expressions for destructuring assignments 2020-11-14 13:53:12 +00:00
node_id.rs The renumber pass is long gone 2020-11-06 03:18:01 +01:00
ptr.rs
token.rs Suggest expressions that look like const generic arguments should be enclosed in brackets 2020-10-26 21:54:45 +00:00
tokenstream.rs Reserve space in advance 2020-11-13 11:19:25 +01:00
visit.rs Add underscore expressions for destructuring assignments 2020-11-14 13:53:12 +00:00