Commit fdcb77b
committed
types: remove one calls to ResolvedType::as_inner
Our goal is to reduce/eliminate the places outside of the `types` module
that use the `TypeInner` type, since this is (ideally) an implementation
detail of `ResolvedType`.
There aren't a lot of these places, it turns out. This commit removes
one "easy" one, in pattern.rs. There, previously we were matching arrays
and using a wildcard _ match to return an error on mismatches. By adding
a bit of code repetiton (the 'return error' line 3 times) and calling
TypeDestructible::as_list and as_array, we can get rid of the wildcard
match, which eliminates the `TypeInner` but also is more robust against
extensions to the Pattern enum.
This leaves the use in ast.rs in `cast_preserves_enum_identity` which
seems quite difficult to remove correctly (the existing code is not
correct either, but ok, let's leave it alone unless we can fix it
completely). We want to make this nonrecursive and correct, but it will
have to wait for a later PR.
Aside from that, the only parts of the code, outside the ResolvedType
module itself, that now need to know the internals of ResolvedType are
in value.rs. Since the structure of Value mirrors the structure of
ResolvedType probably we will just have to live with this; when we
change the representation of ResolvedType we will need to make parallel
changes in value.rs.1 parent f00b08f commit fdcb77b
1 file changed
Lines changed: 22 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
55 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
59 | | - | |
| 60 | + | |
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
65 | | - | |
66 | | - | |
67 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
68 | 73 | | |
69 | | - | |
70 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
71 | 84 | | |
72 | | - | |
73 | 85 | | |
74 | 86 | | |
75 | 87 | | |
| |||
0 commit comments