1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Regression test for #53570. Here, we need to propagate that `T: 'a`
12 // but in some versions of NLL we were propagating a stronger
13 // requirement that `T: 'static`. This arose because we actually had
14 // to propagate both that `T: 'a` but also `T: 'b` where `'b` is the
15 // higher-ranked lifetime that appears in the type of the closure
16 // parameter `x` -- since `'b` cannot be expressed in the caller's
17 // space, that got promoted th `'static`.
22 #![feature(rustc_attrs)]
25 use std::cell::{RefCell, Ref};
31 fn unwrap<'a, 'b>(vec: &'b AnyVec<'a>) -> &'b [T] where T: 'a;
34 struct Scratchpad<'a> {
35 buffers: RefCell<Box<AnyVec<'a>>>,
38 impl<'a> Scratchpad<'a> {
39 fn get<T: GenericVec<T>>(&self) -> Ref<[T]>
42 Ref::map(self.buffers.borrow(), |x| T::unwrap(x.as_ref()))