about summary refs log tree commit diff
path: root/library/core/src/mem/transmutability.rs
AgeCommit message (Collapse)AuthorLines
2025-09-15Remove UnsizedConstParamTy trait and make it into an unstable impltiif-3/+3
2025-03-06library: Use size_of from the prelude instead of importedThalia Archibald-3/+3
Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the prelude instead of importing or qualifying them. These functions were added to all preludes in Rust 1.80.
2025-02-14core: Apply unsafe_op_in_unsafe_fnEric Huss-1/+1
2025-01-08update cfg(bootstrap)Pietro Albini-3/+2
2024-12-20split up `#[rustc_deny_explicit_impl]` attributeLukas Markeffsky-1/+3
This commit splits the `#[rustc_deny_explicit_impl(implement_via_object = ...)]` attribute into two attributes `#[rustc_deny_explicit_impl]` and `#[rustc_do_not_implement_via_object]`. This allows us to have special traits that can have user-defined impls but do not have the automatic trait impl for trait objects (`impl Trait for dyn Trait`).
2024-09-05update cfgsBoxy-19/+10
2024-09-02chore: remove repetitive wordscuishuang-1/+1
Signed-off-by: cuishuang <imcusg@gmail.com>
2024-08-27safe transmute: Rename `BikeshedIntrinsicFrom` to `TransmuteFrom`Jack Wrenn-56/+53
As our implementation of MCP411 nears completion and we begin to solicit testing, it's no longer reasonable to expect testers to type or remember `BikeshedIntrinsicFrom`. The name degrades the ease-of-reading of documentation, and the overall experience of using compiler safe transmute. Tentatively, we'll instead adopt `TransmuteFrom`. This name seems to be the one most likely to be stabilized, after discussion on Zulip [1]. We may want to revisit the ordering of `Src` and `Dst` before stabilization, at which point we'd likely consider `TransmuteInto` or `Transmute`. [1] https://rust-lang.zulipchat.com/#narrow/stream/216762-project-safe-transmute/topic/What.20should.20.60BikeshedIntrinsicFrom.60.20be.20named.3F
2024-08-23document & impl the transmutation modeled by `BikeshedIntrinsicFrom`Jack Wrenn-21/+350
Documents that `BikeshedIntrinsicFrom` models transmute-via-union, which is slightly more expressive than the transmute-via-cast implemented by `transmute_copy`. Additionally, we provide an implementation of transmute-via-union as a method on the `BikeshedIntrinsicFrom` trait with additional documentation on the boundary between trait invariants and caller obligations. Whether or not transmute-via-union is the right kind of transmute to model remains up for discussion [1]. Regardless, it seems wise to document the present behavior. [1] https://rust-lang.zulipchat.com/#narrow/stream/216762-project-safe-transmute/topic/What.20'kind'.20of.20transmute.20to.20model.3F/near/426331967
2024-07-17Split part of `adt_const_params` into `unsized_const_params`Boxy-2/+4
2024-03-20step cfgsMark Rousskov-1/+1
2024-02-27safe transmute: revise safety analysisJack Wrenn-4/+5
Migrate to a simplified safety analysis that does not use visibility. Closes https://github.com/rust-lang/project-safe-transmute/issues/15
2023-07-12Flip cfg's for bootstrap bumpMark Rousskov-2/+1
2023-06-29Enable co-induction support for Safe TransmuteBryan Garza-0/+1
This patch adds the `#[rustc_coinductive]` annotation to `BikeshedIntrinsicFrom`, so that it's possible to compute transmutability for recursive types.
2023-06-20Merge attrs, better validationMichael Goulet-1/+2
2023-06-20Add rustc_do_not_implement_via_objectMichael Goulet-0/+1
2023-06-01Require that const param tys implement ConstParamTyBoxy-0/+5
2023-04-16rm const traits in libcoreDeadbeef-4/+2
2023-04-13Improve safe transmute error reportingBryan Garza-4/+0
This patch updates the error reporting when Safe Transmute is not possible between 2 types by including the reason. Also, fix some small bugs that occur when computing the `Answer` for transmutability.
2022-09-26remove cfg(bootstrap)Pietro Albini-2/+2
2022-08-22safe transmute: use `Assume` struct to provide analysis optionsJack Wrenn-12/+76
This was left as a TODO in #92268, and brings the trait more in line with what was defined in MCP411. `Assume::visibility` has been renamed to `Assume::safety`, as library safety is what's actually being assumed; visibility is just the mechanism by which it is currently checked (this may change). ref: https://github.com/rust-lang/compiler-team/issues/411 ref: https://github.com/rust-lang/rust/issues/99571
2022-08-12Adjust cfgsMark Rousskov-1/+1
2022-07-27safe transmute: reference tracking issueJack Wrenn-2/+2
ref: https://github.com/rust-lang/rust/pull/92268#discussion_r925266769
2022-07-27safe transmute: add `rustc_on_unimplemented` to `BikeshedIntrinsicFrom`Jack Wrenn-0/+4
ref: https://github.com/rust-lang/rust/pull/92268#discussion_r925266583
2022-07-27Initial (incomplete) implementation of transmutability trait.Jack Wrenn-0/+39
This initial implementation handles transmutations between types with specified layouts, except when references are involved. Co-authored-by: Igor null <m1el.2027@gmail.com>