rust/src/test/ui/issues/issue-19404.rs

38 lines
723 B
Rust
Raw Normal View History

// build-pass (FIXME(62277): could be check-pass?)
#![allow(dead_code)]
#![allow(unused_variables)]
2015-07-20 07:39:51 -05:00
use std::any::TypeId;
use std::rc::Rc;
type Fp<T> = Rc<T>;
struct Engine;
trait Component: 'static {}
2015-07-20 07:39:51 -05:00
impl Component for Engine {}
trait Env {
2019-05-28 13:46:13 -05:00
fn get_component_type_id(&self, type_id: TypeId) -> Option<Fp<dyn Component>>;
2015-07-20 07:39:51 -05:00
}
2019-05-28 13:46:13 -05:00
impl<'a> dyn Env + 'a {
2015-07-20 07:39:51 -05:00
fn get_component<T: Component>(&self) -> Option<Fp<T>> {
let x = self.get_component_type_id(TypeId::of::<T>());
None
}
}
trait Figment {
2019-05-28 13:46:13 -05:00
fn init(&mut self, env: &dyn Env);
2015-07-20 07:39:51 -05:00
}
struct MyFigment;
impl Figment for MyFigment {
2019-05-28 13:46:13 -05:00
fn init(&mut self, env: &dyn Env) {
2015-07-20 07:39:51 -05:00
let engine = env.get_component::<Engine>();
}
}
fn main() {}