]> git.lizzy.rs Git - rust.git/blob - tests/ui/const_prop/issue-102553.rs
Rollup merge of #106625 - Swatinem:ref/cov6, r=nagisa
[rust.git] / tests / ui / const_prop / issue-102553.rs
1 // compile-flags: --crate-type=lib
2 // check-pass
3
4 pub trait Widget<E> {
5     fn boxed<'w>(self) -> Box<dyn WidgetDyn<E> + 'w>
6     where
7         Self: Sized + 'w;
8 }
9
10 pub trait WidgetDyn<E> {}
11
12 impl<T, E> WidgetDyn<E> for T where T: Widget<E> {}
13
14 impl<E> Widget<E> for dyn WidgetDyn<E> + '_ {
15     fn boxed<'w>(self) -> Box<dyn WidgetDyn<E> + 'w>
16     where
17         Self: Sized + 'w,
18     {
19         // Even though this is illegal to const evaluate, this should never
20         // trigger an ICE because it can never be called from actual code
21         // (due to the trivially false where-clause predicate).
22         Box::new(self)
23     }
24 }