]> git.lizzy.rs Git - rust.git/blob - src/test/ui/casts-differing-anon.rs
Rollup merge of #57132 - daxpedda:master, r=steveklabnik
[rust.git] / src / test / ui / 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<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 }