]> git.lizzy.rs Git - rust.git/blob - src/test/ui/generator/issue-53548.rs
Auto merge of #102655 - joboet:windows_tls_opt, r=ChrisDenton
[rust.git] / src / test / ui / generator / issue-53548.rs
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).
17 //
18 // check-pass
19
20 #![feature(generators)]
21
22 use std::cell::RefCell;
23 use std::rc::Rc;
24
25 trait Trait: 'static {}
26
27 struct Store<C> {
28     inner: Rc<RefCell<Option<C>>>,
29 }
30
31 fn main() {
32     Box::new(static move || {
33         let store = Store::<Box<dyn Trait>> {
34             inner: Default::default(),
35         };
36         yield ();
37     });
38 }