mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-17 22:46:50 +00:00
Unit tests for gathering and reporting move-errors from mir-borrowck.
This commit tests *just* the subset of the tests that were previously ICE'ing and where now AST- and MIR-borrowck both match in terms of the errors they report. In other words: there remain *other* tests that previously ICE'd, and now no longer ICE, but their remains a divergence between the errors reported by AST-borrowck and by MIR-borrowck.
This commit is contained in:
parent
5a16ef4936
commit
86ca5cf942
@ -8,12 +8,17 @@
|
||||
// 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
|
||||
|
||||
// Check that we check fns appearing in constant declarations.
|
||||
// Issue #22382.
|
||||
|
||||
const MOVE: fn(&String) -> String = {
|
||||
fn broken(x: &String) -> String {
|
||||
return *x //~ ERROR cannot move
|
||||
return *x //[ast]~ ERROR cannot move out of borrowed content [E0507]
|
||||
//[mir]~^ ERROR (Ast) [E0507]
|
||||
//[mir]~| ERROR (Mir) [E0507]
|
||||
}
|
||||
broken
|
||||
};
|
||||
|
@ -8,19 +8,28 @@
|
||||
// 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
|
||||
|
||||
fn with<F>(f: F) where F: FnOnce(&String) {}
|
||||
|
||||
fn arg_item(&_x: &String) {}
|
||||
//~^ ERROR cannot move out of borrowed content
|
||||
//[ast]~^ ERROR cannot move out of borrowed content [E0507]
|
||||
//[mir]~^^ ERROR (Ast) [E0507]
|
||||
//[mir]~| ERROR (Mir) [E0507]
|
||||
|
||||
fn arg_closure() {
|
||||
with(|&_x| ())
|
||||
//~^ ERROR cannot move out of borrowed content
|
||||
//[ast]~^ ERROR cannot move out of borrowed content [E0507]
|
||||
//[mir]~^^ ERROR (Ast) [E0507]
|
||||
//[mir]~| ERROR (Mir) [E0507]
|
||||
}
|
||||
|
||||
fn let_pat() {
|
||||
let &_x = &"hi".to_string();
|
||||
//~^ ERROR cannot move out of borrowed content
|
||||
//[ast]~^ ERROR cannot move out of borrowed content [E0507]
|
||||
//[mir]~^^ ERROR (Ast) [E0507]
|
||||
//[mir]~| ERROR (Mir) [E0507]
|
||||
}
|
||||
|
||||
pub fn main() {}
|
||||
|
@ -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
|
||||
|
||||
use std::rc::Rc;
|
||||
|
||||
pub fn main() {
|
||||
let _x = Rc::new(vec![1, 2]).into_iter();
|
||||
//~^ ERROR cannot move out of borrowed content
|
||||
//[ast]~^ ERROR cannot move out of borrowed content [E0507]
|
||||
//[mir]~^^ ERROR (Ast) [E0507]
|
||||
//[mir]~| ERROR (Mir) [E0507]
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
// Ensure that moves out of static items is forbidden
|
||||
|
||||
struct Foo {
|
||||
@ -22,5 +25,7 @@ fn test(f: Foo) {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
test(BAR); //~ ERROR cannot move out of static item
|
||||
test(BAR); //[ast]~ ERROR cannot move out of static item [E0507]
|
||||
//[mir]~^ ERROR (Ast) [E0507]
|
||||
//[mir]~| ERROR (Mir) [E0507]
|
||||
}
|
||||
|
@ -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 S {f:String}
|
||||
impl Drop for S {
|
||||
fn drop(&mut self) { println!("{}", self.f); }
|
||||
@ -16,17 +19,23 @@ impl Drop for S {
|
||||
fn move_in_match() {
|
||||
match (S {f:"foo".to_string()}) {
|
||||
S {f:_s} => {}
|
||||
//~^ ERROR cannot move out of type `S`, which implements the `Drop` trait
|
||||
//[ast]~^ ERROR cannot move out of type `S`, which implements the `Drop` trait [E0509]
|
||||
//[mir]~^^ ERROR (Ast) [E0509]
|
||||
//[mir]~| ERROR (Mir) [E0509]
|
||||
}
|
||||
}
|
||||
|
||||
fn move_in_let() {
|
||||
let S {f:_s} = S {f:"foo".to_string()};
|
||||
//~^ ERROR cannot move out of type `S`, which implements the `Drop` trait
|
||||
//[ast]~^ ERROR cannot move out of type `S`, which implements the `Drop` trait [E0509]
|
||||
//[mir]~^^ ERROR (Ast) [E0509]
|
||||
//[mir]~| ERROR (Mir) [E0509]
|
||||
}
|
||||
|
||||
fn move_in_fn_arg(S {f:_s}: S) {
|
||||
//~^ ERROR cannot move out of type `S`, which implements the `Drop` trait
|
||||
//[ast]~^ ERROR cannot move out of type `S`, which implements the `Drop` trait [E0509]
|
||||
//[mir]~^^ ERROR (Ast) [E0509]
|
||||
//[mir]~| ERROR (Mir) [E0509]
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -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
|
||||
|
||||
// Issue 4691: Ensure that functional-struct-update can only copy, not
|
||||
// move, when the struct implements Drop.
|
||||
|
||||
@ -20,12 +23,16 @@ impl Drop for T { fn drop(&mut self) { } }
|
||||
|
||||
fn f(s0:S) {
|
||||
let _s2 = S{a: 2, ..s0};
|
||||
//~^ error: cannot move out of type `S`, which implements the `Drop` trait
|
||||
//[ast]~^ error: cannot move out of type `S`, which implements the `Drop` trait
|
||||
//[mir]~^^ ERROR (Ast) [E0509]
|
||||
//[mir]~| ERROR (Mir) [E0509]
|
||||
}
|
||||
|
||||
fn g(s0:T) {
|
||||
let _s2 = T{a: 2, ..s0};
|
||||
//~^ error: cannot move out of type `T`, which implements the `Drop` trait
|
||||
//[ast]~^ error: cannot move out of type `T`, which implements the `Drop` trait
|
||||
//[mir]~^^ ERROR (Ast) [E0509]
|
||||
//[mir]~| ERROR (Mir) [E0509]
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
@ -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
|
||||
|
||||
// Regression test for #38520. Check that moves of `Foo` are not
|
||||
// permitted as `Foo` is not copy (even in a static/const
|
||||
// initializer).
|
||||
@ -21,8 +24,12 @@ const fn get(x: Foo) -> usize {
|
||||
}
|
||||
|
||||
const X: Foo = Foo(22);
|
||||
static Y: usize = get(*&X); //~ ERROR E0507
|
||||
const Z: usize = get(*&X); //~ ERROR E0507
|
||||
static Y: usize = get(*&X); //[ast]~ ERROR E0507
|
||||
//[mir]~^ ERROR (Ast) [E0507]
|
||||
//[mir]~| ERROR (Mir) [E0507]
|
||||
const Z: usize = get(*&X); //[ast]~ ERROR E0507
|
||||
//[mir]~^ ERROR (Ast) [E0507]
|
||||
//[mir]~| ERROR (Mir) [E0507]
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user