Skip to content

Commit a686c04

Browse files
committed
nyaa
1 parent eecf819 commit a686c04

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

src/trait-bounds.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ r[bound.satisfaction.impl]
6464

6565
[bound.satisfaction.impl.builtin]
6666

67-
There exists impls which are automatically generated by the compiler.
67+
There exist impls which are automatically generated by the compiler.
6868

6969
- `Sized`,`Copy`, `Clone`,...
7070

src/types.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,27 @@ let a: List<i32> = List::Cons(7, Box::new(List::Cons(13, Box::new(List::Nil))));
151151

152152
## Equality of types
153153

154+
r[types.equality]
155+
154156
Equality and subtyping of types is generally structural. If the outermost type constructors are the same,
155-
the fields are pairwise related. The only exceptions from this rule are higher ranked types and alias types
157+
corresponding generic arguments are compared. The only exceptions from this rule are higher ranked types and alias types.
158+
159+
r[types.equality.aliases]
160+
161+
Aliases are compared by first normalizing them to a *rigid* type? and then equating their type constructors and recursing into their generic arguments.
162+
163+
r[types.equality.higher-ranked]
164+
165+
Function pointers and trait objects may be higher-ranked.
166+
167+
r[types.equality.higher-ranked.sub]
168+
169+
Subtyping is checked by instantiating the `for` of the subtype with inference variables and the `for` of the supertype with placeholders before relating them as normal.
170+
171+
r[types.equality.higher-ranked.eq]
156172

157-
higher ranked types:
158-
uwu, instantiate binder with placeholders, eq
173+
Equality is checked by both instantiating the `for` of the lhs with inference variables and the `for` of the rhs with placeholders before equating them, and also doing the opposite.
159174

160-
aliases
161-
normalized to a rigid type, then equated as normal
162175

163176
[Array]: types/array.md
164177
[Boolean]: types/boolean.md

src/types/alias-types.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ r[type.alias]
66

77
r[type.alias.rigid]
88

9-
Aliases might be treated as rigid in their current environment. In this case they behave like other rigid types.
9+
Aliases might be treated as *rigid* in their current environment. In this case they behave like other types.
10+
Their equality is structural, *rigid* aliases are only equal if both have the same type constructor and equal corresponding arguments.
1011

1112
r[type.alias.normalization]
1213

0 commit comments

Comments
 (0)