diff options
| author | bobtwinkles <srkoser+github@gmail.com> | 2018-04-04 23:08:10 -0400 |
|---|---|---|
| committer | bobtwinkles <srkoser+github@gmail.com> | 2018-04-04 23:08:10 -0400 |
| commit | 0801bd1d0ea3858aa6a65ecca4602ae2a15902f9 (patch) | |
| tree | ee42b934645996b6b1d9746913c9b54747ccdd95 /src/test/ui/borrowck | |
| parent | 17fea66ba46bb32d1a49495518d899cede1d298a (diff) | |
| download | rust-0801bd1d0ea3858aa6a65ecca4602ae2a15902f9.tar.gz rust-0801bd1d0ea3858aa6a65ecca4602ae2a15902f9.zip | |
two-phase borrows: support multiple activations in one statement
The need for this has arisen since the introduction of two-phase borrows on method autorefs. Fixes 49635 Fixes 49662
Diffstat (limited to 'src/test/ui/borrowck')
| -rw-r--r-- | src/test/ui/borrowck/two-phase-multiple-activations.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/test/ui/borrowck/two-phase-multiple-activations.rs b/src/test/ui/borrowck/two-phase-multiple-activations.rs new file mode 100644 index 00000000000..e1ed41bfb2c --- /dev/null +++ b/src/test/ui/borrowck/two-phase-multiple-activations.rs @@ -0,0 +1,35 @@ +// Copyright 2018 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. + +// revisions: lxl nll +//[lxl]compile-flags: -Z borrowck=mir -Z two-phase-borrows +//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll + +// run-pass + +use std::io::Result; + +struct Foo {} + +pub trait FakeRead { + fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize>; +} + +impl FakeRead for Foo { + fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize> { + Ok(4) + } +} + +fn main() { + let mut a = Foo {}; + let mut v = Vec::new(); + a.read_to_end(&mut v); +} |
