-
Notifications
You must be signed in to change notification settings - Fork 280
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
other-reprs: do not make it sound like we are making ABI promises for repr(int) enums #461
Conversation
58c72a8
to
33dd3a5
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.
Just a note for review, otherwise 👍 from me
knowledge of "invalid" values at this type to optimize enum layout, such as when | ||
this enum is wrapped in `Option`). Note that the function call ABI for these | ||
types is still in general unspecified, except that across `extern "C"` calls they | ||
are ABI-compatible with C enums of the same sign and size. |
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.
Just to point this out here as well, C has non-transitive rules that allow enum
and the underlying integer type to be punned by ABI.
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.
Yeah I saw that comment in the issue. I don't think that's something to discuss here though -- they key point is that the Rust thing matches the C thing.
Non-transitive compatibility doesn't really make sense IMO but that's a discussion for another day.
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've run into problems with cfi tags on methods involving enums in the signature. You probably want to be careful about what you promise here. Unfortunately I don't know what the precise rules are CFI wise.
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.
Thanks!
Information like this should probably go in the reference first. I'll go ahead and approve here, but I think it would be good to have a more deliberate specification over there.
Update books ## rust-lang/book 2 commits in d4d2c18cbd20876b2130a546e790446a8444cb32..4a01a9182496f807aaa5f72d93a25ce18bcbe105 2025-02-24 14:48:34 UTC to 2025-02-13 19:29:47 UTC - Fix typos in chapter 17 (rust-lang/book#4238) - NoStarch backports (rust-lang/book#4224) ## rust-lang/edition-guide 2 commits in 8dbdda7cae4fa030f09f8f5b63994d4d1dde74b9..daa4b763cd848f986813b5cf8069e1649f7147af 2025-02-22 14:58:51 UTC to 2025-02-21 02:30:17 UTC - Remove precise capturing features (rust-lang/edition-guide#362) - use same name as previous example (rust-lang/edition-guide#360) ## rust-lang/nomicon 1 commits in 336f75835a6c0514852cc65aba9a698b699b13c8..8f5c7322b65d079aa5b242eb10d89a98e12471e1 2025-02-19 13:16:47 UTC to 2025-02-19 13:16:47 UTC - other-reprs: do not make it sound like we are making ABI promises for repr(int) enums (rust-lang/nomicon#461) ## rust-lang/reference 4 commits in 6195dbd70fc6f0980c314b4d23875ac570d8253a..615b4cec60c269cfc105d511c93287620032d5b0 2025-02-18 23:01:53 UTC to 2025-02-13 15:12:49 UTC - Add rule identifiers to names chapters (rust-lang/reference#1737) - Switch from AVX to SSE in the example (rust-lang/reference#1735) - Remove attributes from struct field rest patterns (rust-lang/reference#1736) - Update reference for target_feature_11. (rust-lang/reference#1720)
Rollup merge of rust-lang#137552 - rustbot:docs-update, r=ehuss Update books ## rust-lang/book 2 commits in d4d2c18cbd20876b2130a546e790446a8444cb32..4a01a9182496f807aaa5f72d93a25ce18bcbe105 2025-02-24 14:48:34 UTC to 2025-02-13 19:29:47 UTC - Fix typos in chapter 17 (rust-lang/book#4238) - NoStarch backports (rust-lang/book#4224) ## rust-lang/edition-guide 2 commits in 8dbdda7cae4fa030f09f8f5b63994d4d1dde74b9..daa4b763cd848f986813b5cf8069e1649f7147af 2025-02-22 14:58:51 UTC to 2025-02-21 02:30:17 UTC - Remove precise capturing features (rust-lang/edition-guide#362) - use same name as previous example (rust-lang/edition-guide#360) ## rust-lang/nomicon 1 commits in 336f75835a6c0514852cc65aba9a698b699b13c8..8f5c7322b65d079aa5b242eb10d89a98e12471e1 2025-02-19 13:16:47 UTC to 2025-02-19 13:16:47 UTC - other-reprs: do not make it sound like we are making ABI promises for repr(int) enums (rust-lang/nomicon#461) ## rust-lang/reference 4 commits in 6195dbd70fc6f0980c314b4d23875ac570d8253a..615b4cec60c269cfc105d511c93287620032d5b0 2025-02-18 23:01:53 UTC to 2025-02-13 15:12:49 UTC - Add rule identifiers to names chapters (rust-lang/reference#1737) - Switch from AVX to SSE in the example (rust-lang/reference#1735) - Remove attributes from struct field rest patterns (rust-lang/reference#1736) - Update reference for target_feature_11. (rust-lang/reference#1720)
Until something like rust-lang/rust#128600 lands, let's be careful what we say about this.
Also mention that
repr(C)
generally makes this behave the same as C ABI-wise. That's anyway what people already assume this means and are relying on in practice, so there's no point in not saying it IMO?Cc @rust-lang/opsem @chorman0773