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

Issue 42545 type inference regression #42659

Merged

Conversation

nikomatsakis
Copy link
Contributor

Fix an ICE that results from type inference obligations being dropped on the floor. Specifically, when computing the implied bounds, we would sometimes do normalizations that get stored in the cache, but we would not try to solve the resulting obligations. This can sometimes leave type variables uninferred. Occurs only rarely because implied bounds are processed in regionck which happens very late, so usually the cache is populated already from somewhere else.

I think that the proper fix here is probably lazy normalization. This fix is intentionally very narrow both because this code is on the chopping block and because this needs a beta backport.

r? @eddyb
cc @arielb1

@nikomatsakis nikomatsakis added beta-nominated Nominated 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. labels Jun 14, 2017
@eddyb
Copy link
Member

eddyb commented Jun 14, 2017

@bors r+

@bors
Copy link
Contributor

bors commented Jun 14, 2017

📌 Commit ef26ac3 has been approved by eddyb

@aidanhs
Copy link
Member

aidanhs commented Jun 15, 2017

@bors r-

Lots of travis failures, e.g.

[00:41:12] error: /checkout/src/test/compile-fail/coherence-impl-trait-for-trait-object-safe.rs:17: unexpected "error": '17:1: 17:37: the trait `NotObjectSafe` cannot be made into an object [E0038]'
[00:41:12] 
[00:41:12] error: 1 unexpected errors found, 0 expected errors not found
[00:41:12] status: exit code: 101
[00:41:12] command: /checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc /checkout/src/test/compile-fail/coherence-impl-trait-for-trait-object-safe.rs -L /checkout/obj/build/x86_64-unknown-linux-gnu/test/compile-fail --target=x86_64-unknown-linux-gnu --error-format json -L /checkout/obj/build/x86_64-unknown-linux-gnu/test/compile-fail/coherence-impl-trait-for-trait-object-safe.stage2-x86_64-unknown-linux-gnu.compile-fail.libaux -C prefer-dynamic -o /checkout/obj/build/x86_64-unknown-linux-gnu/test/compile-fail/coherence-impl-trait-for-trait-object-safe.stage2-x86_64-unknown-linux-gnu -Crpath -O -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers
[00:41:12] unexpected errors (from JSON output): [
[00:41:12]     Error {
[00:41:12]         line_num: 17,
[00:41:12]         kind: Some(
[00:41:12]             Error
[00:41:12]         ),
[00:41:12]         msg: "17:1: 17:37: the trait `NotObjectSafe` cannot be made into an object [E0038]"
[00:41:12]     }
[00:41:12] ]

@aidanhs aidanhs added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jun 15, 2017
@nikomatsakis
Copy link
Contributor Author

Bah. I hadn't considered all the duplicate errors. I'll see what I can do about suppressing those.

@nikomatsakis
Copy link
Contributor Author

@bors r=eddyb

@bors
Copy link
Contributor

bors commented Jun 15, 2017

📌 Commit 125968b has been approved by eddyb

@arielb1
Copy link
Contributor

arielb1 commented Jun 15, 2017

Won't 125968b have the dropck ICE again on code with type errors? Maybe skip calling regionck from wfcheck if there are type errors in https://github.com/rust-lang/rust/blob/master/src/librustc_typeck/check/wfcheck.rs#L60 - or have smarter span management so that the spans stay the same for both errors, which would get the error deduplicated.

@bors r-

@nikomatsakis
Copy link
Contributor Author

@arielb1

Won't 125968b have the dropck ICE again on code with type errors?

I don't think so, because that was one of those "delayed bug" things, where it only ICEs if an error is not reported.

have smarter span management so that the spans stay the same for both errors, which would get the error deduplicated.

Do we detect and remove duplicate errors based on span etc already? I had thought about tinkering more, but decided it was better to fix the ICE in a narrow way. Still, I could imagine looking at the obligations individually and assigning the span of the enclosing impl if they do not involve anything "local" to the function.

@arielb1
Copy link
Contributor

