]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-19404.rs
Rollup merge of #62337 - Mark-Simulacrum:fix-cpu-usage-script, r=alexcrichton
[rust.git] / src / test / ui / issues / issue-19404.rs
1 // build-pass (FIXME(62277): could be check-pass?)
2 #![allow(dead_code)]
3 #![allow(unused_variables)]
4 use std::any::TypeId;
5 use std::rc::Rc;
6
7 type Fp<T> = Rc<T>;
8
9 struct Engine;
10
11 trait Component: 'static {}
12 impl Component for Engine {}
13
14 trait Env {
15     fn get_component_type_id(&self, type_id: TypeId) -> Option<Fp<dyn Component>>;
16 }
17
18 impl<'a> dyn Env + 'a {
19     fn get_component<T: Component>(&self) -> Option<Fp<T>> {
20         let x = self.get_component_type_id(TypeId::of::<T>());
21         None
22     }
23 }
24
25 trait Figment {
26     fn init(&mut self, env: &dyn Env);
27 }
28
29 struct MyFigment;
30
31 impl Figment for MyFigment {
32     fn init(&mut self, env: &dyn Env) {
33         let engine = env.get_component::<Engine>();
34     }
35 }
36
37 fn main() {}