-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Conversation
r? @varkor (rust_highfive has picked a reviewer for you, use r? to override) |
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. |
src/librustc_typeck/collect.rs
Outdated
if bound_pred.bounds.is_empty() { | ||
if bound_pred.bounds.is_empty() && !ty.has_escaping_bound_vars() { |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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]: ; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Niko! Added it.
@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 ( r? @nikomatsakis or @matthewjasper |
This looks right to me but I second the request for a test that reports an (expected) error. |
@bors r+ |
📌 Commit a11024f has been approved by |
⌛ Testing commit a11024f with merge e6f0d96fae0a2b8cd40b6df8ce54c69ddc488603... |
💔 Test failed - checks-actions |
Failed job (https://github.com/rust-lang-ci/rust/runs/891114144) says:
Seems spurious, @bors retry |
…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
Original message: Rollup merge of rust-lang#72714 - JohnTitor:debug-assert, r=nikomatsakis Fix debug assertion in typeck Fixes rust-lang#72410
Fixes #72410