]> git.lizzy.rs Git - rust.git/blob - src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.rs
Rollup merge of #99064 - lyming2007:issue-97687-fix, r=estebank
[rust.git] / src / test / ui / associated-type-bounds / assoc-type-eq-with-dyn-atb-fail.rs
1 // This test documents that `type Out = Box<dyn Bar<Assoc: Copy>>;`
2 // is allowed and will correctly reject an opaque `type Out` which
3 // does not satisfy the bound `<TheType as Bar>::Assoc: Copy`.
4 //
5 // FIXME(rust-lang/lang): I think this behavior is logical if we want to allow
6 // `dyn Trait<Assoc: Bound>` but we should decide if we want that. // Centril
7 //
8 // Additionally, as reported in https://github.com/rust-lang/rust/issues/63594,
9 // we check that the spans for the error message are sane here.
10
11 #![feature(associated_type_bounds)]
12
13 fn main() {}
14
15 trait Bar {
16     type Assoc;
17 }
18
19 trait Thing {
20     type Out;
21     fn func() -> Self::Out;
22 }
23
24 struct AssocNoCopy;
25 impl Bar for AssocNoCopy {
26     type Assoc = String;
27 }
28
29 impl Thing for AssocNoCopy {
30     type Out = Box<dyn Bar<Assoc: Copy>>;
31
32     fn func() -> Self::Out {
33         //~^ ERROR the trait bound `String: Copy` is not satisfied
34         Box::new(AssocNoCopy)
35     }
36 }