2020-01-09 10:56:38 +00:00
|
|
|
#![feature(negative_impls)]
|
2019-01-03 21:46:46 +00:00
|
|
|
#![allow(order_dependent_trait_objects)]
|
|
|
|
|
|
|
|
// Check that the issue #33140 hack does not allow unintended things.
|
|
|
|
|
|
|
|
// OK
|
2020-01-08 19:10:59 +00:00
|
|
|
trait Trait0 {}
|
2019-01-03 21:46:46 +00:00
|
|
|
|
|
|
|
impl Trait0 for dyn Send {}
|
|
|
|
impl Trait0 for dyn Send {}
|
|
|
|
|
|
|
|
// Problem 1: associated types
|
|
|
|
trait Trait1 {
|
|
|
|
fn my_fn(&self) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Trait1 for dyn Send {}
|
|
|
|
impl Trait1 for dyn Send {}
|
|
|
|
//~^ ERROR E0119
|
|
|
|
|
|
|
|
// Problem 2: negative impl
|
2020-01-08 19:10:59 +00:00
|
|
|
trait Trait2 {}
|
2019-01-03 21:46:46 +00:00
|
|
|
|
|
|
|
impl Trait2 for dyn Send {}
|
|
|
|
impl !Trait2 for dyn Send {}
|
2020-04-22 12:18:22 +00:00
|
|
|
//~^ ERROR E0751
|
2019-01-03 21:46:46 +00:00
|
|
|
|
|
|
|
// Problem 3: type parameter
|
2020-01-08 19:10:59 +00:00
|
|
|
trait Trait3<T: ?Sized> {}
|
2019-01-03 21:46:46 +00:00
|
|
|
|
|
|
|
impl Trait3<dyn Sync> for dyn Send {}
|
|
|
|
impl Trait3<dyn Sync> for dyn Send {}
|
|
|
|
//~^ ERROR E0119
|
|
|
|
|
|
|
|
// Problem 4a: not a trait object - generic
|
2020-01-08 19:10:59 +00:00
|
|
|
trait Trait4a {}
|
2019-01-03 21:46:46 +00:00
|
|
|
|
|
|
|
impl<T: ?Sized> Trait4a for T {}
|
|
|
|
impl Trait4a for dyn Send {}
|
|
|
|
//~^ ERROR E0119
|
|
|
|
|
|
|
|
// Problem 4b: not a trait object - misc
|
2020-01-08 19:10:59 +00:00
|
|
|
trait Trait4b {}
|
2019-01-03 21:46:46 +00:00
|
|
|
|
|
|
|
impl Trait4b for () {}
|
|
|
|
impl Trait4b for () {}
|
|
|
|
//~^ ERROR E0119
|
|
|
|
|
|
|
|
// Problem 4c: not a principal-less trait object
|
2020-01-08 19:10:59 +00:00
|
|
|
trait Trait4c {}
|
2019-01-03 21:46:46 +00:00
|
|
|
|
|
|
|
impl Trait4c for dyn Trait1 + Send {}
|
|
|
|
impl Trait4c for dyn Trait1 + Send {}
|
|
|
|
//~^ ERROR E0119
|
|
|
|
|
|
|
|
// Problem 4d: lifetimes
|
2020-01-08 19:10:59 +00:00
|
|
|
trait Trait4d {}
|
2019-01-03 21:46:46 +00:00
|
|
|
|
|
|
|
impl<'a> Trait4d for dyn Send + 'a {}
|
|
|
|
impl<'a> Trait4d for dyn Send + 'a {}
|
|
|
|
//~^ ERROR E0119
|
|
|
|
|
|
|
|
// Problem 5: where-clauses
|
2020-01-08 19:10:59 +00:00
|
|
|
trait Trait5 {}
|
2019-01-03 21:46:46 +00:00
|
|
|
|
|
|
|
impl Trait5 for dyn Send {}
|
|
|
|
impl Trait5 for dyn Send where u32: Copy {}
|
|
|
|
//~^ ERROR E0119
|
|
|
|
|
|
|
|
fn main() {}
|