diff options
| author | Josh Leeb-du Toit <josh.leebdutoit@gmail.com> | 2017-10-30 09:58:45 +1100 |
|---|---|---|
| committer | Josh Leeb-du Toit <josh.leebdutoit@gmail.com> | 2017-10-30 11:28:44 +1100 |
| commit | cf10bcfe4861ce01fe932300fa64dbb4484f3ef7 (patch) | |
| tree | f7415cac70d034983ce32ddd72c0566157aeeae0 /src/test/ui | |
| parent | 37f2382435816b0ddfc3e46a856463810f66862c (diff) | |
| download | rust-cf10bcfe4861ce01fe932300fa64dbb4484f3ef7.tar.gz rust-cf10bcfe4861ce01fe932300fa64dbb4484f3ef7.zip | |
Move issue-42106 test from compile-fail to ui
Diffstat (limited to 'src/test/ui')
| -rw-r--r-- | src/test/ui/issue-42106.rs | 16 | ||||
| -rw-r--r-- | src/test/ui/issue-42106.stderr | 12 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/test/ui/issue-42106.rs b/src/test/ui/issue-42106.rs new file mode 100644 index 00000000000..f13f1dd1145 --- /dev/null +++ b/src/test/ui/issue-42106.rs @@ -0,0 +1,16 @@ +// Copyright 2017 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. + +fn do_something<T>(collection: &mut Vec<T>) { + let _a = &collection; + collection.swap(1, 2); +} + +fn main() {} diff --git a/src/test/ui/issue-42106.stderr b/src/test/ui/issue-42106.stderr new file mode 100644 index 00000000000..481cdb5f5b2 --- /dev/null +++ b/src/test/ui/issue-42106.stderr @@ -0,0 +1,12 @@ +error[E0502]: cannot borrow `*collection` as mutable because `collection` is also borrowed as immutable + --> $DIR/issue-42106.rs:13:5 + | +12 | let _a = &collection; + | ---------- immutable borrow occurs here +13 | collection.swap(1, 2); + | ^^^^^^^^^^ mutable borrow occurs here +14 | } + | - immutable borrow ends here + +error: aborting due to 2 previous errors + |