arielb1 commented Jun 16, 2017

@nikomatsakis

Sure. traits::error_reporting does not report duplicate and, since my PR, "implied" errors with the same span.

I don't think so, because that was one of those "delayed bug" things, where it only ICEs if an error is not reported.

Then ok. Feel free to r+, but if you can do something simple with the spans that would be best.

@nikomatsakis
Copy link
Contributor Author

Sure. traits::error_reporting does not report duplicate and, since my PR, "implied" errors with the same span.

The problem is that these errors are reported at different times, I think, and hence I'm not sure that logic will apply. That is, the one error is occurring (I believe) when we check the WF of the impl, and the other when we are checking the individual methods.

@nikomatsakis
Copy link
Contributor Author

I verified that they are in different inference contexts, so -- barring significant restructuring -- just tinkering with spans wouldn't cut it.

@nikomatsakis
Copy link
Contributor Author

@bors r=eddyb

@bors
Copy link
Contributor

bors commented Jun 16, 2017

📌 Commit 125968b has been approved by eddyb

@nikomatsakis
Copy link
Contributor Author

@bors r-

Had an idea of how to solve the remaining duplicate error problem.

@nikomatsakis nikomatsakis force-pushed the issue-42545-type-inference-regression branch from 0ab9594 to 9fec409 Compare June 17, 2017 09:40
@nikomatsakis
Copy link
Contributor Author

@bors r=eddyb

@bors
Copy link
Contributor

bors commented Jun 17, 2017

📌 Commit 9fec409 has been approved by eddyb

@bors
Copy link
Contributor

bors commented Jun 17, 2017

⌛ Testing commit 9fec409 with merge dfb8c80...

bors added a commit that referenced this pull request Jun 17, 2017
…sion, r=eddyb

Issue 42545 type inference regression

Fix an ICE that results from type inference obligations being dropped on the floor. Specifically, when computing the implied bounds, we would sometimes do normalizations that get stored in the cache, but we would *not* try to solve the resulting obligations. This can sometimes leave type variables uninferred. Occurs only rarely because implied bounds are processed in regionck which happens very late, so usually the cache is populated already from somewhere else.

I think that the *proper* fix here is probably lazy normalization. This fix is intentionally very narrow both because this code is on the chopping block and because this needs a beta backport.

r? @eddyb
cc @arielb1
@bors
Copy link
Contributor

bors commented Jun 17, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: eddyb
Pushing dfb8c80 to master...

@bors bors merged commit 9fec409 into rust-lang:master Jun 17, 2017
@brson brson added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Jun 22, 2017
@brson brson mentioned this pull request Jun 22, 2017
@alexcrichton alexcrichton removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Jun 22, 2017
bors added a commit that referenced this pull request Jun 25, 2017
[beta] backports

- #42785
- #42740
- #42735
- #42728
- #42695
- #42659
- #42634
- #42566

I just unilaterally accepted all the non-accepted nominations. Everything picked cleanly.

Still testing locally.

cc @rust-lang/compiler

r? @alexcrichton
bors added a commit that referenced this pull request Jun 25, 2017
[beta] backports

- #42785
- #42740
- #42735
- #42728
- #42695
- #42659
- #42634
- #42566

I just unilaterally accepted all the non-accepted nominations. Everything picked cleanly.

Still testing locally.

cc @rust-lang/compiler

r? @alexcrichton
bors added a commit that referenced this pull request Jun 27, 2017
[beta] backports

Reopening #42841 as a new PR due to bors flakiness.

- #42785
- #42740
- #42735
- #42728
- #42695
- #42659
- #42634
- #42566

I just unilaterally accepted all the non-accepted nominations. Everything picked cleanly.
bors added a commit that referenced this pull request Jun 27, 2017
[beta] backports

Reopening #42841 as a new PR due to bors flakiness.

- #42785
- #42740
- #42735
- #42728
- #42695
- #42659
- #42634
- #42566

I just unilaterally accepted all the non-accepted nominations. Everything picked cleanly.
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. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

7 participants