2019-03-12 14:57:06 +00:00
|
|
|
// Regression test for #53548. The `Box<dyn Trait>` type below is
|
2023-10-19 21:46:28 +00:00
|
|
|
// expanded to `Box<dyn Trait + 'static>`, but the coroutine "witness"
|
2019-03-12 14:57:06 +00:00
|
|
|
// that results is `for<'r> { Box<dyn Trait + 'r> }`. The WF code was
|
|
|
|
// encountering an ICE (when debug-assertions were enabled) and an
|
|
|
|
// unexpected compilation error (without debug-asserions) when trying
|
|
|
|
// to process this `'r` region bound. In particular, to be WF, the
|
|
|
|
// region bound must meet the requirements of the trait, and hence we
|
|
|
|
// got `for<'r> { 'r: 'static }`. This would ICE because the `Binder`
|
|
|
|
// constructor we were using was assering that no higher-ranked
|
|
|
|
// regions were involved (because the WF code is supposed to skip
|
|
|
|
// those). The error (if debug-asserions were disabled) came because
|
|
|
|
// we obviously cannot prove that `'r: 'static` for any region `'r`.
|
|
|
|
// Pursuant with our "lazy WF" strategy for higher-ranked regions, the
|
|
|
|
// fix is not to require that `for<'r> { 'r: 'static }` holds (this is
|
|
|
|
// also analogous to what we would do for higher-ranked regions
|
|
|
|
// appearing within the trait in other positions).
|
|
|
|
//
|
2019-11-04 00:00:00 +00:00
|
|
|
// check-pass
|
2019-03-12 14:57:06 +00:00
|
|
|
|
2023-10-19 21:46:28 +00:00
|
|
|
#![feature(coroutines)]
|
2019-03-12 14:57:06 +00:00
|
|
|
|
|
|
|
use std::cell::RefCell;
|
|
|
|
use std::rc::Rc;
|
|
|
|
|
|
|
|
trait Trait: 'static {}
|
|
|
|
|
|
|
|
struct Store<C> {
|
|
|
|
inner: Rc<RefCell<Option<C>>>,
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
Box::new(static move || {
|
|
|
|
let store = Store::<Box<dyn Trait>> {
|
|
|
|
inner: Default::default(),
|
|
|
|
};
|
|
|
|
yield ();
|
|
|
|
});
|
|
|
|
}
|