diff options
| author | Jack Wrenn <jack@wrenn.fyi> | 2024-02-26 16:49:25 +0000 |
|---|---|---|
| committer | Jack Wrenn <jack@wrenn.fyi> | 2024-02-27 16:22:32 +0000 |
| commit | 23ab1bda92b127b18f32fe7593298842fd25e05b (patch) | |
| tree | 5f5b344641919e244cb0c6751f189dbf9db683e8 /library/core | |
| parent | 9afdb8d1d55f7ee80259009c39530d163d24dc65 (diff) | |
| download | rust-23ab1bda92b127b18f32fe7593298842fd25e05b.tar.gz rust-23ab1bda92b127b18f32fe7593298842fd25e05b.zip | |
safe transmute: revise safety analysis
Migrate to a simplified safety analysis that does not use visibility. Closes https://github.com/rust-lang/project-safe-transmute/issues/15
Diffstat (limited to 'library/core')
| -rw-r--r-- | library/core/src/mem/transmutability.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/library/core/src/mem/transmutability.rs b/library/core/src/mem/transmutability.rs index f5cc86e7767..0687874a258 100644 --- a/library/core/src/mem/transmutability.rs +++ b/library/core/src/mem/transmutability.rs @@ -6,10 +6,10 @@ use crate::marker::ConstParamTy; /// any value of type `Self` are safely transmutable into a value of type `Dst`, in a given `Context`, /// notwithstanding whatever safety checks you have asked the compiler to [`Assume`] are satisfied. #[unstable(feature = "transmutability", issue = "99571")] -#[lang = "transmute_trait"] +#[cfg_attr(not(bootstrap), lang = "transmute_trait")] #[rustc_deny_explicit_impl(implement_via_object = false)] #[rustc_coinductive] -pub unsafe trait BikeshedIntrinsicFrom<Src, Context, const ASSUME: Assume = { Assume::NOTHING }> +pub unsafe trait BikeshedIntrinsicFrom<Src, const ASSUME: Assume = { Assume::NOTHING }> where Src: ?Sized, { @@ -28,8 +28,9 @@ pub struct Assume { /// that violates Rust's memory model. pub lifetimes: bool, - /// When `true`, the compiler assumes that *you* have ensured that it is safe for you to violate the - /// type and field privacy of the destination type (and sometimes of the source type, too). + /// When `true`, the compiler assumes that *you* have ensured that no + /// unsoundness will arise from violating the safety invariants of the + /// destination type (and sometimes of the source type, too). pub safety: bool, /// When `true`, the compiler assumes that *you* are ensuring that the source type is actually a valid |
