]> git.proxmox.com Git - rustc.git/blob - src/test/ui/traits/trait-object-generics.rs
New upstream version 1.51.0+dfsg1
[rustc.git] / src / test / ui / traits / trait-object-generics.rs
1 // run-pass
2 // test for #8664
3
4 #![feature(box_syntax)]
5
6 use std::marker;
7
8 pub trait Trait2<A> {
9 fn doit(&self) -> A;
10 }
11
12 pub struct Impl<A1, A2, A3> {
13 m1: marker::PhantomData<(A1,A2,A3)>,
14 /*
15 * With A2 we get the ICE:
16 * task <unnamed> failed at 'index out of bounds: the len is 1 but the index is 1',
17 * src/librustc/middle/subst.rs:58
18 */
19 t: Box<dyn Trait2<A2>+'static>
20 }
21
22 impl<A1, A2, A3> Impl<A1, A2, A3> {
23 pub fn step(&self) {
24 self.t.doit();
25 }
26 }
27
28 // test for #8601
29
30 enum Type<T> { Constant(T) }
31
32 trait Trait<K,V> {
33 fn method(&self, _: Type<(K,V)>) -> isize;
34 }
35
36 impl<V> Trait<u8,V> for () {
37 fn method(&self, _x: Type<(u8,V)>) -> isize { 0 }
38 }
39
40 pub fn main() {
41 let a = box () as Box<dyn Trait<u8, u8>>;
42 assert_eq!(a.method(Type::Constant((1, 2))), 0);
43 }