]> git.lizzy.rs Git - rust.git/commit
auto merge of #20083 : eddyb/rust/fix-expectation, r=nikomatsakis
authorbors <bors@rust-lang.org>
Tue, 23 Dec 2014 18:01:22 +0000 (18:01 +0000)
committerbors <bors@rust-lang.org>
Tue, 23 Dec 2014 18:01:22 +0000 (18:01 +0000)
commitd10642ef0f8976b9fb08500acdff84e3990815fa
tree2e033ae0f1781402df8bb60b458f1f63b6c0432e
parent658529467d9d69ac9e09cacf98a6d61d781c2c76
parentadabf4e63d6b1d33b045aa5078b12dec3693c574
auto merge of #20083 : eddyb/rust/fix-expectation, r=nikomatsakis

This fixes a few corner cases with expected type propagation, e.g.:
```rust
fn take_int_slice(_: &[int]) {}
take_int_slice(&if 1 < 0 { [ 0, 1 ] } else { [ 0, 1 ] });
```
```rust
<anon>:2:28: 2:36 error: mismatched types: expected `[int]`, found `[int, ..2]`
<anon>:2 take_int_slice(&if 1 < 0 { [ 0, 1 ] } else { [ 0, 1 ] });
                                    ^~~~~~~~
<anon>:2:46: 2:54 error: mismatched types: expected `[int]`, found `[int, ..2]`
<anon>:2 take_int_slice(&if 1 < 0 { [ 0, 1 ] } else { [ 0, 1 ] });
                                                      ^~~~~~~~
```
Right now we unpack the expected `&[int]` and pass down `[int]`, forcing
rvalue expressions to take unsized types, which causes mismatch errors.
Instead, I replaced that expectation with a weaker hint, for the unsized
cases - a hint is still required to infer the integer literals' types, above.

Fixes #20169.