//@ edition: 2024 #![feature(associated_const_equality, type_alias_impl_trait, return_type_notation)] #![allow(refining_impl_trait_internal)] use std::iter; fn rpit1() -> impl Iterator { iter::empty() //~^ ERROR type annotations needed } fn rpit2() -> impl Iterator { iter::empty() //~^ ERROR type annotations needed } fn rpit3() -> impl Iterator { iter::empty() //~^ ERROR type annotations needed } type Tait1> = impl Copy; //~^ ERROR unconstrained opaque type type Tait2> = impl Copy; //~^ ERROR unconstrained opaque type type Tait3> = impl Copy; //~^ ERROR unconstrained opaque type type Tait4 = impl Iterator; //~^ ERROR unconstrained opaque type type Tait5 = impl Iterator; //~^ ERROR unconstrained opaque type type Tait6 = impl Iterator; //~^ ERROR unconstrained opaque type fn mismatch() -> impl Iterator { //~^ ERROR [E0277] iter::empty::<*const ()>() } fn mismatch_2() -> impl Iterator { //~^ ERROR [E0277] iter::empty::() } trait Trait { type Gat; const ASSOC: i32; fn foo() -> impl Sized; } impl Trait for () { type Gat = (); const ASSOC: i32 = 3; fn foo() {} } impl Trait for u32 { type Gat = (); const ASSOC: i32 = 4; fn foo() -> u32 { 42 } } fn uncallable(_: impl Iterator) {} fn uncallable_const(_: impl Trait) {} fn uncallable_rtn(_: impl Trait, foo(..): Trait>) {} type MustFail = dyn Iterator; //~^ ERROR [E0719] //~| ERROR conflicting associated type bounds trait Trait2 { const ASSOC: u32; } type MustFail2 = dyn Trait2; //~^ ERROR [E0719] //~| ERROR conflicting associated type bounds type MustFail3 = dyn Iterator; //~^ ERROR [E0719] type MustFail4 = dyn Trait2; //~^ ERROR [E0719] trait Trait3 { fn foo() -> impl Iterator; } impl Trait3 for () { fn foo() -> impl Iterator { //~^ ERROR[E0271] //~| ERROR[E0271] [2u32].into_iter() } } fn main() { uncallable(iter::empty::()); //~ ERROR [E0271] uncallable(iter::empty::()); //~ ERROR [E0271] uncallable_const(()); //~ ERROR [E0271] uncallable_const(4u32); //~ ERROR [E0271] uncallable_rtn(()); //~ ERROR [E0271] uncallable_rtn(17u32); //~ ERROR [E0271] }