diff options
Diffstat (limited to 'tests/ui/borrowck/borrowck-pat-reassign-no-binding.rs')
-rw-r--r-- | tests/ui/borrowck/borrowck-pat-reassign-no-binding.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/ui/borrowck/borrowck-pat-reassign-no-binding.rs b/tests/ui/borrowck/borrowck-pat-reassign-no-binding.rs new file mode 100644 index 000000000..1362fd8ce --- /dev/null +++ b/tests/ui/borrowck/borrowck-pat-reassign-no-binding.rs @@ -0,0 +1,14 @@ +// run-pass + +pub fn main() { + let mut x = None; + match x { + None => { + // It is ok to reassign x here, because there is in + // fact no outstanding loan of x! + x = Some(0); + } + Some(_) => { } + } + assert_eq!(x, Some(0)); +} |