-
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
Introduce trait engine #49202
Introduce trait engine #49202
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nikomatsakis (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. |
3e8979d
to
d442a98
Compare
fn pending_obligations(&self) -> Vec<PendingPredicateObligation<'tcx>>; | ||
} | ||
|
||
impl<'a, 'gcx, 'tcx> dyn TraitEngine<'tcx> { |
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.
This needs to be:
impl<'a, 'gcx, 'tcx> dyn TraitEngine<'tcx> + 'tcx {
..
}
Whenever you create a trait object type dyn Trait
, if that trait object may close over references, then the lifetime of those references needs to be part of its bound. In this case, FulfillmentContext
closes over data of type with lifetime 'tcx
, so we need dyn TraitEngine<'tcx> + 'tcx
.
src/librustc/traits/engine.rs
Outdated
} | ||
|
||
impl<'a, 'gcx, 'tcx> dyn TraitEngine<'tcx> +'tcx { | ||
pub fn new(_tcx: TyCtxt<'_, '_, 'tcx>) -> Box<Self + 'tcx> |
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.
This needs to be Box<Self>
or Box<dyn TraitEngine<'tcx> +'tcx>
Here, Self
= dyn TraitEngine<'tcx> + tcx
(that is a single type). It might be mildly clearer formatted like so dyn (TraitEngine<'tcx> + tcx)
. That is, it is a dynamic type (not statically known) that implements TraitEngine<'tcx>
and which outlives 'tcx
(i.e., meets the bound TraitEngine<'tcx> + 'tcx
).
@nikomatsakis
The main code modification was already done a week ago, but I have been being trapped here. I have tried many ways to resolve the lifetime, but they never works. |
@csmoe ok that was trickier than I thought :) I pushed various commits. |
Let's see what travis thinks. |
☔ The latest upstream changes (presumably #49264) made this pull request unmergeable. Please resolve the merge conflicts. |
This way, we don't have to repeat it.
The use of tcx/gcx in this function is subtle.
This helps to make clear where *global* lifetimes are needed in `coerce_unsized_info`
@bors r+ |
📌 Commit 39712e5 has been approved by |
Sorry for the delay, was waiting until travis was happy =) |
⌛ Testing commit 39712e5 with merge 6b50e0fc7ac915609d9821865cb191aea128e9ac... |
💔 Test failed - status-travis |
@bors retry 3 hour time-out in
|
@bors p=15 |
⌛ Testing commit 39712e5 with merge 83bcdc9af15af7b689ceba0e1772e037dc546c85... |
💔 Test failed - status-travis |
@bors retry Spuriously canceled ¿❓⸮❔😕?❓❔ |
Introduce trait engine address #48895 step 1: introduce trait engine
☀️ Test successful - status-appveyor, status-travis |
address #48895 step 1: introduce trait engine