]>
Commit | Line | Data |
---|---|---|
b7449926 XL |
1 | // Regression test for #53570. Here, we need to propagate that `T: 'a` |
2 | // but in some versions of NLL we were propagating a stronger | |
3 | // requirement that `T: 'static`. This arose because we actually had | |
4 | // to propagate both that `T: 'a` but also `T: 'b` where `'b` is the | |
5 | // higher-ranked lifetime that appears in the type of the closure | |
6 | // parameter `x` -- since `'b` cannot be expressed in the caller's | |
7 | // space, that got promoted th `'static`. | |
8 | // | |
60c5eb7d | 9 | // check-pass |
b7449926 | 10 | |
b7449926 XL |
11 | use std::cell::{RefCell, Ref}; |
12 | ||
13 | trait AnyVec<'a> { | |
14 | } | |
15 | ||
16 | trait GenericVec<T> { | |
dc9dc135 | 17 | fn unwrap<'a, 'b>(vec: &'b dyn AnyVec<'a>) -> &'b [T] where T: 'a; |
b7449926 XL |
18 | } |
19 | ||
20 | struct Scratchpad<'a> { | |
dc9dc135 | 21 | buffers: RefCell<Box<dyn AnyVec<'a>>>, |
b7449926 XL |
22 | } |
23 | ||
24 | impl<'a> Scratchpad<'a> { | |
25 | fn get<T: GenericVec<T>>(&self) -> Ref<[T]> | |
26 | where T: 'a | |
27 | { | |
28 | Ref::map(self.buffers.borrow(), |x| T::unwrap(x.as_ref())) | |
29 | } | |
30 | } | |
31 | ||
32 | fn main() { } |