• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // revisions: current next
2 //[next] compile-flags: -Ztrait-solver=next
3 
4 #![feature(transmutability)]
5 mod assert {
6     use std::mem::{Assume, BikeshedIntrinsicFrom};
7     pub struct Context;
8 
is_transmutable<Src, Dst>() where Dst: BikeshedIntrinsicFrom<Src, Context,9     pub fn is_transmutable<Src, Dst>()
10     where
11         Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY }>
12     {}
13 
is_maybe_transmutable<Src, Dst>() where Dst: BikeshedIntrinsicFrom<Src, Context,14     pub fn is_maybe_transmutable<Src, Dst>()
15     where
16         Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY.and(Assume::VALIDITY) }>
17     {}
18 }
19 
main()20 fn main() {
21     assert::is_transmutable::<u8, bool>(); //~ ERROR cannot be safely transmuted
22     assert::is_maybe_transmutable::<u8, bool>();
23     assert::is_transmutable::<bool, u8>();
24 }
25