]> git.lizzy.rs Git - rust.git/commitdiff
adjust compile-fail error messages
authorRalf Jung <post@ralfj.de>
Tue, 16 Apr 2019 15:17:28 +0000 (17:17 +0200)
committerRalf Jung <post@ralfj.de>
Wed, 17 Apr 2019 14:02:57 +0000 (16:02 +0200)
This also passes miri-test-libstd!

32 files changed:
tests/compile-fail/stacked_borrows/alias_through_mutation.rs
tests/compile-fail/stacked_borrows/aliasing_mut3.rs
tests/compile-fail/stacked_borrows/box_exclusive_violation1.rs
tests/compile-fail/stacked_borrows/buggy_as_mut_slice.rs
tests/compile-fail/stacked_borrows/buggy_split_at_mut.rs
tests/compile-fail/stacked_borrows/illegal_read1.rs
tests/compile-fail/stacked_borrows/illegal_read2.rs
tests/compile-fail/stacked_borrows/illegal_read3.rs
tests/compile-fail/stacked_borrows/illegal_read4.rs
tests/compile-fail/stacked_borrows/illegal_read5.rs
tests/compile-fail/stacked_borrows/illegal_write1.rs
tests/compile-fail/stacked_borrows/illegal_write2.rs
tests/compile-fail/stacked_borrows/illegal_write3.rs
tests/compile-fail/stacked_borrows/illegal_write4.rs
tests/compile-fail/stacked_borrows/illegal_write5.rs
tests/compile-fail/stacked_borrows/load_invalid_mut.rs
tests/compile-fail/stacked_borrows/load_invalid_shr.rs
tests/compile-fail/stacked_borrows/mut_exclusive_violation1.rs
tests/compile-fail/stacked_borrows/outdated_local.rs
tests/compile-fail/stacked_borrows/pass_invalid_mut.rs
tests/compile-fail/stacked_borrows/pass_invalid_shr.rs
tests/compile-fail/stacked_borrows/pointer_smuggling.rs
tests/compile-fail/stacked_borrows/return_invalid_mut.rs
tests/compile-fail/stacked_borrows/return_invalid_mut_option.rs
tests/compile-fail/stacked_borrows/return_invalid_mut_tuple.rs
tests/compile-fail/stacked_borrows/return_invalid_shr.rs
tests/compile-fail/stacked_borrows/return_invalid_shr_option.rs
tests/compile-fail/stacked_borrows/return_invalid_shr_tuple.rs
tests/compile-fail/stacked_borrows/shr_frozen_violation1.rs
tests/compile-fail/stacked_borrows/static_memory_modification.rs
tests/compile-fail/stacked_borrows/transmute-is-no-escape.rs
tests/compile-fail/stacked_borrows/unescaped_local.rs

index 30f5921202c3ffb02b76fc126ee06bf03fcf21da..4a153d74ffb0b35a1eabd18ec0d6e03dfdcb1580 100644 (file)
@@ -9,5 +9,5 @@ fn main() {
     retarget(&mut target_alias, target);
     // now `target_alias` points to the same thing as `target`
     *target = 13;
-    let _val = *target_alias; //~ ERROR does not exist on the borrow stack
+    let _val = *target_alias; //~ ERROR borrow stack
 }
index e3c59d1566142f6255dea8ea5addf2316564ea82..3943e9576158cf9bd7e90a03848ef4e7160586a8 100644 (file)
@@ -1,6 +1,6 @@
 use std::mem;
 
