1 #![feature(specialization, associated_type_defaults)]
3 // Test that attempting to override a non-default method or one not in the
4 // parent impl causes an error.
9 fn foo(&self) -> bool { true }
12 // Specialization tree for Foo:
16 // Box<i32> Box<i64> Vec<()> Vec<bool>
18 impl<T> Foo for Box<T> {
21 fn foo(&self) -> bool { false }
25 impl Foo for Box<i32> {}
27 // Can't override a non-`default` fn
28 impl Foo for Box<i64> {
30 //~^ error: `Ty` specializes an item from a parent `impl`, but that item is not marked `default`
32 //~^ error: `CONST` specializes an item from a parent `impl`, but that item is not marked `default`
33 fn foo(&self) -> bool { true }
34 //~^ error: `foo` specializes an item from a parent `impl`, but that item is not marked `default`
38 // Doesn't mention the item = provided body/value is used and the method is final.
39 impl<T> Foo for Vec<T> {}
42 impl Foo for Vec<()> {}
44 impl Foo for Vec<bool> {
46 //~^ error: `Ty` specializes an item from a parent `impl`, but that item is not marked `default`
48 //~^ error: `CONST` specializes an item from a parent `impl`, but that item is not marked `default`
49 fn foo(&self) -> bool { true }
50 //~^ error: `foo` specializes an item from a parent `impl`, but that item is not marked `default`