2014-03-07 01:43:39 -06:00
|
|
|
// Tests that you can use a fn lifetime parameter as part of
|
|
|
|
// the value for a type parameter in a bound.
|
|
|
|
|
2022-04-19 05:56:18 -05:00
|
|
|
// revisions: base nll
|
|
|
|
// ignore-compare-mode-nll
|
|
|
|
//[nll] compile-flags: -Z borrowck=mir
|
|
|
|
|
2014-03-07 01:43:39 -06:00
|
|
|
trait GetRef<'a> {
|
2015-01-08 04:54:35 -06:00
|
|
|
fn get(&self) -> &'a isize;
|
2014-03-07 01:43:39 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
struct Box<'a> {
|
2015-01-08 04:54:35 -06:00
|
|
|
t: &'a isize
|
2014-03-07 01:43:39 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> GetRef<'a> for Box<'a> {
|
2015-01-08 04:54:35 -06:00
|
|
|
fn get(&self) -> &'a isize {
|
2014-03-07 01:43:39 -06:00
|
|
|
self.t
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> Box<'a> {
|
2015-01-08 04:54:35 -06:00
|
|
|
fn or<'b,G:GetRef<'b>>(&self, g2: G) -> &'a isize {
|
2015-01-12 00:01:44 -06:00
|
|
|
g2.get()
|
2022-04-19 05:56:18 -05:00
|
|
|
//[base]~^ ERROR E0312
|
|
|
|
//[nll]~^^ ERROR lifetime may not live long enough
|
2014-03-07 01:43:39 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
}
|