-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 and test #43475 #43646
fix and test #43475 #43646
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @eddyb (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
This PR introduces a failure to |
@nikomatsakis is on vacation until Aug 15 and I'll like him to have a look on this PR, but try to fix your test failure beforehand. |
|
Hi @Twey! Do you need any help with the test failure? |
Sorry guys, I was also out sick and then on holiday the past week. Am back now and working on this. If anybody can immediately see what's causing this I'd appreciate the hint; currently adding a ton of debug information to track down where the behaviour on this test diverges. |
Back now, will try to get to this ASAP! |
…soc-ty-graph-cycle typecheck again
Think I isolated the issue; made that test pass, but I have to run, so pushing now. Hopefully works. |
src/librustc/traits/select.rs
Outdated
self.inferred_obligations.extend(obligations); | ||
|
||
let Normalized { value: normal_skol_trait_ref, obligations } = | ||
project::normalize( |
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.
I think you want to use normalize_with_depth
to avoid cycles
I'm suspicious of line 1445. Since we have an instance of the trait, surely any ‘obligations’ incurred by normalizing the trait bound are actually hypotheses. But I don't know where I could put these. |
I've removed that line since it was getting in the way of something I wanted to do, but presumably I should be doing something with those obligations. Or is it always true that it's safe to ignore them, since we have a trait bound there anyway? |
ping @nikomatsakis! pinging you on IRC too! |
Sorry for being slow. |
Can you see a bit more about how it was getting in your way? I agree we should be doing something with those obligations. I am a bit reluctant to land this PR since I am sort in the midst of trying to overhaul how we handle normalization and I worry that this will affect compilation times and so forth, but it seems like the right general idea. I think in general that we ought to be combining the obligations (rather than ignoring them...) and propagating them back out: certainly dropping them on the floor is no good. For example, the inference value may have some variables in it which are ultimately constrained by those obligations. |
AFAIUI, Anecdotally, this change doesn't seem to drastically affect compile times where it isn't required — on my machines rustc (+ stdlib) build time seems to be ~50 minutes with or without the change, though I suspect Travis could give more information to someone better able to interpret its output. |
Right, so that sorta' makes sense, but there are cases where indeed we do have to fulfill, in order to unify various variables. (That is, the result of normalization can include fresh type variables which are unconstrained except in those returned predicates.) So, as an extreme example, we might have something like: impl<T, U> Iterator for MyFoo<T>
where T: Iterator<Item = U>
{
type Item = U;
...
} Now if we have an impl that references
Do you have an example? Or did this happen when bootstrapping or something like that? |
Alas, since it didn't compile, I think I scrapped it. I'll try to build rustc with the additional obligations and do a bit of a git dive in the next few days in case I've relied on it somewhere that I can genericize into a MWE, but I can't make any promises. It was quite a finicky one involving recursively-bounded associated types. |
Managed to dig it up!
This builds with eda00c0 but overflows with a44cc9a, because the constraint |
@nikomatsakis @Twey what's the status of this PR? I'm having a hard time telling-- I started breaking out in hives when I saw |
@carols10cents I'm waiting for @nikomatsakis to respond with a better suggestion as to what to do with the incurred obligations that doesn't break correct code or a rationale as to why my counterexample actually shouldn't compile. Edit: if I understand correctly, the difference between our cases is that I want to drop bounds that are specified on the trait, but you're saying that the important bounds we want to keep arise from the impl, right? So perhaps the correct behaviour is for |
Sorry, I've been slow to respond. Partly this is because I think that the need for this PR will be obviated by some of the changes we've been planning for trait matching and selection -- in particular by the ongoing work on lazy normalization. But that branch is not yet to fruition and will probably be some time coming, so I should invest some time in thinking through this PR to see if we can take this approach in the meantime I suppose. |
ping @nikomatsakis, how's the thinking going? :) |
MWE with some extra constraints but without any feature flags, in case that makes it easier to think about:
|
Ping @rust-lang/compiler. It's now been 15 days since we last heard from @nikomatsakis. Anyone care to help think things through? |
Thank you so much for your hard work, @Twey! Unfortunately, I checked with some members of the compiler team and they believe that this PR happens to come at a bad time. It turns out that trait selection is under redesign, and it's believed that the issue at hand should be fixed by lazy normalization. Because of that, we are going to go ahead and close this. I've made a note on the original issue to make sure the test case makes its way into that eventual work. Please don't let this discourage you from making further contributions! |
I have an interest in this issue as well - is there anywhere we can follow lazy normalization work? |
Fix #43475