]> git.proxmox.com Git - rustc.git/blame - src/test/ui/coherence/coherence-impl-trait-for-trait.rs
New upstream version 1.37.0+dfsg1
[rustc.git] / src / test / ui / coherence / coherence-impl-trait-for-trait.rs
CommitLineData
9346a6ac
AL
1// Test that we give suitable error messages when the user attempts to
2// impl a trait `Trait` for its own object type.
3
0731742a
XL
4// revisions: old re
5
6#![cfg_attr(re, feature(re_rebalance_coherence))]
7
9346a6ac
AL
8trait Foo { fn dummy(&self) { } }
9trait Bar: Foo { }
10trait Baz: Bar { }
11
62682a34 12// Supertraits of Baz are not legal:
dc9dc135 13impl Foo for dyn Baz { }
0731742a
XL
14//[old]~^ ERROR E0371
15//[re]~^^ ERROR E0371
dc9dc135 16impl Bar for dyn Baz { }
0731742a
XL
17//[old]~^ ERROR E0371
18//[re]~^^ ERROR E0371
dc9dc135 19impl Baz for dyn Baz { }
0731742a
XL
20//[old]~^ ERROR E0371
21//[re]~^^ ERROR E0371
9346a6ac
AL
22
23// But other random traits are:
24trait Other { }
dc9dc135 25impl Other for dyn Baz { } // OK, Other not a supertrait of Baz
9346a6ac 26
9346a6ac 27fn main() { }