2023-09-01 23:02:11 -05:00
|
|
|
#![feature(return_position_impl_trait_in_trait, async_fn_in_trait)]
|
|
|
|
#![deny(refining_impl_trait)]
|
|
|
|
|
2023-09-06 19:45:12 -05:00
|
|
|
pub trait Foo {
|
2023-09-01 23:02:11 -05:00
|
|
|
fn bar() -> impl Sized;
|
|
|
|
}
|
|
|
|
|
2023-09-06 19:45:12 -05:00
|
|
|
pub struct A;
|
2023-09-01 23:02:11 -05:00
|
|
|
impl Foo for A {
|
|
|
|
fn bar() -> impl Copy {}
|
|
|
|
//~^ ERROR impl method signature does not match trait method signature
|
|
|
|
}
|
|
|
|
|
2023-09-06 19:45:12 -05:00
|
|
|
pub struct B;
|
2023-09-01 23:02:11 -05:00
|
|
|
impl Foo for B {
|
|
|
|
fn bar() {}
|
|
|
|
//~^ ERROR impl method signature does not match trait method signature
|
|
|
|
}
|
|
|
|
|
2023-09-06 19:45:12 -05:00
|
|
|
pub struct C;
|
2023-09-01 23:02:11 -05:00
|
|
|
impl Foo for C {
|
|
|
|
fn bar() -> () {}
|
|
|
|
//~^ ERROR impl method signature does not match trait method signature
|
|
|
|
}
|
|
|
|
|
2023-09-06 19:45:12 -05:00
|
|
|
struct Private;
|
|
|
|
impl Foo for Private {
|
|
|
|
fn bar() -> () {}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait Arg<A> {
|
|
|
|
fn bar() -> impl Sized;
|
|
|
|
}
|
|
|
|
impl Arg<Private> for A {
|
|
|
|
fn bar() -> () {}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait Late {
|
2023-09-01 23:02:11 -05:00
|
|
|
fn bar<'a>(&'a self) -> impl Sized + 'a;
|
|
|
|
}
|
|
|
|
|
2023-09-06 19:45:12 -05:00
|
|
|
pub struct D;
|
2023-09-01 23:02:11 -05:00
|
|
|
impl Late for D {
|
|
|
|
fn bar(&self) -> impl Copy + '_ {}
|
|
|
|
//~^ ERROR impl method signature does not match trait method signature
|
|
|
|
}
|
|
|
|
|
2023-09-29 13:36:20 -05:00
|
|
|
mod unreachable {
|
|
|
|
pub trait UnreachablePub {
|
|
|
|
fn bar() -> impl Sized;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct E;
|
|
|
|
impl UnreachablePub for E {
|
|
|
|
fn bar() {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-01 23:02:11 -05:00
|
|
|
fn main() {}
|