Skip to content

Propagate expected type hints through struct literals. - #40398

Merged
bors merged 2 commits into
rust-lang:masterfrom
eddyb:struct-hint
Mar 20, 2017
Merged

Propagate expected type hints through struct literals.#40398
bors merged 2 commits into
rust-lang:masterfrom
eddyb:struct-hint

Conversation

@eddyb

@eddybeddyb commented Mar 9, 2017

Copy link
Copy Markdown
Contributor

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

@eddybeddyb added beta-nominated Nominated for backporting to the compiler in the beta channel. S-waiting-on-crater Status: Waiting on a crater run to be completed. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 9, 2017
@nikomatsakis

Copy link
Copy Markdown
Contributor

r=me pending crater.

@nikomatsakis

Copy link
Copy Markdown
Contributor

We discussed this in the @rust-lang/compiler meeting. It's a tough call regarding the backport. On the one hand, we definitely want to fix the bug, and it affects anybody using the phf crate to some degree. On the other hand, changes to inference are notoriously sensitive, and so we risk unintended side-effects.

Let's see what crater has to say (a clean run would help allay fears) before reaching a final decision.

@eddyb

eddyb commented Mar 9, 2017

Copy link
Copy Markdown
ContributorAuthor

Crater report only contains false positives (network errors, I think)!

@nikomatsakisnikomatsakis removed the S-waiting-on-crater Status: Waiting on a crater run to be completed. label Mar 9, 2017
@nikomatsakis

nikomatsakis commented Mar 9, 2017

Copy link
Copy Markdown
Contributor

OK, we're marking as beta-accepted. Live on the edge!

cc @rust-lang/compiler

@nikomatsakisnikomatsakis added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Mar 9, 2017
@brsonbrson mentioned this pull request Mar 9, 2017
@alexcrichtonalexcrichton removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Mar 9, 2017
bors added a commit that referenced this pull request Mar 9, 2017
@nikomatsakis

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Mar 16, 2017

Copy link
Copy Markdown
Collaborator

📌 Commit 50aee36 has been approved by nikomatsakis

@nikomatsakis

Copy link
Copy Markdown
Contributor

Looks like this was never formally r+'d?

frewsxcv added a commit to frewsxcv/rust that referenced this pull request Mar 17, 2017
Propagate expected type hints through struct literals.
Partial fix for rust-lang#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 fixesrust-lang#40355 and can be backported.
r? @nikomatsakis
@frewsxcvfrewsxcv mentioned this pull request Mar 17, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Mar 17, 2017
Propagate expected type hints through struct literals.
Partial fix for rust-lang#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 fixesrust-lang#40355 and can be backported.
r? @nikomatsakis
@frewsxcvfrewsxcv mentioned this pull request Mar 17, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Mar 18, 2017
Propagate expected type hints through struct literals.
Partial fix for rust-lang#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 fixesrust-lang#40355 and can be backported.
r? @nikomatsakis
@frewsxcvfrewsxcv mentioned this pull request Mar 18, 2017
arielb1 pushed a commit to arielb1/rust that referenced this pull request Mar 18, 2017
Propagate expected type hints through struct literals.
Partial fix for rust-lang#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 fixesrust-lang#40355 and can be backported.
r? @nikomatsakis
@arielb1arielb1 mentioned this pull request Mar 18, 2017
bors added a commit that referenced this pull request Mar 18, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Mar 20, 2017
Propagate expected type hints through struct literals.
Partial fix for rust-lang#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 fixesrust-lang#40355 and can be backported.
r? @nikomatsakis
@frewsxcvfrewsxcv mentioned this pull request Mar 20, 2017
bors added a commit that referenced this pull request Mar 20, 2017
Rollup of 9 pull requests
- Successful merges: #40241, #40281, #40398, #40521, #40532, #40554, #40566, #40581, #40587
- Failed merges:
@bors
bors merged commit 50aee36 into rust-lang:masterMar 20, 2017
@eddyb
eddyb deleted the struct-hint branch March 20, 2017 11:22
@eddybeddyb added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Mar 20, 2017
@eddyb

Copy link
Copy Markdown
ContributorAuthor

@nikomatsakis@brson If this made it into the stable release but wasn't merged on nightly, it might be missing from beta. I'll re-nominate it to make sure we don't forget to check (and backport if needed).

@brsonbrson added beta-accepted Accepted for backporting to the compiler in the beta channel. and removed beta-accepted Accepted for backporting to the compiler in the beta channel. beta-nominated Nominated for backporting to the compiler in the beta channel. labels Mar 20, 2017
bors added a commit that referenced this pull request Mar 20, 2017
[beta] Backports and version bump
This PR backports these PRs to beta:
* #40583
* #40398
* #40542
and it also includes a version bump to push out a beta with all recent backports.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beta-acceptedAccepted for backporting to the compiler in the beta channel.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crate with large static map in external crate fails to compile

5 participants

@eddyb@nikomatsakis@bors@alexcrichton@brson