2013-06-19 11:32:56 -05:00
|
|
|
// Test that free regions ordering only goes one way. That is,
|
2013-12-10 01:16:18 -06:00
|
|
|
// we have `&'a Node<'b, T>`, which implies that `'a <= 'b`,
|
2018-11-26 20:59:49 -06:00
|
|
|
// but not `'b <= 'a`. Hence, returning `&self.val` (which has lifetime
|
2013-12-10 01:16:18 -06:00
|
|
|
// `'a`) where `'b` is expected yields an error.
|
2013-06-19 11:32:56 -05:00
|
|
|
//
|
|
|
|
// This test began its life as a test for issue #4325.
|
|
|
|
|
2018-11-26 20:59:49 -06:00
|
|
|
struct Node<'b, T: 'b> {
|
|
|
|
val: T,
|
|
|
|
next: Option<&'b Node<'b, T>>
|
2013-03-28 21:24:17 -05:00
|
|
|
}
|
|
|
|
|
2013-12-10 01:16:18 -06:00
|
|
|
impl<'b, T> Node<'b, T> {
|
2018-11-26 20:59:49 -06:00
|
|
|
fn get<'a>(&'a self) -> &'b T {
|
2022-04-01 12:13:25 -05:00
|
|
|
match self.next { //~ ERROR lifetime may not live long enough
|
2018-11-26 20:59:49 -06:00
|
|
|
Some(ref next) => next.get(),
|
2022-04-01 12:13:25 -05:00
|
|
|
None => &self.val
|
2018-11-26 20:59:49 -06:00
|
|
|
}
|
2013-03-28 21:24:17 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|