]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/specialization/non-defaulted-item-fail.rs
1 #![feature(specialization, associated_type_defaults)]
2 //~^ WARN the feature `specialization` is incomplete
4 // Test that attempting to override a non-default method or one not in the
5 // parent impl causes an error.
10 fn foo(&self) -> bool { true }
13 // Specialization tree for Foo:
17 // Box<i32> Box<i64> Vec<()> Vec<bool>
19 impl<T
> Foo
for Box
<T
> {
22 fn foo(&self) -> bool { false }
26 impl Foo
for Box
<i32> {}
28 // Can't override a non-`default` fn
29 impl Foo
for Box
<i64> {
31 //~^ error: `Ty` specializes an item from a parent `impl`, but that item is not marked `default`
33 //~^ error: `CONST` specializes an item from a parent `impl`, but that item is not marked `default`
34 fn foo(&self) -> bool { true }
35 //~^ error: `foo` specializes an item from a parent `impl`, but that item is not marked `default`
39 // Doesn't mention the item = provided body/value is used and the method is final.
40 impl<T
> Foo
for Vec
<T
> {}
43 impl Foo
for Vec
<()> {}
45 impl Foo
for Vec
<bool
> {
47 //~^ error: `Ty` specializes an item from a parent `impl`, but that item is not marked `default`
49 //~^ error: `CONST` specializes an item from a parent `impl`, but that item is not marked `default`
50 fn foo(&self) -> bool { true }
51 //~^ error: `foo` specializes an item from a parent `impl`, but that item is not marked `default`