Tracking issue for bindings in sub-patterns after @s (feature(bindings_after_at)) · Issue #65490 · rust-lang/rust (original) (raw)

This is the tracking issue for #![feature(bindings_after_at)], which allows patterns of form binding @ pat to have bindings in pat, for example ref x @ Some(y).

Implementation history

Old description

Pre-1.0 Rust used to support writing code like:

match x { y @ z => { ... } }

match a { b @ Some(c) => { ... } }

PR #16053 disabled the ability to write such code. More precisely, it disabled the ability to introduce any kind of binding in subpattern P in the context of any binding-pattern ident @ P

The reason we did this was because it was too hard to handle them soundly in the AST-borrowck.

However, now that we have migrated 100% to NLL and thus MIR-borrowck, we should be able to soundly re-enable this feature, without too much effort (I hope).

Note that any attempt to re-enable the feature should do a careful survey of the various cases that can arise (copying, moving, mixing ref and non-ref, match ergonomics, ...)

Also, any attempt to re-enable the feature should also attempt to re-add all the tests that were removed with PR #16053