]> git.lizzy.rs Git - rust.git/blob - tests/mir-opt/inline/dyn_trait.rs
Rollup merge of #106644 - alexcrichton:update-wasi-toolchain, r=cuviper
[rust.git] / tests / mir-opt / inline / dyn_trait.rs
1 #![crate_type = "lib"]
2
3 use std::fmt::Debug;
4
5 pub trait Cache {
6     type V: Debug;
7
8     fn store_nocache(&self);
9 }
10
11 pub trait Query {
12     type V;
13     type C: Cache<V = Self::V>;
14
15     fn cache<T>(s: &T) -> &Self::C;
16 }
17
18 // EMIT_MIR dyn_trait.mk_cycle.Inline.diff
19 #[inline(always)]
20 pub fn mk_cycle<V: Debug>(c: &dyn Cache<V = V>) {
21     c.store_nocache()
22 }
23
24 // EMIT_MIR dyn_trait.try_execute_query.Inline.diff
25 #[inline(always)]
26 pub fn try_execute_query<C: Cache>(c: &C) {
27     mk_cycle(c)
28 }
29
30 // EMIT_MIR dyn_trait.get_query.Inline.diff
31 #[inline(always)]
32 pub fn get_query<Q: Query, T>(t: &T) {
33     let c = Q::cache(t);
34     try_execute_query(c)
35 }