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

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

24 lines
654 B
Rust
Raw Normal View History

2024-05-31 09:51:10 +00: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
trait Trait {}
impl Trait for u32 {}
fn hello() -> Box<impl Trait + ?Sized> {
2024-10-14 17:04:10 +00:00
//[next]~^ ERROR: the trait bound `dyn Send: Trait` is not satisfied
2024-05-31 09:51:10 +00:00
if true {
let x = hello();
2024-10-14 17:04:10 +00:00
//[next]~^ ERROR: the trait bound `dyn Send: Trait` is not satisfied
2024-05-31 09:51:10 +00:00
let y: Box<dyn Send> = x;
//[old]~^ ERROR: the size for values of type `impl Trait + ?Sized` cannot be know
}
Box::new(1u32)
//[next]~^ ERROR: mismatched types
}
fn main() {}