-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
ptr::eq: clarify that comparing dyn Trait is fragile #103567
Conversation
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
r? @thomcc (rust-highfive has picked a reviewer for you, use r? to override) |
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!
@bors r+ rollup |
@bors r+ |
ptr::eq: clarify that comparing dyn Trait is fragile Also remove the dyn trait example from `ptr::eq` since those tests are not actually guaranteed to pass due to how unstable vtable comparison is. Cc `@rust-lang/libs-api` Cc discussion following rust-lang#80505
Rollup of 10 pull requests Successful merges: - rust-lang#103432 (rustdoc: don't mark Box<T> as Iterator, Read, etc) - rust-lang#103526 (More dupe typos again) - rust-lang#103537 (rustdoc: combine shared CSS between `.*-line-numbers`) - rust-lang#103549 (llvm-16: Don't initialize removed legacy passes) - rust-lang#103558 (Update cargo) - rust-lang#103567 (ptr::eq: clarify that comparing dyn Trait is fragile) - rust-lang#103579 (:arrow_up: rust-analyzer) - rust-lang#103580 (Fix typo in docs for `guaranteed_ne`) - rust-lang#103596 (thread::set_name: debug-assert that things went well) - rust-lang#103598 (rustc_lexer::TokenKind improve docs) Failed merges: - rust-lang#103585 (Migrate source line numbers CSS to CSS variables) r? `@ghost` `@rustbot` modify labels: rollup
I wonder if some of the documentation changes here for This PR references #80505 which notably appeared to agree that In other words Since pull request #80505 was closed (I think just because the patch wasn't updated according to feedback) I recently opened #103763 to keep track of the original issue about the If the same conclusion as from #80505 is confirmed for #103763 then it would probably make sense to further iterate the Arc and Rc documentation to somehow clarify that the On the other hand if it's decided that |
@@ -1733,6 +1733,12 @@ pub(crate) unsafe fn align_offset<T: Sized>(p: *const T, a: usize) -> usize { | |||
/// by their address rather than comparing the values they point to | |||
/// (which is what the `PartialEq for &T` implementation does). | |||
/// | |||
/// When comparing wide pointers, both the address and the metadata are tested for equality. | |||
/// However, note that comparing trait object pointers (`*const dyn Trait`) is unrealiable: pointers |
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.
typo: unrealiable -> unreliable
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.
Good catch! #105474
Rollup of 10 pull requests Successful merges: - rust-lang#103432 (rustdoc: don't mark Box<T> as Iterator, Read, etc) - rust-lang#103526 (More dupe typos again) - rust-lang#103537 (rustdoc: combine shared CSS between `.*-line-numbers`) - rust-lang#103549 (llvm-16: Don't initialize removed legacy passes) - rust-lang#103558 (Update cargo) - rust-lang#103567 (ptr::eq: clarify that comparing dyn Trait is fragile) - rust-lang#103579 (:arrow_up: rust-analyzer) - rust-lang#103580 (Fix typo in docs for `guaranteed_ne`) - rust-lang#103596 (thread::set_name: debug-assert that things went well) - rust-lang#103598 (rustc_lexer::TokenKind improve docs) Failed merges: - rust-lang#103585 (Migrate source line numbers CSS to CSS variables) r? `@ghost` `@rustbot` modify labels: rollup
600: Pull changes from upstream `master` r=kirtchev-adacore a=pietroalbini * rust-lang/rust#103605 * rust-lang/rust#103604 * rust-lang/rust#103598 * rust-lang/rust#103596 * rust-lang/rust#103580 * rust-lang/rust#103579 * rust-lang/rust#103567 * rust-lang/rust#103558 * rust-lang/rust#103549 * rust-lang/rust#103537 * rust-lang/rust#103526 * rust-lang/rust#103432 * rust-lang/rust#103571 * rust-lang/rust#103492 * rust-lang/rust#103572 * rust-lang/rust#103554 * rust-lang/rust#103546 * rust-lang/rust#103543 * rust-lang/rust#103428 * rust-lang/rust#102706 * rust-lang/rust#95710 * rust-lang/rust#103284 * rust-lang/rust#103562 * rust-lang/rust#103542 * rust-lang/rust#103536 * rust-lang/rust#103533 * rust-lang/rust#103520 * rust-lang/rust#103444 * rust-lang/rust#103430 * rust-lang/rust#103416 * rust-lang/rust#103287 * rust-lang/rust#103209 * rust-lang/rust#102951 * rust-lang/rust#103279 * rust-lang/rust#103158 Co-authored-by: Lukas Wirth <[email protected]> Co-authored-by: Pietro Albini <[email protected]> Co-authored-by: DropDemBits <[email protected]> Co-authored-by: bors <[email protected]> Co-authored-by: Pietro Albini <[email protected]>
Also remove the dyn trait example from
ptr::eq
since those tests are not actually guaranteed to pass due to how unstable vtable comparison is.Cc @rust-lang/libs-api
Cc discussion following #80505