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