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