]> git.lizzy.rs Git - rust.git/blob - src/test/ui/coherence/coherence-impl-trait-for-trait.rs
Merge commit 'f51aade56f93175dde89177a92e3669ebd8e7592' into clippyup
[rust.git] / src / test / ui / coherence / coherence-impl-trait-for-trait.rs
1 // Test that we give suitable error messages when the user attempts to
2 // impl a trait `Trait` for its own object type.
3
4 trait Foo { fn dummy(&self) { } }
5 trait Bar: Foo { }
6 trait Baz: Bar { }
7
8 // Supertraits of Baz are not legal:
9 impl Foo for dyn Baz { }
10 //~^ ERROR E0371
11 impl Bar for dyn Baz { }
12 //~^ ERROR E0371
13 impl Baz for dyn Baz { }
14 //~^ ERROR E0371
15
16 // But other random traits are:
17 trait Other { }
18 impl Other for dyn Baz { } // OK, Other not a supertrait of Baz
19
20 fn main() { }