diff options
| -rw-r--r-- | src/test/ui/issues/issue-17263.ast.stderr (renamed from src/test/ui/issues/issue-17263.stderr) | 2 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-17263.nll.stderr | 6 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-17263.rs | 38 |
3 files changed, 29 insertions, 17 deletions
diff --git a/src/test/ui/issues/issue-17263.stderr b/src/test/ui/issues/issue-17263.ast.stderr index 4767fbbcfbb..3d42dcb52f5 100644 --- a/src/test/ui/issues/issue-17263.stderr +++ b/src/test/ui/issues/issue-17263.ast.stderr @@ -16,7 +16,7 @@ LL | let (c, d) = (&mut foo.a, &foo.b); | ----- ^^^^^ immutable borrow occurs here (via `foo.b`) | | | mutable borrow occurs here (via `foo.a`) -LL | //~^ ERROR cannot borrow `foo` (via `foo.b`) as immutable +... LL | } | - mutable borrow ends here diff --git a/src/test/ui/issues/issue-17263.nll.stderr b/src/test/ui/issues/issue-17263.nll.stderr index d6009e8078d..cdb574b8b9f 100644 --- a/src/test/ui/issues/issue-17263.nll.stderr +++ b/src/test/ui/issues/issue-17263.nll.stderr @@ -1,12 +1,12 @@ error: compilation successful --> $DIR/issue-17263.rs:15:1 | -LL | / fn main() { #![rustc_error] // rust-lang/rust#49855 +LL | / fn main() { //[nll]~ ERROR compilation successful LL | | let mut x: Box<_> = box Foo { a: 1, b: 2 }; LL | | let (a, b) = (&mut x.a, &mut x.b); -LL | | //~^ ERROR cannot borrow `x` (via `x.b`) as mutable more than once at a time +LL | | //[ast]~^ ERROR cannot borrow `x` (via `x.b`) as mutable more than once at a time ... | -LL | | //~^ ERROR cannot borrow `foo` (via `foo.b`) as immutable +LL | | use_mut(a); LL | | } | |_^ diff --git a/src/test/ui/issues/issue-17263.rs b/src/test/ui/issues/issue-17263.rs index b251f9a4152..754f3b90aac 100644 --- a/src/test/ui/issues/issue-17263.rs +++ b/src/test/ui/issues/issue-17263.rs @@ -1,23 +1,35 @@ -// 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. +// This checks diagnostic quality for cases where AST-borrowck treated +// `Box<T>` as other types (see rust-lang/rfcs#130). NLL again treats +// `Box<T>` specially. We capture the differences via revisions. +// revisions: ast nll +//[ast]compile-flags: -Z borrowck=ast +//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows + +// don't worry about the --compare-mode=nll on this test. +// ignore-compare-mode-nll #![feature(box_syntax, rustc_attrs)] struct Foo { a: isize, b: isize } - -fn main() { #![rustc_error] // rust-lang/rust#49855 +#[rustc_error] // rust-lang/rust#49855 +fn main() { //[nll]~ ERROR compilation successful let mut x: Box<_> = box Foo { a: 1, b: 2 }; let (a, b) = (&mut x.a, &mut x.b); - //~^ ERROR cannot borrow `x` (via `x.b`) as mutable more than once at a time + //[ast]~^ ERROR cannot borrow `x` (via `x.b`) as mutable more than once at a time let mut foo: Box<_> = box Foo { a: 1, b: 2 }; let (c, d) = (&mut foo.a, &foo.b); - //~^ ERROR cannot borrow `foo` (via `foo.b`) as immutable + //[ast]~^ ERROR cannot borrow `foo` (via `foo.b`) as immutable + + // We explicitly use the references created above to illustrate + // that NLL is accepting this code *not* because of artificially + // short lifetimes, but rather because it understands that all the + // references are of disjoint parts of memory. + use_imm(d); + use_mut(c); + use_mut(b); + use_mut(a); } + +fn use_mut<T>(_: &mut T) { } +fn use_imm<T>(_: &T) { } |
