]> git.lizzy.rs Git - rust.git/blob - tests/ui/higher-rank-trait-bounds/hrtb-trait-object-passed-to-closure.rs
Rollup merge of #106797 - FawazTirmizi:dev/issues/104284, r=bjorn3
[rust.git] / tests / ui / higher-rank-trait-bounds / hrtb-trait-object-passed-to-closure.rs
1 // run-pass
2 #![allow(dead_code)]
3 // Test that `&PrinterSupport`, which is really short for `&'a
4 // PrinterSupport<'b>`, gets properly expanded when it appears in a
5 // closure type. This used to result in messed up De Bruijn indices.
6
7 // pretty-expanded FIXME #23616
8
9 trait PrinterSupport<'ast> {
10     fn ast_map(&self) -> Option<&'ast usize> { None }
11 }
12
13 struct NoAnn<'ast> {
14     f: Option<&'ast usize>
15 }
16
17 impl<'ast> PrinterSupport<'ast> for NoAnn<'ast> {
18 }
19
20 fn foo<'ast, G>(f: Option<&'ast usize>, g: G) where G: FnOnce(&dyn PrinterSupport) {
21     let annotation = NoAnn { f: f };
22     g(&annotation)
23 }
24
25 fn main() {}