mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-28 17:53:56 +00:00
6266358237
- Only create dst -> src obligation if Dst is mutable - Add some long comments to explain parts of the transmutability code that were unclear to me when reading - Update/add tests
25 lines
571 B
Rust
25 lines
571 B
Rust
// check-fail
|
|
#![feature(transmutability)]
|
|
|
|
mod assert {
|
|
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
|
pub struct Context;
|
|
|
|
pub fn is_maybe_transmutable<Src, Dst>()
|
|
where
|
|
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
|
Assume {
|
|
alignment: true,
|
|
lifetimes: true,
|
|
safety: true,
|
|
validity: false,
|
|
}
|
|
}>
|
|
{}
|
|
}
|
|
|
|
fn main() {
|
|
#[repr(C)] struct Unit;
|
|
assert::is_maybe_transmutable::<&'static Unit, &'static u8>(); //~ ERROR cannot be safely transmuted
|
|
}
|