2024-05-31 04:51:10 -05:00
|
|
|
//! This test checks that opaque types get unsized instead of
|
|
|
|
//! constraining their hidden type to a trait object.
|
|
|
|
|
|
|
|
//@ revisions: next old
|
|
|
|
//@[next] compile-flags: -Znext-solver
|
|
|
|
|
|
|
|
#![feature(trait_upcasting)]
|
|
|
|
|
|
|
|
trait Trait {}
|
|
|
|
|
|
|
|
impl Trait for u32 {}
|
|
|
|
|
|
|
|
fn hello() -> Box<impl Trait + ?Sized> {
|
|
|
|
if true {
|
|
|
|
let x = hello();
|
|
|
|
let y: Box<dyn Send> = x as Box<dyn Trait + Send>;
|
|
|
|
//[old]~^ ERROR: the size for values of type `impl Trait + ?Sized` cannot be know
|
2024-06-04 11:20:01 -05:00
|
|
|
//~^^ ERROR: mismatched types
|
2024-05-31 04:51:10 -05:00
|
|
|
}
|
|
|
|
Box::new(1u32)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|