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