aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust
diff options
context:
space:
mode:
authorKushal Pal <kushalpal109@gmail.com>2024-08-12 05:48:27 +0000
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-19 15:32:03 +0100
commit5c2ecc630d95077e533d6cac6bf6c4e0f16ba623 (patch)
tree96a799717af8d7dc93cfcede1757502f9db4d7e7 /gcc/testsuite/rust
parent9bba18fcb828ae2c4c85ba7ec1832923e04d2a75 (diff)
downloadgcc-5c2ecc630d95077e533d6cac6bf6c4e0f16ba623.zip
gcc-5c2ecc630d95077e533d6cac6bf6c4e0f16ba623.tar.gz
gcc-5c2ecc630d95077e533d6cac6bf6c4e0f16ba623.tar.bz2
gccrs: Move errors with locations
gcc/rust/ChangeLog: * checks/errors/borrowck/rust-borrow-checker-diagnostics.cc (BorrowCheckerDiagnostics::report_move_errors): Specify locations for code causing errors and related moves. gcc/testsuite/ChangeLog: * rust/borrowck/test_move.rs: Test rich-errors related to moves. * rust/borrowck/test_move_conditional.rs: Likewise. Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
Diffstat (limited to 'gcc/testsuite/rust')
-rw-r--r--gcc/testsuite/rust/borrowck/test_move.rs22
-rw-r--r--gcc/testsuite/rust/borrowck/test_move_conditional.rs45
2 files changed, 61 insertions, 6 deletions
diff --git a/gcc/testsuite/rust/borrowck/test_move.rs b/gcc/testsuite/rust/borrowck/test_move.rs
index 26a1a5b..b647583 100644
--- a/gcc/testsuite/rust/borrowck/test_move.rs
+++ b/gcc/testsuite/rust/borrowck/test_move.rs
@@ -1,11 +1,27 @@
-// { dg-additional-options "-frust-compile-until=compilation -frust-borrowcheck" }
-fn test_move() { // { dg-error "Found move errors in function test_move" }
+// { dg-additional-options "-frust-compile-until=compilation -frust-borrowcheck -fdiagnostics-show-caret -fdiagnostics-show-line-numbers" }
+// { dg-enable-nn-line-numbers "" }
+
+fn test_move() {
struct A {
i: i32,
}
let a = A { i: 1 };
let b = a;
- let c = a;
+ let c = a; //~ ERROR
+ // { dg-error "use of moved value" "" { target *-*-* } .-1 }
+ /*
+ { dg-begin-multiline-output "" }
+ NN | let b = a;
+ | ~
+ | |
+ | value moved here
+ NN | let c = a; //~ ERROR
+ | ^
+ | |
+ | moved value used here
+ { dg-end-multiline-output "" }
+ */
+
}
fn test_move_fixed() {
diff --git a/gcc/testsuite/rust/borrowck/test_move_conditional.rs b/gcc/testsuite/rust/borrowck/test_move_conditional.rs
index e1e8e20..94882bc 100644
--- a/gcc/testsuite/rust/borrowck/test_move_conditional.rs
+++ b/gcc/testsuite/rust/borrowck/test_move_conditional.rs
@@ -1,6 +1,7 @@
-// { dg-additional-options "-frust-compile-until=compilation -frust-borrowcheck" }
+// { dg-additional-options "-frust-compile-until=compilation -frust-borrowcheck -fdiagnostics-show-caret -fdiagnostics-show-line-numbers" }
+// { dg-enable-nn-line-numbers "" }
-fn test_move_conditional(b1: bool, b2:bool) { // { dg-error "Found move errors in function test_move" }
+fn test_move_conditional(b1: bool, b2:bool) {
struct A {
i: i32,
}
@@ -9,9 +10,47 @@ fn test_move_conditional(b1: bool, b2:bool) { // { dg-error "Found move errors i
let b = a;
if b1 {
let b = a;
+ // { dg-error "use of moved value" "" { target *-*-* } .-1 }
+ /*
+ { dg-begin-multiline-output "" }
+ NN | let b = a;
+ | ~
+ | |
+ | value moved here
+ NN | if b1 {
+ NN | let b = a;
+ | ~
+ | |
+ | value moved here
+......
+ NN | let c = a;
+ | ^
+ | |
+ | moved value used here
+ { dg-end-multiline-output "" }
+ */
}
if b2 {
let c = a;
+ // { dg-error "use of moved value" "" { target *-*-* } .-1 }
+ /*
+ { dg-begin-multiline-output "" }
+ NN | let b = a;
+ | ~
+ | |
+ | value moved here
+ NN | if b1 {
+ NN | let b = a;
+ | ^
+ | |
+ | moved value used here
+......
+ NN | let c = a;
+ | ~
+ | |
+ | value moved here
+ { dg-end-multiline-output "" }
+ */
}
}
@@ -25,4 +64,4 @@ fn test_move_fixed(b1: bool, b2:bool) {
if b2 {
let c = a;
}
-} \ No newline at end of file
+}