You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
On 2020-03-26, borrowck: prefer "value" over "_" in diagnostics #70389, written by @Centril and reviewed by @mark-i-m, landed. The PR fixed some bugs in diagnostics where we would end up using _ as the name of the place when matching on a temporary. Now it says "value" in the diagnostic instead.
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).
Back when the feature was removed, we made an explicit note that the long term intention was to reenable it.
And this is a useful coding pattern at times. (The whole reason I went looking for this issue, and then decided to file it after discovering it did not seem to exist, was because I wanted to write code that required this feature, namely a pattern like: ty::Ref(_, adt_ty @ ty::TyS { kind: ty::Adt(adt_def, _), .. }, _))
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
This is the tracking issue for
#![feature(bindings_after_at)], which allows patterns of formbinding @ patto have bindings inpat, for exampleref x @ Some(y).Implementation history
On 2019-12-24, Initial implementation of
#![feature(bindings_after_at)]#66296, containing the initial implementation, landed. The PR was written by @Centril and reviewed by @pnkfelix and @matthewjasper.On 2020-02-10, Correctly parse
mut a @ b#68992 landed. The PR was written by @matthewjasper and reviewed by @Centril. The PR fixed a parser recovery bug whereinmut x @ ywould makeya mutable binding, manifesting as issues Wrong bindings_after_at warnings #67861 and bindings_after_at: outer mutability annotation affects inner bindings #67926.On 2020-02-19, parse: recover
mut (x @ y)as(mut x @ mut y). #69236 landed. The PR was written by @Centril and reviewed by @estebank. The PR adjusted the parser changes in Correctly parsemut a @ b#68992 to retain good error messages on e.g.mut (x @ y)patterns, suggestingmut x @ mut yas opposed tomut x @ y.On 2020-03-08, test(pattern): add tests for combinations of pattern features #69690 landed. The PR was written by @thekuom and reviewed by @Centril and added run-pass tests for the combination of bindings-after-at, or-patterns, box-patterns, slice-patterns.
On 2020-03-08, test(bindings_after_at): add dynamic drop tests for bindings_after_at #69810 landed. The PR was written by @thekuom and reviewed by @Centril and added dynamic-rop run-pass tests for bindings-after-at.
On 2020-03-10, test(patterns): add patterns feature tests to borrowck test suite #69817, written by @thekuom and reviewed by @Centril, landed. The PR added borrow checker tests in combination with or-patterns & other pattern features.
On 2020-03-26, borrowck: prefer "value" over "
_" in diagnostics #70389, written by @Centril and reviewed by @mark-i-m, landed. The PR fixed some bugs in diagnostics where we would end up using_as the name of the place when matching on a temporary. Now it says "value" in the diagnostic instead.Old description
Pre-1.0 Rust used to support writing code like:
PR #16053 disabled the ability to write such code. More precisely, it disabled the ability to introduce any kind of binding in subpattern
Pin the context of any binding-patternident @ PThe 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).
ty::Ref(_, adt_ty @ ty::TyS { kind: ty::Adt(adt_def, _), .. }, _))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