diff options
| author | bors <bors@rust-lang.org> | 2017-10-03 16:42:26 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-10-03 16:42:26 +0000 |
| commit | 835e3e50781af375e6fef2d17e1bfa50d4e4aba3 (patch) | |
| tree | 4d9a4fd2506bcb14b3c77990a7f6078305343d44 /src/test | |
| parent | 8891044e89a22eeed1fcea957140072c26fcc62e (diff) | |
| parent | d328d264aac91f8f5d0514d52d598277389e14e0 (diff) | |
| download | rust-835e3e50781af375e6fef2d17e1bfa50d4e4aba3.tar.gz rust-835e3e50781af375e6fef2d17e1bfa50d4e4aba3.zip | |
Auto merge of #44922 - zilbuz:issue-44596/E0594, r=pnkfelix
MIR borrowck: move span_label to `borrowck_errors.rs` The calls to `span_label` are moved and factorized for: * E0503 (`cannot_use_when_mutably_borrowed()`) * E0506 (`cannot_assign_to_borrowed()`) Additionnally, the error E0594 (`cannot_assign_static()`) has been factorized between `check_loan.rs` and `borrowc_check.rs`. Part of #44596
Diffstat (limited to 'src/test')
4 files changed, 44 insertions, 5 deletions
diff --git a/src/test/compile-fail/E0594.rs b/src/test/compile-fail/E0594.rs new file mode 100644 index 00000000000..8d33d658de9 --- /dev/null +++ b/src/test/compile-fail/E0594.rs @@ -0,0 +1,20 @@ +// 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. + +// revisions: ast mir +//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir + +static NUM: i32 = 18; + +fn main() { + NUM = 20; //[ast]~ ERROR E0594 + //[mir]~^ ERROR cannot assign to immutable static item (Ast) + //[mir]~| ERROR cannot assign to immutable static item `NUM` (Mir) +} diff --git a/src/test/compile-fail/borrowck/borrowck-assign-to-constants.rs b/src/test/compile-fail/borrowck/borrowck-assign-to-constants.rs index 1b5b1899e0d..3c93a391a6b 100644 --- a/src/test/compile-fail/borrowck/borrowck-assign-to-constants.rs +++ b/src/test/compile-fail/borrowck/borrowck-assign-to-constants.rs @@ -8,9 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// revisions: ast mir +//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir + static foo: isize = 5; fn main() { // assigning to various global constants - foo = 6; //~ ERROR cannot assign to immutable static item + foo = 6; //[ast]~ ERROR cannot assign to immutable static item + //[mir]~^ ERROR cannot assign to immutable static item (Ast) + //[mir]~| ERROR cannot assign to immutable static item `foo` (Mir) } diff --git a/src/test/compile-fail/borrowck/borrowck-overloaded-index-ref-index.rs b/src/test/compile-fail/borrowck/borrowck-overloaded-index-ref-index.rs index 4c50caf4976..7f165e00edb 100644 --- a/src/test/compile-fail/borrowck/borrowck-overloaded-index-ref-index.rs +++ b/src/test/compile-fail/borrowck/borrowck-overloaded-index-ref-index.rs @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// revisions: ast mir +//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir + use std::ops::{Index, IndexMut}; struct Foo { @@ -57,12 +60,18 @@ fn main() { let mut s = "hello".to_string(); let rs = &mut s; println!("{}", f[&s]); - //~^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable + //[ast]~^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable + //[mir]~^^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable (Ast) + //[mir]~| ERROR cannot borrow `s` as immutable because it is also borrowed as mutable (Mir) f[&s] = 10; - //~^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable + //[ast]~^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable + //[mir]~^^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable (Ast) + //[mir]~| ERROR cannot borrow `s` as immutable because it is also borrowed as mutable (Mir) let s = Bar { x: 1, }; s[2] = 20; - //~^ ERROR cannot assign to immutable indexed content + //[ast]~^ ERROR cannot assign to immutable indexed content + //[mir]~^^ ERROR cannot assign to immutable indexed content + // FIXME Error for MIR } diff --git a/src/test/compile-fail/issue-5500-1.rs b/src/test/compile-fail/issue-5500-1.rs index 7e5809cdee0..2c2c32c0e88 100644 --- a/src/test/compile-fail/issue-5500-1.rs +++ b/src/test/compile-fail/issue-5500-1.rs @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// revisions: ast mir +//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir + struct TrieMapIterator<'a> { node: &'a usize } @@ -15,6 +18,8 @@ struct TrieMapIterator<'a> { fn main() { let a = 5; let _iter = TrieMapIterator{node: &a}; - _iter.node = & //~ ERROR cannot assign to immutable field + _iter.node = & //[ast]~ ERROR cannot assign to immutable field + //[mir]~^ ERROR cannot assign to immutable field `_iter.node` (Ast) + // FIXME Error for MIR panic!() } |
