2018-08-30 14:18:55 +02:00
|
|
|
// run-pass
|
2013-08-21 19:58:27 -07:00
|
|
|
// test for #8664
|
|
|
|
|
2015-02-12 10:29:52 -05:00
|
|
|
use std::marker;
|
|
|
|
|
2013-08-21 19:58:27 -07:00
|
|
|
pub trait Trait2<A> {
|
2015-02-12 10:29:52 -05:00
|
|
|
fn doit(&self) -> A;
|
2013-08-21 19:58:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
pub struct Impl<A1, A2, A3> {
|
2015-02-12 10:29:52 -05:00
|
|
|
m1: marker::PhantomData<(A1,A2,A3)>,
|
2013-08-21 19:58:27 -07:00
|
|
|
/*
|
|
|
|
* With A2 we get the ICE:
|
2014-02-05 16:33:10 -06:00
|
|
|
* task <unnamed> failed at 'index out of bounds: the len is 1 but the index is 1',
|
|
|
|
* src/librustc/middle/subst.rs:58
|
2013-08-21 19:58:27 -07:00
|
|
|
*/
|
2019-05-28 14:47:21 -04:00
|
|
|
t: Box<dyn Trait2<A2>+'static>
|
2013-08-21 19:58:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<A1, A2, A3> Impl<A1, A2, A3> {
|
|
|
|
pub fn step(&self) {
|
2015-02-12 10:29:52 -05:00
|
|
|
self.t.doit();
|
2013-08-21 19:58:27 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-21 19:11:30 -07:00
|
|
|
// test for #8601
|
|
|
|
|
2022-07-25 22:36:03 +02:00
|
|
|
enum Type<T> { Constant(#[allow(unused_tuple_struct_fields)] T) }
|
2013-08-21 19:11:30 -07:00
|
|
|
|
|
|
|
trait Trait<K,V> {
|
2017-06-25 05:29:10 +03:00
|
|
|
fn method(&self, _: Type<(K,V)>) -> isize;
|
2013-08-21 19:11:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<V> Trait<u8,V> for () {
|
2015-03-25 17:06:52 -07:00
|
|
|
fn method(&self, _x: Type<(u8,V)>) -> isize { 0 }
|
2013-08-21 19:11:30 -07:00
|
|
|
}
|
|
|
|
|
2014-02-07 00:38:33 +02:00
|
|
|
pub fn main() {
|
2021-08-25 02:39:40 +02:00
|
|
|
let a = Box::new(()) as Box<dyn Trait<u8, u8>>;
|
2015-03-03 10:42:26 +02:00
|
|
|
assert_eq!(a.method(Type::Constant((1, 2))), 0);
|
2013-08-21 19:11:30 -07:00
|
|
|
}
|