Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate expected type hints through struct literals. #40398

Merged
merged 2 commits into from
Mar 20, 2017

Conversation

eddyb
Copy link
Member

@eddyb eddyb commented Mar 9, 2017

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

@eddyb eddyb 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
Contributor

r=me pending crater.

@nikomatsakis
Copy link
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
Copy link
Member Author

eddyb commented Mar 9, 2017

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

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

nikomatsakis commented Mar 9, 2017

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

cc @rust-lang/compiler

@nikomatsakis nikomatsakis added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Mar 9, 2017
@brson brson mentioned this pull request Mar 9, 2017
@alexcrichton alexcrichton 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
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Mar 16, 2017

📌 Commit 50aee36 has been approved by nikomatsakis

@nikomatsakis
Copy link
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 fixes rust-lang#40355 and can be backported.

r? @nikomatsakis
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 fixes rust-lang#40355 and can be backported.

r? @nikomatsakis
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 fixes rust-lang#40355 and can be backported.

r? @nikomatsakis
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 fixes rust-lang#40355 and can be backported.

r? @nikomatsakis
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 fixes rust-lang#40355 and can be backported.

r? @nikomatsakis
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:master Mar 20, 2017
@eddyb eddyb deleted the struct-hint branch March 20, 2017 11:22
@eddyb eddyb added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Mar 20, 2017
@eddyb
Copy link
Member Author

eddyb commented Mar 20, 2017

@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).

@brson brson 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 free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel. T-compiler Relevant 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