about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser/pat.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-07-29 16:59:45 +0000
committerbors <bors@rust-lang.org>2023-07-29 16:59:45 +0000
commit70757fbdd76565563a2311db393459899a38b40f (patch)
tree0131c3978d38c522f8349a812c29e9025dafa161 /compiler/rustc_parse/src/parser/pat.rs
parent186fe5327e4f7b17bd03f9125a34697562c00c30 (diff)
parent53f0cb4b8a0055b13db9fbf645b8370769490b0d (diff)
downloadrust-70757fbdd76565563a2311db393459899a38b40f.tar.gz
rust-70757fbdd76565563a2311db393459899a38b40f.zip
Auto merge of #2993 - Vanille-N:tb-protector, r=RalfJung
TB: Redefine trigger condition for protectors

The Coq formalization revealed that as currently implemented, read accesses did not always commute.
Indeed starting from a lazily initialized `Active` protected tag, applying a foreign read then a child read produces `Frozen`, but child read then foreign read triggers UB (because the child read initializes _before_ the `Active -> Frozen`).

This reformulation of when protectors trigger fixes that issue:
- instead of `Active + foreign read -> Frozen` and `Active -> Frozen` when protected is UB
- we do `Active + foreign read -> if protected { Disabled } else { Frozen }`

There is already precedent for transitions being dependent on the presence of a protector (`Reserved + foreign read -> if protected { Frozen } else { Reserved }`), and this has the nice side-effect of simplifying the protector trigger condition to just an equality check against `Disabled` since now there is protector UB iff a protected tag becomes `Disabled`.

In order not to introduce an extra `if`, it was decided that `Disabled -> Disabled` would be UB when protected, which was not the case previously. This is merely a theoretical for now because a protected `Disabled` is unreachable in the first place.

The extra test is not directly related to this modification, but also checks things related to protectors and lazy initialization.
Diffstat (limited to 'compiler/rustc_parse/src/parser/pat.rs')
0 files changed, 0 insertions, 0 deletions