rust/tests/ui/traits/negative-bounds/opaque-type-unsatisfied-bound.rs

22 lines
658 B
Rust

//@ compile-flags: -Znext-solver
#![feature(negative_bounds, negative_impls)]
trait Trait {}
impl !Trait for () {}
fn produce() -> impl !Trait {}
fn consume(_: impl Trait) {}
fn main() {
consume(produce()); //~ ERROR the trait bound `impl !Trait: Trait` is not satisfied
}
fn weird0() -> impl Sized + !Sized {}
//~^ ERROR type mismatch resolving `impl !Sized + Sized == ()`
fn weird1() -> impl !Sized + Sized {}
//~^ ERROR type mismatch resolving `impl !Sized + Sized == ()`
fn weird2() -> impl !Sized {}
//~^ ERROR type mismatch resolving `impl !Sized == ()`
//~| ERROR the size for values of type `impl !Sized` cannot be known at compilation time