-pub fn safe(_x: &mut i32, _y: &i32) {} //~ ERROR does not exist on the borrow stack
+pub fn safe(_x: &mut i32, _y: &i32) {} //~ ERROR borrow stack
 
 fn main() {
     let mut x = 0;
index 481915faed0401260af9e9a76a0004b1bbc250ac..7d7f5e24e2b0b06bc807b3a23300755ffd493e3d 100644 (file)
@@ -8,7 +8,7 @@ fn demo_mut_advanced_unique(mut our: Box<i32>) -> i32 {
   unknown_code_2();
 
   // We know this will return 5
-  *our //~ ERROR does not exist on the borrow stack
+  *our //~ ERROR borrow stack
 }
 
 // Now comes the evil context
index 98d4e6f22965dd24353bafe66f7e9ac430cbd394..9ff67ae354220c6e005d2f1eaf9124f92ae94d83 100644 (file)
@@ -13,5 +13,5 @@ fn main() {
     let v1 = safe::as_mut_slice(&v);
     let _v2 = safe::as_mut_slice(&v);
     v1[1] = 5;
-    //~^ ERROR does not exist on the borrow stack
+    //~^ ERROR borrow stack
 }
index 42f345f55144cd8a718d71fc860892d381d6397c..812dd47ef1d9068fb7aa15585eaa5a4d66df7493 100644 (file)
@@ -9,7 +9,7 @@ pub fn split_at_mut<T>(self_: &mut [T], mid: usize) -> (&mut [T], &mut [T]) {
             assert!(mid <= len);
 
             (from_raw_parts_mut(ptr, len - mid), // BUG: should be "mid" instead of "len - mid"
-            //~^ ERROR does not exist on the borrow stack
+            //~^ ERROR borrow stack
             from_raw_parts_mut(ptr.offset(mid as isize), len - mid))
         }
     }
