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

Fix debug assertion in typeck #72714

Merged
merged 1 commit into from
Jul 21, 2020
Merged

Fix debug assertion in typeck #72714

merged 1 commit into from
Jul 21, 2020

Conversation

JohnTitor
Copy link
Member

Fixes #72410

@rust-highfive
Copy link
Collaborator

r? @varkor

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 28, 2020
@varkor
Copy link
Member

varkor commented May 30, 2020

I'd like to see a comment explaining why this extra condition is necessary. Also, I'm not sure whether ignoring it completely is the right way to go.

r? @eddyb, who originally added this predicate.

@rust-highfive rust-highfive assigned eddyb and unassigned varkor May 30, 2020
@JohnCSimon JohnCSimon added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 6, 2020
@Elinvynia Elinvynia added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 25, 2020
@JohnTitor JohnTitor added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 30, 2020
@JohnTitor
Copy link
Member Author

My initial thought was that we could apply the same way as #72019 but yeah, now, I'm not sure if it's always true. @eddyb could you confirm this?

if bound_pred.bounds.is_empty() {
if bound_pred.bounds.is_empty() && !ty.has_escaping_bound_vars() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, this was previously changed from a WF predicate, to an outlives one?

I suspect instead of changing the condition here (which would hide e.g. where for<'a> Foo<'a>:, from WF), you just need to change the ty::Binder::dummy to ty::Binder::bind.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! That should work fine.

fn map()
where
Self: Sized,
for<'a> &'a mut [u8]: ;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have a test for a type that is not WF, which this PR would allow compiling, but we'd never want to.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we separate that test in an another file? And I'm not sure what kind of test case is appropriate.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps something like

trait Foo<'a> { }

fn map()
    where for<'a> &'a mut [dyn Foo<'a>]

which I think ought to fail because dyn Foo<'a>: Sized doesn't hold

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could add it in the same file I suppose

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Niko! Added it.

@eddyb
Copy link
Member

eddyb commented Jul 15, 2020

My initial thought was that we could apply the same way as #72019 but yeah, now, I'm not sure if it's always true. @eddyb could you confirm this?

@JohnTitor that change was in suggestion logic, whereas here it's for enforcing WF, and ICEs are preferred to unsoundness.

I left a comment with my suggestion (dummy -> bind) for making this work, I hope that works (since I didn't actually test it).

r? @nikomatsakis or @matthewjasper

@nikomatsakis
Copy link
Contributor

This looks right to me but I second the request for a test that reports an (expected) error.

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Jul 20, 2020

📌 Commit a11024f has been approved by nikomatsakis

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 20, 2020
@bors
Copy link
Contributor

bors commented Jul 20, 2020

⌛ Testing commit a11024f with merge e6f0d96fae0a2b8cd40b6df8ce54c69ddc488603...

@bors
Copy link
Contributor

bors commented Jul 20, 2020

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 20, 2020
@JohnTitor
Copy link
Member Author

Failed job (https://github.com/rust-lang-ci/rust/runs/891114144) says:

To https://github.com/pietroalbini/rust-toolstate
 ! [remote rejected] master -> master (permission denied)
error: failed to push some refs to 'https://github.com/pietroalbini/rust-toolstate'
Sleeping for 3 seconds before retrying push
From https://github.com/pietroalbini/rust-toolstate
 * branch            master     -> FETCH_HEAD
HEAD is now at 3158691 (windows CI update)
thread 'main' panicked at 'Failed to update toolstate repository with new data', src/bootstrap/toolstate.rs:447:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test check-tools
Build completed unsuccessfully in 0:00:33

Seems spurious, @bors retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 20, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 20, 2020
…arth

Rollup of 13 pull requests

Successful merges:

 - rust-lang#72714 (Fix debug assertion in typeck)
 - rust-lang#73197 (Impl Default for ranges)
 - rust-lang#73323 (wf: check foreign fn decls for well-formedness)
 - rust-lang#74051 (disallow non-static lifetimes in const generics)
 - rust-lang#74376 (test caching opt_const_param_of on disc)
 - rust-lang#74501 (Ayu theme: Use different background color for Run button)
 - rust-lang#74505 (Fix search input focus in ayu theme)
 - rust-lang#74522 (Update sanitizer docs)
 - rust-lang#74546 (Fix duplicate maybe_uninit_extra attribute)
 - rust-lang#74552 (Stabilize TAU constant.)
 - rust-lang#74555 (Improve "important traits" popup display on mobile)
 - rust-lang#74557 (Fix an ICE on an invalid `binding @ ...` in a tuple struct pattern)
 - rust-lang#74561 (update backtrace-rs)

Failed merges:

r? @ghost
@bors bors merged commit 105cd49 into rust-lang:master Jul 21, 2020
@JohnTitor JohnTitor deleted the debug-assert branch July 21, 2020 06:32
rust-timer added a commit to rust-timer/rust that referenced this pull request Jul 21, 2020
Original message:
Rollup merge of rust-lang#72714 - JohnTitor:debug-assert, r=nikomatsakis

Fix debug assertion in typeck

Fixes rust-lang#72410
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[debug assertion] thread 'rustc' panicked at 'assertion failed: !value.has_escaping_bound_vars()'
8 participants