-
Notifications
You must be signed in to change notification settings - Fork 508
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
Add trait_upcasting related languages changes #1622
Conversation
rust-lang/rust#101336 is still open, did we actually end up committing to something? |
@WaffleLapkin: Yes, it's just pending documentation rust-lang/rust#101336 (comment) -- presumably this is (A.) on Niko's list. |
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.
You may also want to edit https://doc.rust-lang.org/reference/behavior-considered-undefined.html as Niko mentioned in the issue you linked; you may want to re-read the FCP, but I believe it's UB to conjure up a vtable now since it must be valid for upcasting.
What exactly are you referring to here? I assume the "issue" is rust-lang/rust#101336 (a link would have been good, it took clicking on 4 links to track this down :D ). Niko says a lot of things there, though. :) |
@compiler-errors doc.rust-lang.org/reference/behavior-considered-undefined.html already mentions invalid metadata in any kind of pointer makes an invalid value, so I don't think we need to add anything on top of that?
|
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 believe this is ready and consistent with what is implemented on master. I think all that needs to be done w.r.t. trait upcasting is a fresh stabilization PR?
This comment has been minimized.
This comment has been minimized.
Any movement on this? |
@PoignardAzur I'm working on a stabilization PR (after which this can be merged) |
607255c
to
3139bd7
Compare
@compiler-errors could you take another look, do the changes still make sense? |
@rustbot ready |
In the original PR for this... ...there's a discussion about adding a line to the behavior considered undefined of:
There was some back and forth and it's not clear where that landed. Thoughts on that? |
The comment here is the answer https://github.com/rust-lang/reference/pull/1259/files#r1404804424. I don't think this needs further changing. It doesn't really matter if the pointer is bad; upcasting only cares about the vtable metadata. |
@WaffleLapkin I think this isn't quite right. How I read the Behaviors Considered Undefined section, it says...
where "producing an invalid value is hence immediate UB". But the consensus from rust-lang/rust#101336 was that having an invalid vtable is not a failure of the validity invariant. Rather, the UB occurs when a
|
To be clear, consensus was that we are not ruling on the validity invariant at this point. The validity invariant for vtable metadata is an open question, discussed at rust-lang/unsafe-code-guidelines#516. Meanwhile, the reference says that the vtable pointer must point to a vtable of the right trait and Miri enforces this; this is following our usual strategy of having a bit more UB for now and possibly relaxing this in the future. |
Hmm, OK, that's not what I thought the consensus was. =) Maybe I'm misremembering, though when I read the text I quoted it seems clear-ish. We need to find some clearer way though to describe the "upper/lower bounds" of what is and is not UB, I think it's going to be very hard to keep things in sync over time the way it is now (where it is e.g. difficult to tell if the reference is out of date or over approximating).
…On Thu, Dec 19, 2024, at 1:51 AM, Ralf Jung wrote:
> But the consensus from rust-lang/rust#101336 <rust-lang/rust#101336> was that having an invalid vtable is not a failure of the validity invariant.
>
To be clear, consensus was that we are not ruling on the validity invariant at this point. The validity invariant for vtable metadata is an open question, discussed at rust-lang/unsafe-code-guidelines#516 <rust-lang/unsafe-code-guidelines#516>. Meanwhile, the reference says that the vtable pointer must point to a vtable of the right trait and Miri enforces this; this is following our usual strategy of having a bit more UB for now and possibly relaxing this in the future.
—
Reply to this email directly, view it on GitHub <#1622 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AABF4ZX7ZXAI3MZZOHKHJNL2GJUI7AVCNFSM6AAAAABORRYCSKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNJSHEYTOOBZGU>.
You are receiving this because you commented.Message ID: ***@***.***>
|
We currently say this above the UB list
So the entire thing should be considered as approximating. Maybe we should start slowly widdling this down to just a few items in the list, though I think we should always reserve the right to remove UB. Anyway this is getting off-topic for this PR. The validity invariant for vtables doesn't have to be settled for this one. |
6c4f538
to
0a2d4d0
Compare
…treat, r=compiler-errors Stabilize `feature(trait_upcasting)` This feature was "done" for a while now, I think it's finally time to stabilize it! Stabilization report: rust-lang#134367 (comment). cc reference PR: rust-lang/reference#1622. Closes rust-lang#65991 (tracking issue), closes rust-lang#89460 (the lint is no longer future incompat). r? compiler-errors
…treat, r=compiler-errors Stabilize `feature(trait_upcasting)` This feature was "done" for a while now, I think it's finally time to stabilize it! Stabilization report: rust-lang#134367 (comment). cc reference PR: rust-lang/reference#1622. Closes rust-lang#65991 (tracking issue), closes rust-lang#89460 (the lint is no longer future incompat). r? compiler-errors
Rollup merge of rust-lang#134367 - WaffleLapkin:trait_upcasting_as_a_treat, r=compiler-errors Stabilize `feature(trait_upcasting)` This feature was "done" for a while now, I think it's finally time to stabilize it! Stabilization report: rust-lang#134367 (comment). cc reference PR: rust-lang/reference#1622. Closes rust-lang#65991 (tracking issue), closes rust-lang#89460 (the lint is no longer future incompat). r? compiler-errors
rust-lang/rust#134367 (comment) has been merged, so this can be merged as well :) |
5dbb2de
to
0a2d4d0
Compare
…compiler-errors Stabilize `feature(trait_upcasting)` This feature was "done" for a while now, I think it's finally time to stabilize it! Stabilization report: rust-lang/rust#134367 (comment). cc reference PR: rust-lang/reference#1622. Closes #65991 (tracking issue), closes #89460 (the lint is no longer future incompat). r? compiler-errors
This aligns the reference with the results of r-l/r/120248.
Co-authored-by: Michael Goulet <[email protected]> Co-authored-by: Charles Lew <[email protected]>
I.e., document the behavior after r-l/r/119338.
0a2d4d0
to
2837b28
Compare
I rebased to collapse some back and forth, to fix an author name, to make some minor stylistic tweaks (capitalization and line unwrapping), and to remove the note section mentioned above. We're anticipating further work on this to address some things raised in the threads here in a follow-up PR that Waffle has in progress. |
Follow-up: #1731 |
Update books ## rust-lang/edition-guide 1 commits in f56aecc3b036dff16404b525a83b00f911b9bbea..8dbdda7cae4fa030f09f8f5b63994d4d1dde74b9 2025-02-06 20:06:58 UTC to 2025-02-06 20:06:58 UTC - Correct spelling error in `static-mut-references.md` (rust-lang/edition-guide#358) ## rust-embedded/book 1 commits in ddbf1b4e2858fedb71b7c42eb15c4576517dc125..0b8219ac23a3e09464e4e0166c768cf1c4bba0d5 2025-02-07 08:26:59 UTC to 2025-02-07 08:26:59 UTC - Update gcc toolchain download link for windows (rust-embedded/book#384) ## rust-lang/reference 3 commits in 4249fb411dd27f945e2881eb0378044b94cee06f..de2d5289e45506b11dd652bef4f99de64be70e1c 2025-02-08 22:12:20 UTC to 2025-02-06 19:02:01 UTC - Add trait_upcasting related languages changes (rust-lang/reference#1622) - fixup `»` insertion for rules (rust-lang/reference#1730) - doc `cenum_impl_drop_cast` (rust-lang/reference#1713) ## rust-lang/rust-by-example 2 commits in 743766929f1e53e72fab74394ae259bbfb4a7619..66543bbc5b7dbd4e679092c07ae06ba6c73fd912 2025-02-06 12:38:08 UTC to 2025-02-04 01:46:09 UTC - Add more examples @ drop.md (rust-lang/rust-by-example#1912) - es translation to 3100 (rust-lang/rust-by-example#1911)
Update books ## rust-lang/edition-guide 1 commits in f56aecc3b036dff16404b525a83b00f911b9bbea..8dbdda7cae4fa030f09f8f5b63994d4d1dde74b9 2025-02-06 20:06:58 UTC to 2025-02-06 20:06:58 UTC - Correct spelling error in `static-mut-references.md` (rust-lang/edition-guide#358) ## rust-embedded/book 1 commits in ddbf1b4e2858fedb71b7c42eb15c4576517dc125..0b8219ac23a3e09464e4e0166c768cf1c4bba0d5 2025-02-07 08:26:59 UTC to 2025-02-07 08:26:59 UTC - Update gcc toolchain download link for windows (rust-embedded/book#384) ## rust-lang/reference 3 commits in 4249fb411dd27f945e2881eb0378044b94cee06f..de2d5289e45506b11dd652bef4f99de64be70e1c 2025-02-08 22:12:20 UTC to 2025-02-06 19:02:01 UTC - Add trait_upcasting related languages changes (rust-lang/reference#1622) - fixup `»` insertion for rules (rust-lang/reference#1730) - doc `cenum_impl_drop_cast` (rust-lang/reference#1713) ## rust-lang/rust-by-example 2 commits in 743766929f1e53e72fab74394ae259bbfb4a7619..66543bbc5b7dbd4e679092c07ae06ba6c73fd912 2025-02-06 12:38:08 UTC to 2025-02-04 01:46:09 UTC - Add more examples @ drop.md (rust-lang/rust-by-example#1912) - es translation to 3100 (rust-lang/rust-by-example#1911)
Update books ## rust-lang/edition-guide 1 commits in f56aecc3b036dff16404b525a83b00f911b9bbea..8dbdda7cae4fa030f09f8f5b63994d4d1dde74b9 2025-02-06 20:06:58 UTC to 2025-02-06 20:06:58 UTC - Correct spelling error in `static-mut-references.md` (rust-lang/edition-guide#358) ## rust-embedded/book 1 commits in ddbf1b4e2858fedb71b7c42eb15c4576517dc125..0b8219ac23a3e09464e4e0166c768cf1c4bba0d5 2025-02-07 08:26:59 UTC to 2025-02-07 08:26:59 UTC - Update gcc toolchain download link for windows (rust-embedded/book#384) ## rust-lang/reference 3 commits in 4249fb411dd27f945e2881eb0378044b94cee06f..de2d5289e45506b11dd652bef4f99de64be70e1c 2025-02-08 22:12:20 UTC to 2025-02-06 19:02:01 UTC - Add trait_upcasting related languages changes (rust-lang/reference#1622) - fixup `»` insertion for rules (rust-lang/reference#1730) - doc `cenum_impl_drop_cast` (rust-lang/reference#1713) ## rust-lang/rust-by-example 2 commits in 743766929f1e53e72fab74394ae259bbfb4a7619..66543bbc5b7dbd4e679092c07ae06ba6c73fd912 2025-02-06 12:38:08 UTC to 2025-02-04 01:46:09 UTC - Add more examples @ drop.md (rust-lang/rust-by-example#1912) - es translation to 3100 (rust-lang/rust-by-example#1911)
Rollup merge of rust-lang#136825 - rustbot:docs-update, r=ehuss Update books ## rust-lang/edition-guide 1 commits in f56aecc3b036dff16404b525a83b00f911b9bbea..8dbdda7cae4fa030f09f8f5b63994d4d1dde74b9 2025-02-06 20:06:58 UTC to 2025-02-06 20:06:58 UTC - Correct spelling error in `static-mut-references.md` (rust-lang/edition-guide#358) ## rust-embedded/book 1 commits in ddbf1b4e2858fedb71b7c42eb15c4576517dc125..0b8219ac23a3e09464e4e0166c768cf1c4bba0d5 2025-02-07 08:26:59 UTC to 2025-02-07 08:26:59 UTC - Update gcc toolchain download link for windows (rust-embedded/book#384) ## rust-lang/reference 3 commits in 4249fb411dd27f945e2881eb0378044b94cee06f..de2d5289e45506b11dd652bef4f99de64be70e1c 2025-02-08 22:12:20 UTC to 2025-02-06 19:02:01 UTC - Add trait_upcasting related languages changes (rust-lang/reference#1622) - fixup `»` insertion for rules (rust-lang/reference#1730) - doc `cenum_impl_drop_cast` (rust-lang/reference#1713) ## rust-lang/rust-by-example 2 commits in 743766929f1e53e72fab74394ae259bbfb4a7619..66543bbc5b7dbd4e679092c07ae06ba6c73fd912 2025-02-06 12:38:08 UTC to 2025-02-04 01:46:09 UTC - Add more examples @ drop.md (rust-lang/rust-by-example#1912) - es translation to 3100 (rust-lang/rust-by-example#1911)
I applied review comments from #1259 and added updates from rust-lang/rust#120248.
Tracking issue: rust-lang/rust#65991
Stabilization proposal: rust-lang/rust#134367
cc @crlf0710 @compiler-errors @RalfJung