rust/tests/ui/impl-trait/object-unsafe-trait-in-return-position-impl-trait.rs

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

47 lines
567 B
Rust
Raw Normal View History

trait NotObjectSafe {
fn foo() -> Self;
}
trait ObjectSafe {
fn bar(&self);
}
struct A;
struct B;
impl NotObjectSafe for A {
fn foo() -> Self {
A
}
}
impl NotObjectSafe for B {
fn foo() -> Self {
B
}
}
impl ObjectSafe for A {
fn bar(&self) {}
}
impl ObjectSafe for B {
fn bar(&self) {}
}
fn can() -> impl NotObjectSafe {
if true {
return A;
}
B //~ ERROR mismatched types
}
fn cat() -> impl ObjectSafe {
if true {
return A;
}
B //~ ERROR mismatched types
}
fn main() {}