]> git.lizzy.rs Git - rust.git/blob - src/test/ui/associated-types/associated-types-incomplete-object.rs
feat(rustdoc): open sidebar menu when links inside it are focused
[rust.git] / src / test / ui / associated-types / associated-types-incomplete-object.rs
1 // Check that the user gets an error if they omit a binding from an
2 // object type.
3
4 pub trait Foo {
5     type A;
6     type B;
7     fn boo(&self) -> <Self as Foo>::A;
8 }
9
10 struct Bar;
11
12 impl Foo for isize {
13     type A = usize;
14     type B = char;
15     fn boo(&self) -> usize {
16         42
17     }
18 }
19
20 pub fn main() {
21     let a = &42isize as &dyn Foo<A=usize, B=char>;
22
23     let b = &42isize as &dyn Foo<A=usize>;
24     //~^ ERROR the value of the associated type `B` (from trait `Foo`) must be specified
25
26     let c = &42isize as &dyn Foo<B=char>;
27     //~^ ERROR the value of the associated type `A` (from trait `Foo`) must be specified
28
29     let d = &42isize as &dyn Foo;
30     //~^ ERROR the value of the associated types `A` (from trait `Foo`), `B` (from trait
31 }