rust/tests/ui/issues/issue-19404.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

38 lines
686 B
Rust
Raw Normal View History

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