Skip to content

Commit d9fc1a1

Browse files
Havvyldm0
authored andcommitted
Cleanup expected type interaction in LUB coercions
1 parent f13f494 commit d9fc1a1

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/type-coercions.md

+4-6
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,10 @@ special situation where we can get `LubCoerce(ty0, ty1) == Some(ty2)`:
256256
`LubCoerce((FnDef | Closure), (FnDef | Closure)) == Some(FnPtr)` (where Closure
257257
is non-capturing). You can check it with the pseudo code.
258258

259-
It also worth mentioning code below compiles if and only if
260-
`LubCoerce(Ty, typeof(a), typeof(b)).is_some()`:
259+
When an expression that performs LUB coercion has an expected type, the
260+
expected type is added to the list of types the coercion operates on. So,
261+
for example, in each of the following let statements, the coercion being
262+
performed is `LubCoerce(Ty, typeof(a), typeof(b))`.
261263

262264
```rust
263265
# #[derive(Clone, Copy)]
@@ -277,10 +279,6 @@ let bar: Ty = match true {
277279
let baz: [Ty; 2] = [a, b];
278280
```
279281

280-
That's because with expected type, the compiler checks
281-
`LubCoerce(expected, ty0, ty1, ty2...).is_some()` rather than
282-
`LubCoerce(ty0, ty1, ty2...) == expected`.
283-
284282
[array literal expressions]: expressions/array-expr.md
285283
[if expressions]: expressions/if-expr.md
286284
[match]: expressions/match-expr.md

0 commit comments

Comments
 (0)