diff options
Diffstat (limited to 'tests/ui/regions/regions-infer-reborrow-ref-mut-recurse.rs')
-rw-r--r-- | tests/ui/regions/regions-infer-reborrow-ref-mut-recurse.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/ui/regions/regions-infer-reborrow-ref-mut-recurse.rs b/tests/ui/regions/regions-infer-reborrow-ref-mut-recurse.rs new file mode 100644 index 000000000..31a48b4ad --- /dev/null +++ b/tests/ui/regions/regions-infer-reborrow-ref-mut-recurse.rs @@ -0,0 +1,18 @@ +// run-pass +#![allow(dead_code)] +// Test an edge case in region inference: the lifetime of the borrow +// of `*x` must be extended to at least 'a. + +// pretty-expanded FIXME #23616 + +fn foo<'a,'b>(x: &'a &'b mut isize) -> &'a isize { + let y = &*x; // should be inferred to have type &'a &'b mut isize... + + // ...because if we inferred, say, &'x &'b mut isize where 'x <= 'a, + // this reborrow would be illegal: + &**y +} + +pub fn main() { + /* Just want to know that it compiles. */ +} |