diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2016-02-18 05:21:15 -0500 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2016-02-24 18:40:39 -0500 |
| commit | 6660ad6f8df0fcbe5120093ec63e0a3e81a54327 (patch) | |
| tree | 891a4154750a46c8020f8bdcde3973be04dd7912 /src/test/compile-fail/borrowck-anon-fields-struct.rs | |
| parent | 1c850d8448c3e19a0c650fa6ebe10db23b0b3ab9 (diff) | |
| download | rust-6660ad6f8df0fcbe5120093ec63e0a3e81a54327.tar.gz rust-6660ad6f8df0fcbe5120093ec63e0a3e81a54327.zip | |
Move the borrowck run-pass/compile-fail tests into their own directories
as a test.
Diffstat (limited to 'src/test/compile-fail/borrowck-anon-fields-struct.rs')
| -rw-r--r-- | src/test/compile-fail/borrowck-anon-fields-struct.rs | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/src/test/compile-fail/borrowck-anon-fields-struct.rs b/src/test/compile-fail/borrowck-anon-fields-struct.rs deleted file mode 100644 index 5ee2b89dd98..00000000000 --- a/src/test/compile-fail/borrowck-anon-fields-struct.rs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that we are able to distinguish when loans borrow different -// anonymous fields of a tuple vs the same anonymous field. - -struct Y(usize, usize); - -fn distinct_variant() { - let mut y = Y(1, 2); - - let a = match y { - Y(ref mut a, _) => a - }; - - let b = match y { - Y(_, ref mut b) => b - }; - - *a += 1; - *b += 1; -} - -fn same_variant() { - let mut y = Y(1, 2); - - let a = match y { - Y(ref mut a, _) => a - }; - - let b = match y { - Y(ref mut b, _) => b //~ ERROR cannot borrow - }; - - *a += 1; - *b += 1; -} - -fn main() { -} |
