2025-08-20 14:02:50 -04:00
|
|
|
// https://github.com/rust-lang/rust/issues/58734
|
2019-03-04 19:24:52 -08:00
|
|
|
trait Trait {
|
|
|
|
|
fn exists(self) -> ();
|
|
|
|
|
|
2024-10-09 23:31:01 +02:00
|
|
|
fn dyn_incompatible() -> Self;
|
2019-03-04 19:24:52 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Trait for () {
|
|
|
|
|
fn exists(self) -> () {
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-09 23:31:01 +02:00
|
|
|
fn dyn_incompatible() -> Self {
|
2019-03-04 19:24:52 -08:00
|
|
|
()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn main() {
|
2024-10-09 23:31:01 +02:00
|
|
|
// dyn-compatible or not, this call is OK
|
2019-03-04 19:24:52 -08:00
|
|
|
Trait::exists(());
|
2024-10-09 23:31:01 +02:00
|
|
|
// no dyn-compatibility error
|
2019-03-04 19:24:52 -08:00
|
|
|
Trait::nonexistent(());
|
2025-05-26 10:38:02 +00:00
|
|
|
//~^ WARN trait objects without an explicit `dyn` are deprecated
|
2021-07-10 10:00:54 +02:00
|
|
|
//~| WARN this is accepted in the current edition
|
2025-02-12 15:52:15 +01:00
|
|
|
//~| ERROR the trait `Trait` is not dyn compatible
|
2019-03-04 19:24:52 -08:00
|
|
|
}
|