rust/tests/ui/impl-trait/unsized_coercion2.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
487 B
Rust
Raw Normal View History

2024-05-28 10:38:18 -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
//@[next] check-pass
trait Trait {}
impl Trait for u32 {}
fn hello() -> Box<impl Trait + ?Sized> {
if true {
let x = hello();
let y: Box<dyn Trait> = x;
//[old]~^ ERROR: the size for values of type `impl Trait + ?Sized` cannot be know
}
Box::new(1u32)
}
fn main() {}