[WIP] Introduce repr(Swift) - #160729
Conversation
Squash of the following 8 commits Added Swift repr and callconv Implemented extern "Swift" and started repr(Swift) Also assert size_of and align_of Adjust ABI to account for Swift small structs Splat Swift structs' padding as well Renames and adjust core::mem primitives Fix build post-merge Correct SizedTypeProperties::SIZE x test
|
Some changes occurred in compiler/rustc_passes/src/check_attr.rs cc @jdonszelmann, @JonathanBrouwer
cc @bjorn3 These commits modify compiler targets. This PR changes rustc_public cc @oli-obk, @celinval, @ouz-a, @makai410
cc @rust-lang/wg-const-eval Some changes occurred to the CTFE machinery Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri Some changes occurred in compiler/rustc_hir/src/attrs |
|
Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @JohnTitor (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
| largest_niche: element.largest_niche.filter(|_| count != 0), | ||
| uninhabited: element.uninhabited && count != 0, | ||
| align: element.align, | ||
| size_without_padding: size, |
There was a problem hiding this comment.
Something as fundamental as adding a new kind of size will at the very least need an MCP if it's something that only ever matters internally to compiler devs, or an RFC if it is relevant to people writing (unsafe) Rust code.
There was a problem hiding this comment.
Indeed, and furthermore the attribute change requires a T-lang RFC, see https://github.com/rust-lang/rfcs#what-the-process-is
If you'd only like to like to gauge interest without writing a full RFC immediately, I'd recommend opening a zulip thread explaining your idea
@rustbot author
There was a problem hiding this comment.
cf. #156481, but that was only a lang experiment about swift function call ABI, not repr(swift).
There was a problem hiding this comment.
In particular, any repr(Swift) ABI attempts really ought to address #155815 (comment) and #155815 (comment):
When will arguments be marked as
swiftselfandswifterrorin LLVM IR? Without these it is impossible to call class methods and fallible functions respectively afaik. Also how useful is this withoutrepr(Swift)? Delaying implementation of that to another PR would be fine I think, but I would personally like to see at least a plan for how to soundly implementrepr(Swift)given that it breaks the stride=size assumption that is true for all current memory layouts.[...]
To be clear, I'm not going to block this PR on figuring out
repr(Swift). I'm just a bit worried that we don't figure outrepr(Swift)makingextern "Swift"not that useful.By the way I noticed that a question of mine in the previous attempt hadn't been answered yet: #64582 (comment) https://github.com/swiftlang/swift/blob/main/docs/ABI/CallingConventionSummary.rst seems to suggest like the answer to my question is no it doesn't need a separate
classify_argon Apple platforms, but I'm not sure.
There was a problem hiding this comment.
Indeed, and furthermore the attribute change requires a T-lang RFC, see https://github.com/rust-lang/rfcs#what-the-process-is
If you'd only like to like to gauge interest without writing a full RFC immediately, I'd recommend opening a zulip thread explaining your idea
@rustbot author
There was a problem hiding this comment.
Yes, and you were given a lot of questions there that need a coherent answer and buy-in from the relevant team(s) before we can begin landing code changes here. You are proposing a very deep-cutting change here, we're not doing such changes without some planning.
I can't tell immediately whether your goal is to expose a new kind of "size" as something Rust programmers can see and need to deal with (needs RFC) or just a new internal representation of types in the compiler (needs MCP).
|
Reminder, once the PR becomes ready for a review, use |
|
Some changes occurred in compiler/rustc_attr_parsing |
|
I've fixed the build so I can actually run my test ground at https://github.com/Lancelotbronner/rust-swift-interop. I'll do some more research on how I can deal with the questions, I'd personally like it to remain internal but I don't know if that's feasible. |
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
☔ The latest upstream changes (presumably #160761) made this pull request unmergeable. Please resolve the merge conflicts by rebasing. |
Adds the
repr(Swift)attribute, allowing direct representation of Swift structs.Since rebasing on the latest main it probably doesn't compile anymore.
I'd like to gauge interest to see if it's worth my time to continue this.