From 17d4e9be2afba44c05135752b837bbd1b7b5bee6 Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Sun, 24 Dec 2017 13:37:39 +0200 Subject: Make killing of out-of-scope borrows a pre-statement effect Fixes #46875. Fixes #46917. Fixes #46935. --- .../two-phase-activation-sharing-interference.rs | 1 - src/test/ui/nll/borrow-use-issue-46875.rs | 30 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/nll/borrow-use-issue-46875.rs (limited to 'src/test') diff --git a/src/test/compile-fail/borrowck/two-phase-activation-sharing-interference.rs b/src/test/compile-fail/borrowck/two-phase-activation-sharing-interference.rs index b6f5e17f1f6..a9797e4d215 100644 --- a/src/test/compile-fail/borrowck/two-phase-activation-sharing-interference.rs +++ b/src/test/compile-fail/borrowck/two-phase-activation-sharing-interference.rs @@ -56,7 +56,6 @@ fn should_also_eventually_be_ok_with_nll() { let _z = &x; *y += 1; //[lxl]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable - //[nll]~^^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable } fn main() { } diff --git a/src/test/ui/nll/borrow-use-issue-46875.rs b/src/test/ui/nll/borrow-use-issue-46875.rs new file mode 100644 index 00000000000..47d69fe8e97 --- /dev/null +++ b/src/test/ui/nll/borrow-use-issue-46875.rs @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(nll)] + +// run-pass + +fn vec() { + let mut _x = vec!['c']; + let _y = &_x; + _x = Vec::new(); +} + +fn int() { + let mut _x = 5; + let _y = &_x; + _x = 7; +} + +fn main() { + vec(); + int(); +} -- cgit 1.4.1-3-g733a5