Finish stabilization of result_ffi_guarantees
by workingjubilee · Pull Request #130628 · rust-lang/rust (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation61 Commits5 Checks6 Files changed
Conversation
This file contains hidden or 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
[ Show hidden characters]({{ revealButtonHref }})
The internal linting has been changed, so all that is left is making sure we stabilize what we want to stabilize.
Closes #110503
cc @ehuss @Lokathor
r? @BoxyUwU
rustbot has assigned @BoxyUwU.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.
Use r?
to explicitly pick a reviewer
rustbot added S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
Relevant to the compiler team, which will review and decide on the PR/issue.
labels
workingjubilee added S-blocked
Status: Blocked on something else such as an RFC or other implementation work.
and removed S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels
This comment was marked as resolved.
@@ -1,3 +1,4 @@ |
---|
//@ build-pass |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a test for your own custom result-like type here to ensure that it's not special cased to Result
?
additionally, do we have tests that guarantee that, you know, this guarantee actually holds for various examples? would be good to have them :)
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The RFC does not actually extend beyond Result, actually.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well then improper_ctypes is implemented incorrectly, because it allows all result-like enums. the comment above the feature declaration also says result-like
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy to write more tests anyways, mind.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, we'd need to make sure what we actually want to guarantee before writing tests or changing the lint^^
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well then improper_ctypes is implemented incorrectly, because it allows all result-like enums. the comment above the feature declaration also says result-like
Hm.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i have been informed and see in the code that it also allows all option-like enums so... yolo?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The feature description should certainly at least be correct here.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic about "Option-like types" is ooooold, it exists at least Since Rust 1.5 where it got moved in this PR.
(There's also a "FIXME: This duplicates code in trans" there, which still exists, and which I have no idea if it is still true -- it is unclear to me where that duplicate code would be and what it would do.)
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the original logic for recognizing Option-like types was added when the lint was originally implemented, in 25f9534. It was just always carried over since then.
So... I think for Result
we don't want this, we want to specifically recognize that type. And probably for Option
, too, but that's a different PR.
@ehuss has raised the concern that the documentation updates are unfinished.
To repeat my answer in the issue, I think if std's Result docs are correct1, then that should be fine for now. The Reference docs are lagging and work is being done to catch up, but doesn't need to block anything here.
Footnotes
- Though it seems like those docs were missing a caveat that the ABI was not guaranteed for FFI, which I would expect this PR to then remove. ↩
current TODOs:
- I want to write another test for sizedness checking of some types, at least
Correct feature description- Update std docs for
fn(...T) -> R
: https://doc.rust-lang.org/stable/std/primitive.fn.html#abi-compatibility - Fix comment
- ??? stabilization report???
rustbot added S-waiting-on-author
Status: This is awaiting some action (such as code changes or more information) from the author.
and removed S-blocked
Status: Blocked on something else such as an RFC or other implementation work.
labels
Relevant to the language team, which will review and decide on the PR/issue.
and removed T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
labels
@rfcbot fcp merge
This completes stabilization of RFC 3391, which guarantees the layout of Option<T>
, Result<T, ()>
, and Result<(), T>
where T
is a nonzero type like Nonnull
, function pointer, etc. to be the same as the underlying type.
These semantics were already documented prematurely without lang FCP in #124870. The effect of this RFC appears to be to stop linting on such types in extern "C"
fn declarations as not being FFI safe.
This FCP serves as signoff that we are fine with fully stabilizing the RFC.
@rustbot label I-lang-nominated
Team member @tmandry has proposed to merge this. The next step is review by the rest of the tagged team members:
No concerns currently listed.
Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!
cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns.
See this document for info about what commands tagged team members can give me.
I'm happy-enough to just let that land.
Since I should rewrite the layout test to use the rustc_abi
dump attribute anyways:
@bors r=RalfJung
📌 Commit 7baf066 has been approved by RalfJung
It is now in the queue for this repository.
bors added S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
and removed S-waiting-on-author
Status: This is awaiting some action (such as code changes or more information) from the author.
labels
Finished benchmarking commit (3e33bda): comparison URL.
Overall result: ✅ improvements - no action needed
@rustbot label: -perf-regression
Instruction count
This is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
mean | range | count | |
---|---|---|---|
Regressions ❌ (primary) | - | - | 0 |
Regressions ❌ (secondary) | - | - | 0 |
Improvements ✅ (primary) | - | - | 0 |
Improvements ✅ (secondary) | -0.5% | [-0.5%, -0.5%] | 2 |
All ❌✅ (primary) | - | - | 0 |
Max RSS (memory usage)
Results (secondary 3.7%)
This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
mean | range | count | |
---|---|---|---|
Regressions ❌ (primary) | - | - | 0 |
Regressions ❌ (secondary) | 3.7% | [3.7%, 3.7%] | 1 |
Improvements ✅ (primary) | - | - | 0 |
Improvements ✅ (secondary) | - | - | 0 |
All ❌✅ (primary) | - | - | 0 |
Cycles
Results (secondary 8.1%)
This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
mean | range | count | |
---|---|---|---|
Regressions ❌ (primary) | - | - | 0 |
Regressions ❌ (secondary) | 8.1% | [8.1%, 8.1%] | 1 |
Improvements ✅ (primary) | - | - | 0 |
Improvements ✅ (secondary) | - | - | 0 |
All ❌✅ (primary) | - | - | 0 |
Binary size
This benchmark run did not return any relevant results for this metric.
Bootstrap: 780.893s -> 782.557s (0.21%)
Artifact size: 333.66 MiB -> 333.66 MiB (0.00%)
This was referenced
Oct 21, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request
…cross
update ABI compatibility docs for new option-like rules
Documents the rules decided [here](rust-lang#130628 (comment)) for our ABI compatibility rules.
Long-term this should be moved to the reference, but for now this is what we got.
Cc @rust-lang/lang
@rust-lang/opsem
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request
Rollup merge of rust-lang#132003 - RalfJung:abi-compat-docs, r=traviscross
update ABI compatibility docs for new option-like rules
Documents the rules decided [here](rust-lang#130628 (comment)) for our ABI compatibility rules.
Long-term this should be moved to the reference, but for now this is what we got.
Cc @rust-lang/lang
@rust-lang/opsem
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request
…=compiler-errors
abi/compatibility: also test Option-like types
Adds tests for the decision [here](rust-lang#130628 (comment)).
Cc @workingjubilee
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request
…=compiler-errors
abi/compatibility: also test Option-like types
Adds tests for the decision [here](rust-lang#130628 (comment)).
Cc @workingjubilee
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request
Rollup merge of rust-lang#132002 - RalfJung:abi-compat-option-like, r=compiler-errors
abi/compatibility: also test Option-like types
Adds tests for the decision [here](rust-lang#130628 (comment)).
Cc @workingjubilee
joboet added a commit to joboet/rust that referenced this pull request
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request
Labels
This issue / PR is in PFCP or FCP with a disposition to merge it.
The final comment period is finished for this PR / Issue.
This PR was explicitly merged by bors.
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Relevant to the language team, which will review and decide on the PR/issue.