-
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
Object safe for dispatch #57545
Object safe for dispatch #57545
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. |
5c2fd5a
to
18a3376
Compare
@withoutboats PR is up :) |
This comment has been minimized.
This comment has been minimized.
18a3376
to
90718ea
Compare
This comment has been minimized.
This comment has been minimized.
90718ea
to
c516035
Compare
@bovinebuddha I'm sorry for not getting back to you in all this time! It's been a very busy couple of weeks. I've added it to my calendar to review on Monday Jan 28, so hopefully that will help. |
This comment has been minimized.
This comment has been minimized.
@nikomatsakis It's alright, I get gather you've got quite a full schedule. Just excited that its finally getting reviewed. |
c516035
to
667042e
Compare
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.
OK, I did a first pass. The code seems very nice.
I left myself some notes for next time. I want to come back and re-read the RFC a bit. I also wanted to reconsider some potential interactions with other parts of the trait system.
(I've scheduled a slot in my calendar for this on this coming Friday.)
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
667042e
to
c30d624
Compare
This comment has been minimized.
This comment has been minimized.
c30d624
to
936794d
Compare
} else { | ||
return; | ||
} | ||
} |
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.
Is the check for the feature flag necessary here? It seems like you could check if the trait is object safe anyway, even if the feature is not enabled. Or would that result in duplicate errors?
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 believe this is the code which adds the automatic 'impl Trait for dyn Trait' predicate to trait objects. Maybe the branches should be clarified and a comment added. Like:
// If we should add the automatic 'impl Trait for dyn Trait' or not
let object_impl_trait = !self.infcx.tcx.features().object_safe_for_dispatch ||
self.tcx().is_object_safe(principal.def_id());
if (object_impl_trait) {
principal.with_self_ty(self.tcx(), self_ty)
} else {
return;
}
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.
At minimum, a comment would be good here -- I think I vaguely prefer the if object_impl_trait { .. }
version as well.
But a comment like this would be great:
// Prior to RFC 2027, dyn Foo: Foo
was always true. But RFC 2027 makes that only true if Foo
is object safe.
About the feature name: I know it comes from the RFC, but to me the feature is more general than just allowing static dispatch on |
I also didn't really like using the RFC name for the feature. I suggested something like 'symmetric_object_safety' but I think your name might be more to the point? |
This comment has been minimized.
This comment has been minimized.
936794d
to
666ca6f
Compare
This comment has been minimized.
This comment has been minimized.
@nikomatsakis you can review this now (before new conflicts arise 😄 ) |
Your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem. Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
I'm not sure what the problem is here-- I see no problem locally |
@bors r+ I'm going to guess that this error is spurious somehow. |
📌 Commit ef5acde has been approved by |
🌲 The tree is currently closed for pull requests below priority 1000, this pull request will be tested once the tree is reopened |
Using this as a canary to check infra status; @bors p=1001 |
…atsakis Object safe for dispatch cc #43561
Your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem. Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
💔 Test failed - checks-azure |
@bors retry p=1 |
…atsakis Object safe for dispatch cc #43561
☀️ Test successful - checks-azure |
@nikomatsakis once this is stabilized, we remove this hacky code from object_safety.rs rust/src/librustc/traits/object_safety.rs Line 558 in 8318ef2
In that code, we substitute in |
@mikeyhew Can you extend the FIXME? |
cc #43561