]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #40398 - eddyb:struct-hint, r=nikomatsakis
authorCorey Farwell <coreyf@rwell.org>
Mon, 20 Mar 2017 00:51:07 +0000 (20:51 -0400)
committerGitHub <noreply@github.com>
Mon, 20 Mar 2017 00:51:07 +0000 (20:51 -0400)
Propagate expected type hints through struct literals.

Partial fix for #31260 to maximize backwards-compatibility, i.e. the hint is provided but not coerced to.

The added test works because `{...; x}` with a hint of `T` coerces `x` to `T`, and the reasoning why that is slightly different has to do with DSTs: `&Struct { tail: [x] }: &Struct<[T]>` has a hint of `[T]` for `[x]`, but the inferred type should be `[T; 1]` to succeed later, so `[x]` shouldn't be *forced* to be `[T]`.

*However*, implementing that complete behavior in a backwards-compatible way may be non-trivial, and has not yet been fully investigated, while this PR fixes #40355 and can be backported.

r? @nikomatsakis

1  2 
src/librustc_typeck/check/mod.rs

Simple merge