index 3fb38abefdae483b2febb7e0f5706cd6397d072a..d942d2b27b999ac6b2438b74ae242156a7aa5255 100644 (file)
@@ -7,7 +7,7 @@ fn main() {
     let xref = unsafe { &mut *xraw }; // derived from raw, so using raw is still ok...
     callee(xraw);
     let _val = *xref; // ...but any use of raw will invalidate our ref.
-    //~^ ERROR: does not exist on the borrow stack
+    //~^ ERROR: borrow stack
 }
 
 fn callee(xraw: *mut i32) {
index e43340f0b8eed47866228397680ae778bd017435..c50c88d48f8c9383c30067df4a7b0d374698908e 100644 (file)
@@ -7,7 +7,7 @@ fn main() {
     let xref = unsafe { &mut *xraw }; // derived from raw, so using raw is still ok...
     callee(xraw);
     let _val = *xref; // ...but any use of raw will invalidate our ref.
-    //~^ ERROR: does not exist on the borrow stack
+    //~^ ERROR: borrow stack
 }
 
 fn callee(xraw: *mut i32) {
index b4abbb4a1aedf8005817f285b2441823bad4c02d..09fd5d534cf7d988986ade107de12b99b2894654 100644 (file)
@@ -15,7 +15,7 @@ fn main() {
     callee(xref1_sneaky);
     // ... though any use of it will invalidate our ref.
     let _val = *xref2;
-    //~^ ERROR: does not exist on the borrow stack
+    //~^ ERROR: borrow stack
 }
 
 fn callee(xref1: usize) {
index bb889de8f839eb7fdc07b16e369a50a4f3291dc5..d7e281e3ffe5c7de1a9d94937d1b315964732245 100644 (file)
@@ -5,5 +5,5 @@ fn main() {
     let xraw = xref1 as *mut _;
     let xref2 = unsafe { &mut *xraw };
     let _val = unsafe { *xraw }; // use the raw again, this invalidates xref2 *even* with the special read except for uniq refs
-    let _illegal = *xref2; //~ ERROR does not exist on the borrow stack
+    let _illegal = *xref2; //~ ERROR borrow stack
 }
index 0f4737f16e63d500343b78b28f15582b805ab0da..d6120cd64ad0075c70a4438607312f530d626231 100644 (file)
@@ -12,5 +12,5 @@ fn main() {
     let _val = *xref; // we can even still use our mutable reference
     mem::forget(unsafe { ptr::read(xshr) }); // but after reading through the shared ref
     let _val = *xref; // the mutable one is dead and gone
-    //~^ ERROR does not exist on the borrow stack
+    //~^ ERROR borrow stack
 }
index d0a23cb44489ae8ec4511c5f709cdc49371dd791..dd262a341ed2df1d2101352459288f4fa3b3c9af 100644 (file)
@@ -5,5 +5,5 @@ fn main() {
         let x : *mut u32 = xref as *const _ as *mut _;
         unsafe { *x = 42; } // invalidates shared ref, activates raw
     }
-    let _x = *xref; //~ ERROR is not frozen
+    let _x = *xref; //~ ERROR borrow stack
 }
index affa21c7625ead98ae207921dc55d799ca4545f1..62ea05e1811e717d60c1636449e9592369c5b714 100644 (file)
@@ -3,6 +3,6 @@ fn main() {
     let target2 = target as *mut _;
     drop(&mut *target); // reborrow
     // Now make sure our ref is still the only one.
-    unsafe { *target2 = 13; } //~ ERROR does not exist on the borrow stack
+    unsafe { *target2 = 13; } //~ ERROR borrow stack
     let _val = *target;
 }
index dc4edcc3a5b4496c5e0424ba68905379f2f52368..d2d8528d9078683334fc43bc3d62a778dc00012c 100644 (file)
@@ -3,6 +3,6 @@ fn main() {
     // Make sure raw ptr with raw tag cannot mutate frozen location without breaking the shared ref.
     let r#ref = &target; // freeze
     let ptr = r#ref as *const _ as *mut _; // raw ptr, with raw tag
-    unsafe { *ptr = 42; } //~ ERROR does not exist on the borrow stack
+    unsafe { *ptr = 42; } //~ ERROR borrow stack
     let _val = *r#ref;
 }
index 37ae0f055f0ee52ca6f4951d1e4ab226f3b775bb..be4f89ba289a14542e37b2aa0122a855f90396e4 100644 (file)
@@ -9,5 +9,5 @@ fn main() {
     let ptr = reference as *const _ as *mut i32; // raw ptr, with raw tag
     let _mut_ref: &mut i32 = unsafe { mem::transmute(ptr) }; // &mut, with raw tag
     // Now we retag, making our ref top-of-stack -- and, in particular, unfreezing.
-    let _val = *reference; //~ ERROR is not frozen
+    let _val = *reference; //~ ERROR borrow stack
 }
index 3a0738bfd0b855e90a309fd8b0d4dd9307bcef45..c60fe90fe05c7e798093cbb8dc6ba8e46934c687 100644 (file)
@@ -8,7 +8,7 @@ fn main() {
     callee(xraw);
     // ... though any use of raw value will invalidate our ref.
     let _val = *xref;
-    //~^ ERROR: does not exist on the borrow stack
+    //~^ ERROR: borrow stack
 }
 
 fn callee(xraw: *mut i32) {
index f2e4b36f85cc242234914854df72397a0b8eedea..1704b7fe19b2ed4be5ab1bf0a0507ca7763d60ea 100644 (file)
@@ -5,5 +5,5 @@ fn main() {
     let xref = unsafe { &mut *xraw };
     let xref_in_mem = Box::new(xref);
     let _val = unsafe { *xraw }; // invalidate xref
-    let _val = *xref_in_mem; //~ ERROR does not exist on the borrow stack
+    let _val = *xref_in_mem; //~ ERROR borrow stack
 }
index 6599924f0f4c49e92c9fa0e36dbfbbdda8cb1179..4757a2c1e58942f1d93444509cbeb480cce47461 100644 (file)
@@ -5,5 +5,5 @@ fn main() {
     let xref = unsafe { &*xraw };
     let xref_in_mem = Box::new(xref);
     unsafe { *xraw = 42 }; // unfreeze
-    let _val = *xref_in_mem; //~ ERROR is not frozen
+    let _val = *xref_in_mem; //~ ERROR borrow stack
 }
index 3fe6b6567423c80f9fd706c11f4469660c67254f..03343b985a0219b63402dd20340757ab2cbfa001 100644 (file)
@@ -21,7 +21,7 @@ fn unknown_code_1(x: &i32) { unsafe {
 } }
 
 fn unknown_code_2() { unsafe {
-    *LEAK = 7; //~ ERROR barrier
+    *LEAK = 7; //~ ERROR borrow stack
 } }
 
 fn main() {
index ba36e43e0c5d4c39ab960bdc0bc0c9d2f2ce8aa2..4cb655366ef1fc220f33827293ff322f478594db 100644 (file)
@@ -3,7 +3,7 @@ fn main() {
     let y: *const i32 = &x;
     x = 1; // this invalidates y by reactivating the lowermost uniq borrow for this local
 
-    assert_eq!(unsafe { *y }, 1); //~ ERROR does not exist on the borrow stack
+    assert_eq!(unsafe { *y }, 1); //~ ERROR borrow stack
 
     assert_eq!(x, 1);
 }
index b239237f019928e4a22209fba51a97859f143128..d8a53b7a96309ecc249344b4f38a096763ff586c 100644 (file)
@@ -6,5 +6,5 @@ fn main() {
     let xraw = x as *mut _;
     let xref = unsafe { &mut *xraw };
     let _val = unsafe { *xraw }; // invalidate xref
-    foo(xref); //~ ERROR does not exist on the borrow stack
+    foo(xref); //~ ERROR borrow stack
 }
index 22a80e27103e1ec126c86de0664ca8c89fde6f07..091604a283b9cd8ed6d64b6244d3152ce5c41b13 100644 (file)
@@ -6,5 +6,5 @@ fn main() {
     let xraw = x as *mut _;
     let xref = unsafe { &*xraw };
     unsafe { *xraw = 42 }; // unfreeze
-    foo(xref); //~ ERROR is not frozen
+    foo(xref); //~ ERROR borrow stack
 }
index a8207d58e99b23dccaf4a144175b61c8c96ab8d4..f724cdd2a7694e7f2261b1c061eec1ca95e99b16 100644 (file)
@@ -8,7 +8,7 @@ fn fun1(x: &mut u8) {
 
 fn fun2() {
     // Now we use a pointer we are not allowed to use
-    let _x = unsafe { *PTR }; //~ ERROR does not exist on the borrow stack
+    let _x = unsafe { *PTR }; //~ ERROR borrow stack
 }
 
 fn main() {
index 31f8a4e33afd906a77efb2d6ee58622d374bdc59..54004ec43882311e2e6d0ebb6c5fec655628101c 100644 (file)
@@ -3,7 +3,7 @@ fn foo(x: &mut (i32, i32)) -> &mut i32 {
     let xraw = x as *mut (i32, i32);
     let ret = unsafe { &mut (*xraw).1 };
     let _val = unsafe { *xraw }; // invalidate xref
-    ret //~ ERROR does not exist on the borrow stack
+    ret //~ ERROR borrow stack
 }
 
 fn main() {
index 750d507d6f660150f7ef96d20cbd2dea93768e59..2eb2df81f5f16dc0d2fa02b5a4aea4b2e4265abf 100644 (file)
@@ -3,7 +3,7 @@ fn foo(x: &mut (i32, i32)) -> Option<&mut i32> {
     let xraw = x as *mut (i32, i32);
     let ret = Some(unsafe { &mut (*xraw).1 });
     let _val = unsafe { *xraw }; // invalidate xref
-    ret //~ ERROR does not exist on the borrow stack
+    ret //~ ERROR borrow stack
 }
 
 fn main() {
index bb712e9e486cd6d977edaa4cafe5b5e18c2f24d3..8b73df4bd1ac343fd7e6644bb1fea8587f344243 100644 (file)
@@ -3,7 +3,7 @@ fn foo(x: &mut (i32, i32)) -> (&mut i32,) {
     let xraw = x as *mut (i32, i32);
     let ret = (unsafe { &mut (*xraw).1 },);
     let _val = unsafe { *xraw }; // invalidate xref
-    ret //~ ERROR does not exist on the borrow stack
+    ret //~ ERROR borrow stack
 }
 
 fn main() {
index 986dd18b2e0b4e1c1467c1bf68e1f9c69d4b2574..eab026f9a47c60a13681fda27cb4d122b456049d 100644 (file)
@@ -3,7 +3,7 @@ fn foo(x: &mut (i32, i32)) -> &i32 {
     let xraw = x as *mut (i32, i32);
     let ret = unsafe { &(*xraw).1 };
     unsafe { *xraw = (42, 23) }; // unfreeze
-    ret //~ ERROR is not frozen
+    ret //~ ERROR borrow stack
 }
 
 fn main() {
index 9d220991c330210cdeb66174c1217e782f7002d9..f3a35ca266c6bcfc570ac863095a2565773b83b4 100644 (file)
@@ -3,7 +3,7 @@ fn foo(x: &mut (i32, i32)) -> Option<&i32> {
     let xraw = x as *mut (i32, i32);
     let ret = Some(unsafe { &(*xraw).1 });
     unsafe { *xraw = (42, 23) }; // unfreeze
-    ret //~ ERROR is not frozen
+    ret //~ ERROR borrow stack
 }
 
 fn main() {
index 060fa25c2307e9f6e468a99fd20714f83a943ec2..82723bade27d7b362489fe38f847353466398493 100644 (file)
@@ -3,7 +3,7 @@ fn foo(x: &mut (i32, i32)) -> (&i32,) {
     let xraw = x as *mut (i32, i32);
     let ret = (unsafe { &(*xraw).1 },);
     unsafe { *xraw = (42, 23) }; // unfreeze
-    ret //~ ERROR is not frozen
+    ret //~ ERROR borrow stack
 }
 
 fn main() {
index 560c9dfb665dd518d2474531f54d1a1d80f1a25e..5031210c547b1c890174a4e73a39d0435a19bdab 100644 (file)
@@ -8,9 +8,6 @@ fn main() {
     println!("{}", foo(&mut 0));
 }
 
-// If we replace the `*const` by `&`, my current dev version of miri
-// *does* find the problem, but not for a good reason: It finds it because
-// of barriers, and we shouldn't rely on unknown code using barriers.
-fn unknown_code(x: *const i32) {
-    unsafe { *(x as *mut i32) = 7; } //~ ERROR barrier
+fn unknown_code(x: &i32) {
+    unsafe { *(x as *const i32 as *mut i32) = 7; } //~ ERROR borrow stack
 }
index c092cbfe5098594ea79af8b5da8019842b270410..88ac164947660d8beeab7df3f7223a6c01ce2f94 100644 (file)
@@ -3,6 +3,6 @@
 #[allow(mutable_transmutes)]
 fn main() {
     let _x = unsafe {
-        std::mem::transmute::<&usize, &mut usize>(&X) //~ ERROR mutable reference with frozen tag
+        std::mem::transmute::<&usize, &mut usize>(&X) //~ ERROR borrow stack
     };
 }
index 45ada88977788968f3f15be18ed4cae423f02ae1..e9282c5ba8f27e2ce9a2111d7fcb34bd820fb0ff 100644 (file)
@@ -10,5 +10,5 @@ fn main() {
     let _raw: *mut i32 = unsafe { mem::transmute(&mut x[0]) };
     // `raw` still carries a tag, so we get another pointer to the same location that does not carry a tag
     let raw = (&mut x[1] as *mut i32).wrapping_offset(-1);
-    unsafe { *raw = 13; } //~ ERROR does not exist on the borrow stack
+    unsafe { *raw = 13; } //~ ERROR borrow stack
 }
index 1db14ea7eda545e6f0bc72162fb05e5516a07452..b49e6cce63bc3fc32108d0143a27e8df8361517e 100644 (file)
@@ -4,5 +4,5 @@ fn main() {
     let mut x = 42;
     let raw = &mut x as *mut i32 as usize as *mut i32;
     let _ptr = &mut x;
-    unsafe { *raw = 13; } //~ ERROR does not exist on the borrow stack
+    unsafe { *raw = 13; } //~ ERROR borrow stack
 }