-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
[WIP] Move pointee_info_at to TyLayoutMethods. #57150
Closed
wildarch
wants to merge
7
commits into
rust-lang:master
from
wildarch:issue-56166-miri-fntype-arg-passing
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
15955b9
Move pointee_info_at to TyLayoutMethods.
wildarch 659ffb2
Fix typo in src/librustc/ty/layout.rs
oli-obk 3d3d64f
Return instead of collecting to mut result.
wildarch e08d9cf
Remove old pointee_info_at body.
wildarch 7cba55e
Add param_env parameter to pointee_info_at.
wildarch bb05cb8
Make line fit within 100 character limit.
wildarch 3ce7a68
impl `pointee_info_at` in TyLayout.
wildarch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 realize now that this is actually an isomorphism with
Result<T, Self::Err>
.In the case of
impl<T> MaybeResult<T> for T
, thatErr
associated type would be!
, which would make both conversions total.So the existing API could be replaced with:
MaybeResult::from_ok(x)
->MaybeResult::from(Ok(x))
x.map_same(f)
->MaybeResult::from(x.to_result().map(f))
x.ok()
->x.to_result().ok()
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.
@eddyb I am a bit confused here. Does this mean I have to create two methods
from
andto_result
forMaybeResult
?And in
In this
x
should have ato_result
method. But in our caseTyLayout
has no such method.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.
from
should be astd::convert::From
impl.to_result
should be a method, yes.x
is aMaybeResult
, so it will have theto_result
method.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.
@oli-obk I am trying to implement
std::convert::From
forMaybeResult
like this:Getting some issues:
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.
oh... that was stupid of me. Sorry about that. It should suffice to add a
: From<TyLayout<'tcx>>
bound on the definition ofMaybeResult
.This will end up requiring that all implementors of
MaybeResult
also implementFrom
, not sure how well that works with theT
implThere 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.
@oli-obk
I am trying something like this:
This is the fallout:
Should we implement
From
forResult
? Does not seem right.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.
Sorry for not giving a full signature, I think I meant this:
We can't use the
From
trait becauseT
doesn't implementFrom<Result<T, !>>
(nor doesResult<T, !>
implementInto<T>
).