]> git.proxmox.com Git - rustc.git/blame - src/test/run-pass/trait-object-generics.rs
New upstream version 1.20.0+dfsg1
[rustc.git] / src / test / run-pass / trait-object-generics.rs
CommitLineData
1a4d82fc
JJ
1// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
11// test for #8664
12
c34b1796 13
1a4d82fc
JJ
14#![allow(unknown_features)]
15#![feature(box_syntax)]
16
85aaf69f
SL
17use std::marker;
18
1a4d82fc 19pub trait Trait2<A> {
85aaf69f 20 fn doit(&self) -> A;
1a4d82fc
JJ
21}
22
23pub struct Impl<A1, A2, A3> {
85aaf69f 24 m1: marker::PhantomData<(A1,A2,A3)>,
1a4d82fc
JJ
25 /*
26 * With A2 we get the ICE:
27 * task <unnamed> failed at 'index out of bounds: the len is 1 but the index is 1',
28 * src/librustc/middle/subst.rs:58
29 */
30 t: Box<Trait2<A2>+'static>
31}
32
33impl<A1, A2, A3> Impl<A1, A2, A3> {
34 pub fn step(&self) {
85aaf69f 35 self.t.doit();
1a4d82fc
JJ
36 }
37}
38
39// test for #8601
40
85aaf69f 41enum Type<T> { Constant(T) }
1a4d82fc
JJ
42
43trait Trait<K,V> {
041b39d2 44 fn method(&self, _: Type<(K,V)>) -> isize;
1a4d82fc
JJ
45}
46
47impl<V> Trait<u8,V> for () {
c34b1796 48 fn method(&self, _x: Type<(u8,V)>) -> isize { 0 }
1a4d82fc
JJ
49}
50
51pub fn main() {
b039eaaf 52 let a = box () as Box<Trait<u8, u8>>;
c34b1796 53 assert_eq!(a.method(Type::Constant((1, 2))), 0);
1a4d82fc 54}