rust/tests/ui/impl-trait/in-trait/refine.rs

59 lines
1.0 KiB
Rust
Raw Normal View History

2023-09-01 23:02:11 -05:00
#![deny(refining_impl_trait)]
pub trait Foo {
2023-09-01 23:02:11 -05:00
fn bar() -> impl Sized;
}
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
}
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
}
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
}
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;
}
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
}
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() {}