Skip to content

Commit

Permalink
Make structural displayable without state
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadrieril committed Jan 18, 2025
1 parent 9db7bdd commit 712673c
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 90 deletions.
6 changes: 3 additions & 3 deletions src/rulesets/ty_based.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,10 +436,8 @@ impl RuleOptions {

/// Purely structural matching, with no match ergonomics.
pub const STRUCTURAL: Self = RuleOptions {
match_constructor_through_ref: false,
ref_binding_on_inherited: RefBindingOnInheritedBehavior::Error,
mut_binding_on_inherited: MutBindingOnInheritedBehavior::Error,
inherited_ref_on_ref: InheritedRefOnRefBehavior::Error,
match_constructor_through_ref: false,
allow_ref_pat_on_ref_mut: false,
eat_inherited_ref_alone: false,
eat_mut_inside_shared: false,
Expand All @@ -448,6 +446,8 @@ impl RuleOptions {

/// The minimal amout of match ergonomics that's forward-compatible with most proposals.
pub const MIN_ERGONOMICS: Self = RuleOptions {
ref_binding_on_inherited: RefBindingOnInheritedBehavior::Error,
mut_binding_on_inherited: MutBindingOnInheritedBehavior::Error,
match_constructor_through_ref: true,
..Self::STRUCTURAL
};
Expand Down
16 changes: 8 additions & 8 deletions tests/snapshots/bundle_rules@structural-Expression.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ info:
simplify_deref_mut: true
downgrade_mut_inside_shared: false
eat_mut_inside_shared: false
ref_binding_on_inherited: Error
mut_binding_on_inherited: Error
ref_binding_on_inherited: AllocTemporary
mut_binding_on_inherited: Keep
---
p0 @ e.0: T0, p1 @ e.1: T1
--------------------------- "Constructor"
Expand All @@ -27,17 +27,17 @@ p @ *e: T
&mut p @ e: &mut T

x @ &e: &T
---------------------------------- "BindingBorrow"
ref x @ e: T, e is not a reference
------------ "BindingBorrow"
ref x @ e: T

x @ &mut e: &mut T
-------------------------------------- "BindingBorrow"
ref mut x @ e: T, e is not a reference
------------------ "BindingBorrow"
ref mut x @ e: T


-------- "Binding"
x @ e: T


---------------------------------- "Binding"
mut x @ e: T, e is not a reference
------------ "Binding"
mut x @ e: T
16 changes: 8 additions & 8 deletions tests/snapshots/bundle_rules@structural-SequentInMemory.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ info:
simplify_deref_mut: true
downgrade_mut_inside_shared: false
eat_mut_inside_shared: false
ref_binding_on_inherited: Error
mut_binding_on_inherited: Error
ref_binding_on_inherited: AllocTemporary
mut_binding_on_inherited: Keep
---
movep0: T0, movep1: T1
----------------------------- "Constructor"
Expand All @@ -27,17 +27,17 @@ move ⊢ p: T
move&mut p: &mut T

refx: T
--------------- "BindingBorrow"
moveref x: T
------------- "BindingBorrow"
bmref x: T

ref mutx: T
------------------- "BindingBorrow"
moveref mut x: T
----------------- "BindingBorrow"
bmref mut x: T


--------- "Binding"
bmx: T


--------------- "Binding"
movemut x: T
------------- "Binding"
bmmut x: T
42 changes: 21 additions & 21 deletions tests/snapshots/bundle_rules@structural-SequentUserVisible.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,33 @@ info:
simplify_deref_mut: true
downgrade_mut_inside_shared: false
eat_mut_inside_shared: false
ref_binding_on_inherited: Error
mut_binding_on_inherited: Error
ref_binding_on_inherited: AllocTemporary
mut_binding_on_inherited: Keep
---
realp0: T0, real p1: T1
----------------------------- "Constructor"
_[p0, p1]: [T0, T1]
p0: T0, p1: T1
------------------ "Constructor"
[p0, p1]: [T0, T1]

realp: T
----------- "Deref"
r&p: &T
p: T
------ "Deref"
&p: &T

realp: T
------------------ "Deref"
r&mut p: &mut T
p: T
-------------- "Deref"
&mut p: &mut T

inhx: &T
--------------- "BindingBorrow"
realref x: T
x: &T
-------- "BindingBorrow"
ref x: T

inhx: &mut T
------------------- "BindingBorrow"
realref mut x: T
x: &mut T
------------ "BindingBorrow"
ref mut x: T


-------- "Binding"
rx: T
---- "Binding"
x: T


--------------- "Binding"
realmut x: T
-------- "Binding"
mut x: T
76 changes: 50 additions & 26 deletions tests/snapshots/trace_cli@10939586865865297633.snap
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,21 @@ The old ruleset is on the left, and the new one on the right.
----------------- "DerefMutWithShared" |
r, m&p: &mut T |

|
------------------ "Binding" |
inh, mmut x: &T |
| inh, mx: &&T
| ------------------ "BindingBorrow"
| inh, mref x: &T

|
---------------------- "Binding" |
inh, mmut x: &mut T |
| inh, mx: &&mut T
| ---------------------- "BindingBorrow"
| inh, mref x: &mut T

| inh, mx: &mut &T
| ---------------------- "BindingBorrow"
| inh, mref mut x: &T

| inh, mx: &mut &mut T
| -------------------------- "BindingBorrow"
| inh, mref mut x: &mut T


allow_ref_pat_on_ref_mut: true -> false
Expand All @@ -50,8 +58,8 @@ eat_mut_inside_shared: true -> false
fallback_to_outer: "No"
inherited_ref_on_ref: "EatOuter" -> "Error"
match_constructor_through_ref: true -> false
mut_binding_on_inherited: "Keep" -> "Error"
ref_binding_on_inherited: "Error"
mut_binding_on_inherited: "Keep"
ref_binding_on_inherited: "Error" -> "AllocTemporary"
simplify_deref_mut: true
Current and saved rulesets were swapped
The two rulesets are described by the following sets of rules, with differences highlighted.
Expand Down Expand Up @@ -85,13 +93,21 @@ The old current ruleset is on the left, and the new current one on the right.
| ----------------- "DerefMutWithShared"
| r, m&p: &mut T

|
| ------------------ "Binding"
| inh, mmut x: &T
inh, mx: &&T |
------------------ "BindingBorrow" |
inh, mref x: &T |

|
| ---------------------- "Binding"
| inh, mmut x: &mut T
inh, mx: &&mut T |
---------------------- "BindingBorrow" |
inh, mref x: &mut T |

inh, mx: &mut &T |
---------------------- "BindingBorrow" |
inh, mref mut x: &T |

inh, mx: &mut &mut T |
-------------------------- "BindingBorrow" |
inh, mref mut x: &mut T |


allow_ref_pat_on_ref_mut: false -> true
Expand All @@ -101,8 +117,8 @@ eat_mut_inside_shared: false -> true
fallback_to_outer: "No"
inherited_ref_on_ref: "Error" -> "EatOuter"
match_constructor_through_ref: false -> true
mut_binding_on_inherited: "Error" -> "Keep"
ref_binding_on_inherited: "Error"
mut_binding_on_inherited: "Keep"
ref_binding_on_inherited: "AllocTemporary" -> "Error"
simplify_deref_mut: true
Comparing against the saved ruleset. Use `unsave` to forget the saved ruleset.
The two rulesets are described by the following sets of rules, with differences highlighted.
Expand Down Expand Up @@ -152,22 +168,30 @@ The current ruleset is on the left, and the saved one on the right.
------------------ "BindingBorrow" | ------------------ "BindingBorrow"
real, mref x: T | real, mref x: T

| inh, mx: &&T
| ------------------ "BindingBorrow"
| inh, mref x: &T

| inh, mx: &&mut T
| ---------------------- "BindingBorrow"
| inh, mref x: &mut T

inh, mx: &mut T | inh, mx: &mut T
---------------------- "BindingBorrow" | ---------------------- "BindingBorrow"
real, mref mut x: T | real, mref mut x: T

|
----------- "Binding" | ----------- "Binding"
r, mx: T | r, mx: T
| inh, mx: &mut &T
| ---------------------- "BindingBorrow"
| inh, mref mut x: &T

|
------------------ "Binding" | ------------------ "Binding"
real, mmut x: T | real, mmut x: T
| inh, mx: &mut &mut T
| -------------------------- "BindingBorrow"
| inh, mref mut x: &mut T

|
------------------ "Binding" |
inh, mmut x: &T |
----------- "Binding" | ----------- "Binding"
r, mx: T | r, mx: T

|
---------------------- "Binding" |
inh, mmut x: &mut T |
--------------- "Binding" | --------------- "Binding"
r, mmut x: T | r, mmut x: T
36 changes: 22 additions & 14 deletions tests/snapshots/trace_cli@14439240379964399004.snap
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,21 @@ The old ruleset is on the left, and the new one on the right.
----------------- "DerefMutWithShared" |
r, m&p: &mut T |

|
------------------ "Binding" |
inh, mmut x: &T |
| inh, mx: &&T
| ------------------ "BindingBorrow"
| inh, mref x: &T

|
---------------------- "Binding" |
inh, mmut x: &mut T |
| inh, mx: &&mut T
| ---------------------- "BindingBorrow"
| inh, mref x: &mut T

| inh, mx: &mut &T
| ---------------------- "BindingBorrow"
| inh, mref mut x: &T

| inh, mx: &mut &mut T
| -------------------------- "BindingBorrow"
| inh, mref mut x: &mut T


allow_ref_pat_on_ref_mut: true -> false
Expand All @@ -49,8 +57,8 @@ eat_mut_inside_shared: true -> false
fallback_to_outer: "No"
inherited_ref_on_ref: "EatOuter" -> "Error"
match_constructor_through_ref: true -> false
mut_binding_on_inherited: "Keep" -> "Error"
ref_binding_on_inherited: "Error"
mut_binding_on_inherited: "Keep"
ref_binding_on_inherited: "Error" -> "AllocTemporary"
simplify_deref_mut: true
The current options can be fully described as the following set of rules.
The typing predicate looks like `r, m ⊢ p: T`, where
Expand All @@ -72,17 +80,17 @@ real, m ⊢ p: T
r, m&mut p: &mut T

inh, mx: &T
------------------ "BindingBorrow"
real, mref x: T
--------------- "BindingBorrow"
r, mref x: T

inh, mx: &mut T
---------------------- "BindingBorrow"
real, mref mut x: T
------------------- "BindingBorrow"
r, mref mut x: T


----------- "Binding"
r, mx: T


------------------ "Binding"
real, mmut x: T
--------------- "Binding"
r, mmut x: T
28 changes: 18 additions & 10 deletions tests/snapshots/trace_cli@5650066042996044784.snap
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,21 @@ The old ruleset is on the left, and the new one on the right.
----------------- "DerefMutWithShared" |
r, m&p: &mut T |

|
------------------ "Binding" |
inh, mmut x: &T |
| inh, mx: &&T
| ------------------ "BindingBorrow"
| inh, mref x: &T

|
---------------------- "Binding" |
inh, mmut x: &mut T |
| inh, mx: &&mut T
| ---------------------- "BindingBorrow"
| inh, mref x: &mut T

| inh, mx: &mut &T
| ---------------------- "BindingBorrow"
| inh, mref mut x: &T

| inh, mx: &mut &mut T
| -------------------------- "BindingBorrow"
| inh, mref mut x: &mut T


allow_ref_pat_on_ref_mut: true -> false
Expand All @@ -50,8 +58,8 @@ eat_mut_inside_shared: true -> false
fallback_to_outer: "No"
inherited_ref_on_ref: "EatOuter" -> "Error"
match_constructor_through_ref: true -> false
mut_binding_on_inherited: "Keep" -> "Error"
ref_binding_on_inherited: "Error"
mut_binding_on_inherited: "Keep"
ref_binding_on_inherited: "Error" -> "AllocTemporary"
simplify_deref_mut: true
Comparing against the saved ruleset. Use `unsave` to forget the saved ruleset.
The current ruleset is on the left, and the saved one on the right.
Expand All @@ -62,6 +70,6 @@ eat_mut_inside_shared: false -> true
fallback_to_outer: "No"
inherited_ref_on_ref: "Error" -> "EatOuter"
match_constructor_through_ref: false -> true
mut_binding_on_inherited: "Error" -> "Keep"
ref_binding_on_inherited: "Error"
mut_binding_on_inherited: "Keep"
ref_binding_on_inherited: "AllocTemporary" -> "Error"
simplify_deref_mut: true

0 comments on commit 712673c

Please sign in to comment.