]> git.proxmox.com Git - rustc.git/blame - src/test/ui/issues/issue-19404.rs
New upstream version 1.41.1+dfsg1
[rustc.git] / src / test / ui / issues / issue-19404.rs
CommitLineData
60c5eb7d 1// build-pass
0bf4aa26
XL
2#![allow(dead_code)]
3#![allow(unused_variables)]
c1a9b12d 4use std::any::TypeId;
c1a9b12d
SL
5use std::rc::Rc;
6
7type Fp<T> = Rc<T>;
8
9struct Engine;
10
9e0c209e 11trait Component: 'static {}
c1a9b12d
SL
12impl Component for Engine {}
13
14trait Env {
dc9dc135 15 fn get_component_type_id(&self, type_id: TypeId) -> Option<Fp<dyn Component>>;
c1a9b12d
SL
16}
17
dc9dc135 18impl<'a> dyn Env + 'a {
c1a9b12d
SL
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
25trait Figment {
dc9dc135 26 fn init(&mut self, env: &dyn Env);
c1a9b12d
SL
27}
28
29struct MyFigment;
30
31impl Figment for MyFigment {
dc9dc135 32 fn init(&mut self, env: &dyn Env) {
c1a9b12d
SL
33 let engine = env.get_component::<Engine>();
34 }
35}
36
37fn main() {}