]> git.proxmox.com Git - rustc.git/blob - tests/ui/cast/casts-differing-anon.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / cast / casts-differing-anon.rs
1 use std::fmt;
2
3 fn foo() -> Box<impl fmt::Debug+?Sized> {
4 let x : Box<[u8]> = Box::new([0]);
5 x
6 }
7 fn bar() -> Box<impl fmt::Debug+?Sized> {
8 let y: Box<dyn fmt::Debug> = Box::new([0]);
9 y
10 }
11
12 fn main() {
13 let f = foo();
14 let b = bar();
15
16 // this is an `*mut [u8]` in practice
17 let f_raw : *mut _ = Box::into_raw(f);
18 // this is an `*mut fmt::Debug` in practice
19 let mut b_raw = Box::into_raw(b);
20 // ... and they should not be mixable
21 b_raw = f_raw as *mut _; //~ ERROR is invalid
22 }