diff options
Diffstat (limited to 'tests/ui/regions/regions-infer-borrow-scope-within-loop-ok.rs')
-rw-r--r-- | tests/ui/regions/regions-infer-borrow-scope-within-loop-ok.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/ui/regions/regions-infer-borrow-scope-within-loop-ok.rs b/tests/ui/regions/regions-infer-borrow-scope-within-loop-ok.rs new file mode 100644 index 000000000..dca26742d --- /dev/null +++ b/tests/ui/regions/regions-infer-borrow-scope-within-loop-ok.rs @@ -0,0 +1,12 @@ +// run-pass + +fn borrow<T>(x: &T) -> &T {x} + +pub fn main() { + let x: Box<_> = Box::new(3); + loop { + let y = borrow(&*x); + assert_eq!(*x, *y); + break; + } +} |