]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/try-block/try-block-maybe-bad-lifetime.rs
1 // compile-flags: --edition 2018
3 #![feature(try_blocks)]
6 fn do_something_with
<T
>(_x
: T
) {}
8 // This test checks that borrows made and returned inside try blocks are properly constrained
11 // Test that a borrow which *might* be returned still freezes its referent
13 let x
: Result
<&i32, ()> = try
{
17 i
= 0; //~ ERROR cannot assign to `i` because it is borrowed
23 let x
= String
::new();
24 let _y
: Result
<(), ()> = try
{
28 println
!("{}", x
); //~ ERROR borrow of moved value: `x`
32 // Test that a borrow which *might* be assigned to an outer variable still freezes
36 let _x
: Result
<(), ()> = try
{
40 i
= 0; //~ ERROR cannot assign to `i` because it is borrowed