2018-08-30 14:18:55 +02:00
|
|
|
//@ run-pass
|
2018-09-25 23:51:35 +02:00
|
|
|
#![allow(unused_imports)]
|
2013-11-15 17:04:01 -05:00
|
|
|
// Test that we are able to compile calls to associated fns like
|
|
|
|
// `decode()` where the bound on the `Self` parameter references a
|
|
|
|
// lifetime parameter of the trait. This example indicates why trait
|
|
|
|
// lifetime parameters must be early bound in the type of the
|
|
|
|
// associated item.
|
|
|
|
|
2015-03-22 13:13:15 -07:00
|
|
|
//@ pretty-expanded FIXME #23616
|
|
|
|
|
2015-02-12 10:29:52 -05:00
|
|
|
use std::marker;
|
|
|
|
|
2013-11-15 17:04:01 -05:00
|
|
|
pub enum Value<'v> {
|
|
|
|
A(&'v str),
|
|
|
|
B,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait Decoder<'v> {
|
|
|
|
fn read(&mut self) -> Value<'v>;
|
|
|
|
}
|
|
|
|
|
2015-03-31 19:58:01 -04:00
|
|
|
pub trait Decodable<'v, D: Decoder<'v>> {
|
2013-11-15 17:04:01 -05:00
|
|
|
fn decode(d: &mut D) -> Self;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'v, D: Decoder<'v>> Decodable<'v, D> for () {
|
|
|
|
fn decode(d: &mut D) -> () {
|
|
|
|
match d.read() {
|
2014-11-06 00:05:53 -08:00
|
|
|
Value::A(..) => (),
|
|
|
|
Value::B => Decodable::decode(d),
|
2013-11-15 17:04:01 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-05 18:25:01 -05:00
|
|
|
pub fn main() { }
|