-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Tracking Issue for result_ffi_guarantees (RFC 3391) #110503
Comments
I did a bunch of work on ABI tests for
|
Is anyone still working on this? If not, I'd love to try my shot at it. |
I have not heard word of anyone working on this in a very long time. It's probably a safe bet to begin a PR. |
Besides adjusting the improper-ctypes lint (which is happening in #122253), some other things that should be done: |
Should the documentation change be a separate PR? |
Yes, that probably makes review easier. |
Support Result<T, E> across FFI when niche optimization can be used Allow allow enums like `Result<T, E>` to be used across FFI if the T/E can be niche optimized and the non-niche-optimized type is FFI safe. Implementation of rust-lang/rfcs#3391 Tracking issue: rust-lang#110503 Additional ABI and codegen tests were added in rust-lang#115372
Support Result<T, E> across FFI when niche optimization can be used Allow allow enums like `Result<T, E>` to be used across FFI if the T/E can be niche optimized and the non-niche-optimized type is FFI safe. Implementation of rust-lang/rfcs#3391 Tracking issue: rust-lang#110503 Additional ABI and codegen tests were added in rust-lang#115372
Support Result<T, E> across FFI when niche optimization can be used Allow allow enums like `Result<T, E>` to be used across FFI if the T/E can be niche optimized and the non-niche-optimized type is FFI safe. Implementation of rust-lang/rfcs#3391 Tracking issue: rust-lang#110503 Additional ABI and codegen tests were added in rust-lang#115372
Support Result<T, E> across FFI when niche optimization can be used (v2) This PR is identical to rust-lang#122253, which was approved and merged but then removed from master by a force-push due to a [CI bug](https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/ci.20broken.3F). r? ghost Original PR description: --- Allow allow enums like `Result<T, E>` to be used across FFI if the T/E can be niche optimized and the non-niche-optimized type is FFI safe. Implementation of rust-lang/rfcs#3391 Tracking issue: rust-lang#110503 Additional ABI and codegen tests were added in rust-lang#115372
Support Result<T, E> across FFI when niche optimization can be used (v2) This PR is identical to rust-lang#122253, which was approved and merged but then removed from master by a force-push due to a [CI bug](https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/ci.20broken.3F). r? ghost Original PR description: --- Allow allow enums like `Result<T, E>` to be used across FFI if the T/E can be niche optimized and the non-niche-optimized type is FFI safe. Implementation of rust-lang/rfcs#3391 Tracking issue: rust-lang#110503 Additional ABI and codegen tests were added in rust-lang#115372
Support Result<T, E> across FFI when niche optimization can be used (v2) This PR is identical to rust-lang#122253, which was approved and merged but then removed from master by a force-push due to a [CI bug](https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/ci.20broken.3F). r? ghost Original PR description: --- Allow allow enums like `Result<T, E>` to be used across FFI if the T/E can be niche optimized and the non-niche-optimized type is FFI safe. Implementation of rust-lang/rfcs#3391 Tracking issue: rust-lang#110503 Additional ABI and codegen tests were added in rust-lang#115372
The lint update PR has merged. |
I hope docs are next, then. :) We shouldn't go too long with such a gap between what we document and what we implement. The |
philosophically speaking I'm not sure how much the reference needs to say in addition to what the standard library type docs say, but yeah docs on Option and Result are the next step. I will likely have time for a docs PR very soon if no one else does it first |
Support Result<T, E> across FFI when niche optimization can be used (v2) This PR is identical to #122253, which was approved and merged but then removed from master by a force-push due to a [CI bug](https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/ci.20broken.3F). r? ghost Original PR description: --- Allow allow enums like `Result<T, E>` to be used across FFI if the T/E can be niche optimized and the non-niche-optimized type is FFI safe. Implementation of rust-lang/rfcs#3391 Tracking issue: rust-lang/rust#110503 Additional ABI and codegen tests were added in rust-lang/rust#115372
Support Result<T, E> across FFI when niche optimization can be used (v2) This PR is identical to #122253, which was approved and merged but then removed from master by a force-push due to a [CI bug](https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/ci.20broken.3F). r? ghost Original PR description: --- Allow allow enums like `Result<T, E>` to be used across FFI if the T/E can be niche optimized and the non-niche-optimized type is FFI safe. Implementation of rust-lang/rfcs#3391 Tracking issue: rust-lang/rust#110503 Additional ABI and codegen tests were added in rust-lang/rust#115372
Support Result<T, E> across FFI when niche optimization can be used (v2) This PR is identical to #122253, which was approved and merged but then removed from master by a force-push due to a [CI bug](https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/ci.20broken.3F). r? ghost Original PR description: --- Allow allow enums like `Result<T, E>` to be used across FFI if the T/E can be niche optimized and the non-niche-optimized type is FFI safe. Implementation of rust-lang/rfcs#3391 Tracking issue: rust-lang/rust#110503 Additional ABI and codegen tests were added in rust-lang/rust#115372
…lnay Update Result docs to the new guarantees The `Option` docs already explain the guarantees given in [RFC 3391](https://github.com/rust-lang/rfcs/blob/master/text/3391-result_ffi_guarantees.md), so all that we need is a paragraph saying that some `Result` type combinations will also qualify. Part of rust-lang#110503
Rollup merge of rust-lang#124870 - Lokathor:update-result-docs, r=dtolnay Update Result docs to the new guarantees The `Option` docs already explain the guarantees given in [RFC 3391](https://github.com/rust-lang/rfcs/blob/master/text/3391-result_ffi_guarantees.md), so all that we need is a paragraph saying that some `Result` type combinations will also qualify. Part of rust-lang#110503
Update Result docs to the new guarantees The `Option` docs already explain the guarantees given in [RFC 3391](https://github.com/rust-lang/rfcs/blob/master/text/3391-result_ffi_guarantees.md), so all that we need is a paragraph saying that some `Result` type combinations will also qualify. Part of rust-lang/rust#110503
I don't know, actually. I just saw a checked box and assumed the box wouldn't be checked if it wasn't completed yet. |
I must have been under the impression that this was only a documentation change. It probably needs a lang team signoff since it's more than that. |
Hm? Lang FCPed it? rust-lang/rfcs#3391 (comment) |
The feature gate is still unstable: rust/compiler/rustc_feature/src/unstable.rs Lines 575 to 577 in 1a5a224
That needs to move to accepted in the neighboring module, and might need updates in places that use it too, like: rust/compiler/rustc_lint/src/types.rs Lines 1147 to 1149 in 1a5a224
|
I have opened #130628 on the assumption that all necessary documentation changes have landed already. Please let me know if that is incorrect. |
I do not believe this has been documented. I think that will be needed before stabilization should continue. Also, it would be helpful to update the top comment with links to the implementation, since it's not really clear to me what was actually changed. |
I believe it was documented on the Result type. Should we add it to the Reference? |
Indeed the Result type was documented accordingly: https://doc.rust-lang.org/std/result/index.html#representation Unfortunately some very peculiar events happened with CI around the time, so the history is somewhat harder to actually track. |
I have lifted all PRs relevant to the implementation history to the top. |
@ehuss It seems none of the ABI guarantees of Result or Option have been documented in the Reference that I can see, and I'm not sure where the other ABI guarantees that we offer are in the Reference either. So I think this is a larger concern than the matter of this feature and a separate issue should be opened for it. Type layout doesn't seem even close to exhaustive. |
@ehuss I can post a bare-minimum PR to the reference regarding this specific guarantee, but it will mostly serve to make it more obvious that the work is direly unfinished w/r/t documenting ABI in the Reference. |
Thanks @workingjubilee! I am a bit confused, since I don't fully understand the connection between I am also quite confused about what is being stabilized, or about the process being used. From the timeline I see:
Some questions:
Sorry for all the dumb questions, but I am very confused as to what is being proposed. As for layout guarantees, since the reference currently doesn't cover that, then I think it is fine to skip it for now. We are inching our way forward with rust-lang/reference#1545, and I think this might be included there (cc @chorman0773). |
Will probably also want to go into the type-layout chapter as well. It can be added to abi as well once 1545 is merged. |
That IS the behavior with this feature.
Option already had such an ABI guarantee documented: https://doc.rust-lang.org/std/option/index.html#representation
My understanding is that it is not a functional behavioral change. It is a promise that the behavior will not change, and that if it varies from the documented behavior, it will be treated as a bug. To many developers, this is much more important than "how the compiler actually behaves".
I don't understand the question. Result is not a |
the RFC is not about:
the RFC is about:
|
FTR, I already have plans to redo the type-layout chapter, particularily the enum section. |
gonna level with you here, this RFC was basically a stabilization report for a behavior we already implemented. 🙃
I don't really know what to tell you here? This entire RFC arose because T-lang has such a crushingly low bandwidth that people have to use extremely high-volume signals (like RFCs) to get their attention for long. Then they have to make the RFC extremely conservative to avoid it being nitpicked to death. Then T-lang doesn't have sufficient bandwidth to properly shepherd something through its process so that missteps don't happen. So missteps happen. I expect that can only realistically be solved by T-lang deciding to prioritize onboarding sufficient members in some capacity as to at least have a successorship. Perhaps they are actually doing that? But such would also consume their bandwidth, so either way, something like this was inevitable in some case. I have no magical power to wave a wand and make them do that if they are not. |
Doing a stabilization report is probably a good idea nonetheless. |
I suppose I will draft one, then! No promises it won't be very silly though. |
Oh, sorry, yea, that didn't make sense. My thinking was, do we have a stable guarantee such that
That's what I'm trying to drill down to; is this just a documentation change, or is it a behavior change? If it was a documentation change, then I would not have expected #122253 to exist, unless the only goal there was to squelch For documentation-only changes, we have generally not required a stabilization report or separate FCP for an accepted RFC. Documentation-only RFCs normally get their doc changes merged almost right away, and there is no tracking issue. This seems slightly more than that, though.
100% agree with you1, and I don't want to put up roadblocks where it's not appropriate. However, I do want to make sure that there is awareness and understanding of what is happening. Footnotes
|
@ehuss I don't believe we have any guarantee that something is not defined. In fact the entire point of the RFC is to make your example cose snippit be defined, as far as i can read it |
@ehuss Of course! tbh I'm mostly just playing my occasional role of "clown that pratfalls into thing everyone is confused about, prompting everyone to laugh, cheer, boo, throw tomatoes, or buy popcorn". :^) |
...speaking of documentation, is this written anywhere? I mean oral tradition is well and dandy but this actually seems worth formalizing because of the whole "T-lang has a tiny amount of bandwidth" 🫠 so it's good to note down when something only hard-requires one Formal Team Decision instead of two Formal Team Decisions. I do think a tracking issue sometimes is warranted simply because "wait how many places do we have to update the documentation exactly...?" sometimes uhh needs a Formal Issue. And there technically were related compiler changes in this re: the lint. I won't start an argument about whether lints are metaphysically also documentation, tho'. :^) |
And yeah, with this feature, these are now both correct: let x: Result<NonZeroI32, ()> = unsafe { std::mem::transmute(12) };
extern "C" {
fn f() -> Result<NonZeroI32, ()>;
} The latter even should, IIRC, be correct under the "integer normalization" CFI flag (which reduces entropy but enables certain ABI-compatible equivalencies). This is because the equivalence is sorta defined in terms of transmute:
|
I have opened rust-lang/reference#1623 to track "documenting a complete explanation of our ABI rules, also what even is an ABI, huh? what?" |
The entire RFC was basically "just" a docs change. I didn't know there is a feature gate, all it can be doing is affecting the lint as feature gates affecting layout would be unsound so I hope we don't do it. ;)
So if this is anyway not in the reference, no update is needed there. Which means I think all that is left is stabilizing the feature - after we confirm what exactly it does.^^
|
This is a tracking issue for the RFC "result_ffi_guarantees" (rust-lang/rfcs#3391).
About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Steps
Stabilization PR (see instructions on rustc-dev-guide)(not necessary, reference FCP should be all that's needed)Unresolved Questions
None
Implementation history
The text was updated successfully, but these errors were encountered: