Skip to content

Commit 712673c

Browse files
committed
Make structural displayable without state
1 parent 9db7bdd commit 712673c

7 files changed

+130
-90
lines changed

src/rulesets/ty_based.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -436,10 +436,8 @@ impl RuleOptions {
436436

437437
/// Purely structural matching, with no match ergonomics.
438438
pub const STRUCTURAL: Self = RuleOptions {
439-
match_constructor_through_ref: false,
440-
ref_binding_on_inherited: RefBindingOnInheritedBehavior::Error,
441-
mut_binding_on_inherited: MutBindingOnInheritedBehavior::Error,
442439
inherited_ref_on_ref: InheritedRefOnRefBehavior::Error,
440+
match_constructor_through_ref: false,
443441
allow_ref_pat_on_ref_mut: false,
444442
eat_inherited_ref_alone: false,
445443
eat_mut_inside_shared: false,
@@ -448,6 +446,8 @@ impl RuleOptions {
448446

449447
/// The minimal amout of match ergonomics that's forward-compatible with most proposals.
450448
pub const MIN_ERGONOMICS: Self = RuleOptions {
449+
ref_binding_on_inherited: RefBindingOnInheritedBehavior::Error,
450+
mut_binding_on_inherited: MutBindingOnInheritedBehavior::Error,
451451
match_constructor_through_ref: true,
452452
..Self::STRUCTURAL
453453
};

tests/snapshots/[email protected]

+8-8
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ info:
1111
simplify_deref_mut: true
1212
downgrade_mut_inside_shared: false
1313
eat_mut_inside_shared: false
14-
ref_binding_on_inherited: Error
15-
mut_binding_on_inherited: Error
14+
ref_binding_on_inherited: AllocTemporary
15+
mut_binding_on_inherited: Keep
1616
---
1717
p0 @ e.0: T0, p1 @ e.1: T1
1818
--------------------------- "Constructor"
@@ -27,17 +27,17 @@ p @ *e: T
2727
&mut p @ e: &mut T
2828

2929
x @ &e: &T
30-
---------------------------------- "BindingBorrow"
31-
ref x @ e: T, e is not a reference
30+
------------ "BindingBorrow"
31+
ref x @ e: T
3232

3333
x @ &mut e: &mut T
34-
-------------------------------------- "BindingBorrow"
35-
ref mut x @ e: T, e is not a reference
34+
------------------ "BindingBorrow"
35+
ref mut x @ e: T
3636

3737

3838
-------- "Binding"
3939
x @ e: T
4040

4141

42-
---------------------------------- "Binding"
43-
mut x @ e: T, e is not a reference
42+
------------ "Binding"
43+
mut x @ e: T

tests/snapshots/[email protected]

+8-8
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ info:
1111
simplify_deref_mut: true
1212
downgrade_mut_inside_shared: false
1313
eat_mut_inside_shared: false
14-
ref_binding_on_inherited: Error
15-
mut_binding_on_inherited: Error
14+
ref_binding_on_inherited: AllocTemporary
15+
mut_binding_on_inherited: Keep
1616
---
1717
movep0: T0, movep1: T1
1818
----------------------------- "Constructor"
@@ -27,17 +27,17 @@ move ⊢ p: T
2727
move&mut p: &mut T
2828

2929
refx: T
30-
--------------- "BindingBorrow"
31-
moveref x: T
30+
------------- "BindingBorrow"
31+
bmref x: T
3232

3333
ref mutx: T
34-
------------------- "BindingBorrow"
35-
moveref mut x: T
34+
----------------- "BindingBorrow"
35+
bmref mut x: T
3636

3737

3838
--------- "Binding"
3939
bmx: T
4040

4141

42-
--------------- "Binding"
43-
movemut x: T
42+
------------- "Binding"
43+
bmmut x: T

tests/snapshots/[email protected]

+21-21
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,33 @@ info:
1111
simplify_deref_mut: true
1212
downgrade_mut_inside_shared: false
1313
eat_mut_inside_shared: false
14-
ref_binding_on_inherited: Error
15-
mut_binding_on_inherited: Error
14+
ref_binding_on_inherited: AllocTemporary
15+
mut_binding_on_inherited: Keep
1616
---
17-
realp0: T0, real p1: T1
18-
----------------------------- "Constructor"
19-
_[p0, p1]: [T0, T1]
17+
p0: T0, p1: T1
18+
------------------ "Constructor"
19+
[p0, p1]: [T0, T1]
2020

21-
realp: T
22-
----------- "Deref"
23-
r&p: &T
21+
p: T
22+
------ "Deref"
23+
&p: &T
2424

25-
realp: T
26-
------------------ "Deref"
27-
r&mut p: &mut T
25+
p: T
26+
-------------- "Deref"
27+
&mut p: &mut T
2828

29-
inhx: &T
30-
--------------- "BindingBorrow"
31-
realref x: T
29+
x: &T
30+
-------- "BindingBorrow"
31+
ref x: T
3232

33-
inhx: &mut T
34-
------------------- "BindingBorrow"
35-
realref mut x: T
33+
x: &mut T
34+
------------ "BindingBorrow"
35+
ref mut x: T
3636

3737

38-
-------- "Binding"
39-
rx: T
38+
---- "Binding"
39+
x: T
4040

4141

42-
--------------- "Binding"
43-
realmut x: T
42+
-------- "Binding"
43+
mut x: T

tests/snapshots/[email protected]

+50-26
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,21 @@ The old ruleset is on the left, and the new one on the right.
3434
----------------- "DerefMutWithShared" |
3535
r, m&p: &mut T |
3636

37-
|
38-
------------------ "Binding" |
39-
inh, mmut x: &T |
37+
| inh, mx: &&T
38+
| ------------------ "BindingBorrow"
39+
| inh, mref x: &T
4040

41-
|
42-
---------------------- "Binding" |
43-
inh, mmut x: &mut T |
41+
| inh, mx: &&mut T
42+
| ---------------------- "BindingBorrow"
43+
| inh, mref x: &mut T
44+
45+
| inh, mx: &mut &T
46+
| ---------------------- "BindingBorrow"
47+
| inh, mref mut x: &T
48+
49+
| inh, mx: &mut &mut T
50+
| -------------------------- "BindingBorrow"
51+
| inh, mref mut x: &mut T
4452

4553

4654
allow_ref_pat_on_ref_mut: true -> false
@@ -50,8 +58,8 @@ eat_mut_inside_shared: true -> false
5058
fallback_to_outer: "No"
5159
inherited_ref_on_ref: "EatOuter" -> "Error"
5260
match_constructor_through_ref: true -> false
53-
mut_binding_on_inherited: "Keep" -> "Error"
54-
ref_binding_on_inherited: "Error"
61+
mut_binding_on_inherited: "Keep"
62+
ref_binding_on_inherited: "Error" -> "AllocTemporary"
5563
simplify_deref_mut: true
5664
Current and saved rulesets were swapped
5765
The two rulesets are described by the following sets of rules, with differences highlighted.
@@ -85,13 +93,21 @@ The old current ruleset is on the left, and the new current one on the right.
8593
| ----------------- "DerefMutWithShared"
8694
| r, m&p: &mut T
8795

88-
|
89-
| ------------------ "Binding"
90-
| inh, mmut x: &T
96+
inh, mx: &&T |
97+
------------------ "BindingBorrow" |
98+
inh, mref x: &T |
9199

92-
|
93-
| ---------------------- "Binding"
94-
| inh, mmut x: &mut T
100+
inh, mx: &&mut T |
101+
---------------------- "BindingBorrow" |
102+
inh, mref x: &mut T |
103+
104+
inh, mx: &mut &T |
105+
---------------------- "BindingBorrow" |
106+
inh, mref mut x: &T |
107+
108+
inh, mx: &mut &mut T |
109+
-------------------------- "BindingBorrow" |
110+
inh, mref mut x: &mut T |
95111

96112

97113
allow_ref_pat_on_ref_mut: false -> true
@@ -101,8 +117,8 @@ eat_mut_inside_shared: false -> true
101117
fallback_to_outer: "No"
102118
inherited_ref_on_ref: "Error" -> "EatOuter"
103119
match_constructor_through_ref: false -> true
104-
mut_binding_on_inherited: "Error" -> "Keep"
105-
ref_binding_on_inherited: "Error"
120+
mut_binding_on_inherited: "Keep"
121+
ref_binding_on_inherited: "AllocTemporary" -> "Error"
106122
simplify_deref_mut: true
107123
Comparing against the saved ruleset. Use `unsave` to forget the saved ruleset.
108124
The two rulesets are described by the following sets of rules, with differences highlighted.
@@ -152,22 +168,30 @@ The current ruleset is on the left, and the saved one on the right.
152168
------------------ "BindingBorrow" | ------------------ "BindingBorrow"
153169
real, mref x: T | real, mref x: T
154170

171+
| inh, mx: &&T
172+
| ------------------ "BindingBorrow"
173+
| inh, mref x: &T
174+
175+
| inh, mx: &&mut T
176+
| ---------------------- "BindingBorrow"
177+
| inh, mref x: &mut T
178+
155179
inh, mx: &mut T | inh, mx: &mut T
156180
---------------------- "BindingBorrow" | ---------------------- "BindingBorrow"
157181
real, mref mut x: T | real, mref mut x: T
158182

159-
|
160-
----------- "Binding" | ----------- "Binding"
161-
r, mx: T | r, mx: T
183+
| inh, mx: &mut &T
184+
| ---------------------- "BindingBorrow"
185+
| inh, mref mut x: &T
162186

163-
|
164-
------------------ "Binding" | ------------------ "Binding"
165-
real, mmut x: T | real, mmut x: T
187+
| inh, mx: &mut &mut T
188+
| -------------------------- "BindingBorrow"
189+
| inh, mref mut x: &mut T
166190

167191
|
168-
------------------ "Binding" |
169-
inh, mmut x: &T |
192+
----------- "Binding" | ----------- "Binding"
193+
r, mx: T | r, mx: T
170194

171195
|
172-
---------------------- "Binding" |
173-
inh, mmut x: &mut T |
196+
--------------- "Binding" | --------------- "Binding"
197+
r, mmut x: T | r, mmut x: T

tests/snapshots/[email protected]

+22-14
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,21 @@ The old ruleset is on the left, and the new one on the right.
3333
----------------- "DerefMutWithShared" |
3434
r, m&p: &mut T |
3535

36-
|
37-
------------------ "Binding" |
38-
inh, mmut x: &T |
36+
| inh, mx: &&T
37+
| ------------------ "BindingBorrow"
38+
| inh, mref x: &T
3939

40-
|
41-
---------------------- "Binding" |
42-
inh, mmut x: &mut T |
40+
| inh, mx: &&mut T
41+
| ---------------------- "BindingBorrow"
42+
| inh, mref x: &mut T
43+
44+
| inh, mx: &mut &T
45+
| ---------------------- "BindingBorrow"
46+
| inh, mref mut x: &T
47+
48+
| inh, mx: &mut &mut T
49+
| -------------------------- "BindingBorrow"
50+
| inh, mref mut x: &mut T
4351

4452

4553
allow_ref_pat_on_ref_mut: true -> false
@@ -49,8 +57,8 @@ eat_mut_inside_shared: true -> false
4957
fallback_to_outer: "No"
5058
inherited_ref_on_ref: "EatOuter" -> "Error"
5159
match_constructor_through_ref: true -> false
52-
mut_binding_on_inherited: "Keep" -> "Error"
53-
ref_binding_on_inherited: "Error"
60+
mut_binding_on_inherited: "Keep"
61+
ref_binding_on_inherited: "Error" -> "AllocTemporary"
5462
simplify_deref_mut: true
5563
The current options can be fully described as the following set of rules.
5664
The typing predicate looks like `r, m ⊢ p: T`, where
@@ -72,17 +80,17 @@ real, m ⊢ p: T
7280
r, m&mut p: &mut T
7381

7482
inh, mx: &T
75-
------------------ "BindingBorrow"
76-
real, mref x: T
83+
--------------- "BindingBorrow"
84+
r, mref x: T
7785

7886
inh, mx: &mut T
79-
---------------------- "BindingBorrow"
80-
real, mref mut x: T
87+
------------------- "BindingBorrow"
88+
r, mref mut x: T
8189

8290

8391
----------- "Binding"
8492
r, mx: T
8593

8694

87-
------------------ "Binding"
88-
real, mmut x: T
95+
--------------- "Binding"
96+
r, mmut x: T

tests/snapshots/[email protected]

+18-10
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,21 @@ The old ruleset is on the left, and the new one on the right.
3434
----------------- "DerefMutWithShared" |
3535
r, m&p: &mut T |
3636

37-
|
38-
------------------ "Binding" |
39-
inh, mmut x: &T |
37+
| inh, mx: &&T
38+
| ------------------ "BindingBorrow"
39+
| inh, mref x: &T
4040

41-
|
42-
---------------------- "Binding" |
43-
inh, mmut x: &mut T |
41+
| inh, mx: &&mut T
42+
| ---------------------- "BindingBorrow"
43+
| inh, mref x: &mut T
44+
45+
| inh, mx: &mut &T
46+
| ---------------------- "BindingBorrow"
47+
| inh, mref mut x: &T
48+
49+
| inh, mx: &mut &mut T
50+
| -------------------------- "BindingBorrow"
51+
| inh, mref mut x: &mut T
4452

4553

4654
allow_ref_pat_on_ref_mut: true -> false
@@ -50,8 +58,8 @@ eat_mut_inside_shared: true -> false
5058
fallback_to_outer: "No"
5159
inherited_ref_on_ref: "EatOuter" -> "Error"
5260
match_constructor_through_ref: true -> false
53-
mut_binding_on_inherited: "Keep" -> "Error"
54-
ref_binding_on_inherited: "Error"
61+
mut_binding_on_inherited: "Keep"
62+
ref_binding_on_inherited: "Error" -> "AllocTemporary"
5563
simplify_deref_mut: true
5664
Comparing against the saved ruleset. Use `unsave` to forget the saved ruleset.
5765
The current ruleset is on the left, and the saved one on the right.
@@ -62,6 +70,6 @@ eat_mut_inside_shared: false -> true
6270
fallback_to_outer: "No"
6371
inherited_ref_on_ref: "Error" -> "EatOuter"
6472
match_constructor_through_ref: false -> true
65-
mut_binding_on_inherited: "Error" -> "Keep"
66-
ref_binding_on_inherited: "Error"
73+
mut_binding_on_inherited: "Keep"
74+
ref_binding_on_inherited: "AllocTemporary" -> "Error"
6775
simplify_deref_mut: true

0 commit comments

Comments
 (0)