1 // Regression test for #53548. The `Box<dyn Trait>` type below is
2 // expanded to `Box<dyn Trait + 'static>`, but the generator "witness"
3 // that results is `for<'r> { Box<dyn Trait + 'r> }`. The WF code was
4 // encountering an ICE (when debug-assertions were enabled) and an
5 // unexpected compilation error (without debug-asserions) when trying
6 // to process this `'r` region bound. In particular, to be WF, the
7 // region bound must meet the requirements of the trait, and hence we
8 // got `for<'r> { 'r: 'static }`. This would ICE because the `Binder`
9 // constructor we were using was assering that no higher-ranked
10 // regions were involved (because the WF code is supposed to skip
11 // those). The error (if debug-asserions were disabled) came because
12 // we obviously cannot prove that `'r: 'static` for any region `'r`.
13 // Pursuant with our "lazy WF" strategy for higher-ranked regions, the
14 // fix is not to require that `for<'r> { 'r: 'static }` holds (this is
15 // also analogous to what we would do for higher-ranked regions
16 // appearing within the trait in other positions).
20 #![feature(generators)]
22 use std::cell::RefCell;
25 trait Trait: 'static {}
28 inner: Rc<RefCell<Option<C>>>,
32 Box::new(static move || {
33 let store = Store::<Box<dyn Trait>> {
34 inner: Default::default(),